tee3apps-cms-sdk-react 0.0.1
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/.env +11 -0
- package/README.md +255 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +33 -0
- package/rollup.config.js +43 -0
- package/src/Components/BoxRenderer.tsx +108 -0
- package/src/Components/ComponentRenderer.tsx +29 -0
- package/src/Components/ImageComponent.tsx +68 -0
- package/src/Components/RowComponent.tsx +66 -0
- package/src/Components/TextComponent.tsx +47 -0
- package/src/ErrorBoundary.tsx +35 -0
- package/src/Page.tsx +124 -0
- package/src/PageComponents/BoxComponent.tsx +397 -0
- package/src/PageComponents/RowComponent.tsx +113 -0
- package/src/PageComponents/Visual-Components/CarouselComponent.tsx +366 -0
- package/src/PageComponents/Visual-Components/GroupBrandComponent.tsx +391 -0
- package/src/PageComponents/Visual-Components/GroupCategoryComponent.tsx +425 -0
- package/src/PageComponents/Visual-Components/GroupImageList.tsx +669 -0
- package/src/PageComponents/Visual-Components/GroupProductComponent.tsx +671 -0
- package/src/PageComponents/Visual-Components/GroupVideoList.tsx +590 -0
- package/src/PageComponents/Visual-Components/ImageComponent.tsx +163 -0
- package/src/PageComponents/Visual-Components/LinkComponent.tsx +68 -0
- package/src/PageComponents/Visual-Components/LottieComponent.tsx +213 -0
- package/src/PageComponents/Visual-Components/NavigationComponent.tsx +178 -0
- package/src/PageComponents/Visual-Components/Styles/ProductListViewOne.tsx +102 -0
- package/src/PageComponents/Visual-Components/Styles/ProductListViewTwo.tsx +104 -0
- package/src/PageComponents/Visual-Components/Styles/product-list-view-one.css +166 -0
- package/src/PageComponents/Visual-Components/Styles/product-list-view-two.css +182 -0
- package/src/PageComponents/Visual-Components/TabComponent.tsx +1169 -0
- package/src/PageComponents/Visual-Components/TextComponent.tsx +114 -0
- package/src/PageComponents/Visual-Components/VideoComponent.tsx +191 -0
- package/src/PageComponents/Visual-Components/tab.css +697 -0
- package/src/common.interface.ts +216 -0
- package/src/const.ts +6 -0
- package/src/env.d.ts +15 -0
- package/src/index.css +82 -0
- package/src/index.ts +2 -0
- package/src/types.ts +234 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Linodeurl } from '../../const';
|
|
3
|
+
|
|
4
|
+
interface PageImage {
|
|
5
|
+
shapeImageId: string;
|
|
6
|
+
shape: string;
|
|
7
|
+
isDynamic: string;
|
|
8
|
+
url: string;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface PageId {
|
|
14
|
+
_id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
code: string;
|
|
17
|
+
image: PageImage;
|
|
18
|
+
isActive: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Channel {
|
|
22
|
+
_id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
code: string;
|
|
25
|
+
isActive: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface PageDataItem {
|
|
29
|
+
page_id: any;
|
|
30
|
+
channel: Channel;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface CategoryImage {
|
|
34
|
+
shapeImageId: string;
|
|
35
|
+
shape: string;
|
|
36
|
+
isDynamic: boolean | string;
|
|
37
|
+
url: string;
|
|
38
|
+
width?: number;
|
|
39
|
+
height?: number;
|
|
40
|
+
alt?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface CategoryItem {
|
|
44
|
+
_id?: string;
|
|
45
|
+
code: string;
|
|
46
|
+
name: any;
|
|
47
|
+
image?: CategoryImage;
|
|
48
|
+
parent?: string | null;
|
|
49
|
+
pages?: PageDataItem[];
|
|
50
|
+
children?: CategoryItem[];
|
|
51
|
+
fullPath?: string;
|
|
52
|
+
isActive?: boolean;
|
|
53
|
+
isDeleted?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface GroupCategoryStatic {
|
|
57
|
+
_id: string;
|
|
58
|
+
code: string;
|
|
59
|
+
name: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface GroupCategoryDynamic {
|
|
63
|
+
code: string;
|
|
64
|
+
name: { all: string };
|
|
65
|
+
channel: string;
|
|
66
|
+
list: CategoryItem[];
|
|
67
|
+
isActive?: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface GroupCategoryData {
|
|
71
|
+
static: GroupCategoryStatic;
|
|
72
|
+
dynamic: GroupCategoryDynamic;
|
|
73
|
+
showItems: CategoryItem[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface HeaderTextStyle {
|
|
77
|
+
fontSize: number;
|
|
78
|
+
fontColor: string;
|
|
79
|
+
isBold: boolean;
|
|
80
|
+
isItalic: boolean;
|
|
81
|
+
isUnderline: boolean;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface DeviceBooleanProps {
|
|
85
|
+
web: boolean;
|
|
86
|
+
mobileweb: boolean;
|
|
87
|
+
mobileapp: boolean;
|
|
88
|
+
tablet: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface DeviceLayoutProps {
|
|
92
|
+
web: string;
|
|
93
|
+
mobileweb: string;
|
|
94
|
+
mobileapp: string;
|
|
95
|
+
tablet: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface GroupCategoryComponentProps {
|
|
99
|
+
nameData: any;
|
|
100
|
+
type: string;
|
|
101
|
+
groupcategory: GroupCategoryData;
|
|
102
|
+
showItems?: CategoryItem[];
|
|
103
|
+
selectedCategories?: CategoryItem[];
|
|
104
|
+
items?: CategoryItem[];
|
|
105
|
+
activeStatus: boolean;
|
|
106
|
+
headerImage: string;
|
|
107
|
+
headerTextStyle: HeaderTextStyle;
|
|
108
|
+
layout: DeviceLayoutProps;
|
|
109
|
+
showHeader: DeviceBooleanProps;
|
|
110
|
+
showCategoryName: DeviceBooleanProps;
|
|
111
|
+
isHorizontalScroll: DeviceBooleanProps;
|
|
112
|
+
headerBackground: string;
|
|
113
|
+
carouselBackground: string;
|
|
114
|
+
channelid: string;
|
|
115
|
+
selectedChannel: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface GroupCategoryComponentMainProps {
|
|
119
|
+
props: GroupCategoryComponentProps;
|
|
120
|
+
deviceMode?: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const GroupCategoryComponent: React.FC<GroupCategoryComponentMainProps> = ({ props, deviceMode = 'web' }) => {
|
|
124
|
+
const getCurrentBooleanProp = (prop?: DeviceBooleanProps) => {
|
|
125
|
+
if (!prop) return false;
|
|
126
|
+
switch (deviceMode) {
|
|
127
|
+
case 'mobileweb': return !!prop.mobileweb;
|
|
128
|
+
case 'mobileapp': return !!prop.mobileapp;
|
|
129
|
+
case 'tablet': return !!prop.tablet;
|
|
130
|
+
case 'web':
|
|
131
|
+
default: return !!prop.web;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const getCurrentLayout = () => {
|
|
136
|
+
if (!props.layout) return 'NONE';
|
|
137
|
+
switch (deviceMode) {
|
|
138
|
+
case 'mobileweb': return props.layout.mobileweb ;
|
|
139
|
+
case 'mobileapp': return props.layout.mobileapp ;
|
|
140
|
+
case 'tablet': return props.layout.tablet ;
|
|
141
|
+
case 'web':
|
|
142
|
+
default: return props.layout.web ;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const showHeader = getCurrentBooleanProp(props.showHeader);
|
|
147
|
+
const showCategoryName = getCurrentBooleanProp(props.showCategoryName);
|
|
148
|
+
const isHorizontalScroll = getCurrentBooleanProp(props.isHorizontalScroll);
|
|
149
|
+
const currentLayout = getCurrentLayout();
|
|
150
|
+
|
|
151
|
+
const getCategories = (): CategoryItem[] => {
|
|
152
|
+
if (props.groupcategory?.showItems) {
|
|
153
|
+
if (props.groupcategory?.showItems?.length) return props.groupcategory?.showItems;
|
|
154
|
+
}
|
|
155
|
+
return [];
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const categories = getCategories();
|
|
159
|
+
|
|
160
|
+
// Carousel navigation buttons (layout NONE)
|
|
161
|
+
const scrollLeft = () => {
|
|
162
|
+
const carousel = document.querySelector('.groupCategoryCarousel');
|
|
163
|
+
if (carousel) {
|
|
164
|
+
(carousel as HTMLElement).scrollBy({ left: -200, behavior: 'smooth' });
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const scrollRight = () => {
|
|
169
|
+
const carousel = document.querySelector('.groupCategoryCarousel');
|
|
170
|
+
if (carousel) {
|
|
171
|
+
(carousel as HTMLElement).scrollBy({ left: 200, behavior: 'smooth' });
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const getImageUrl = (url: string) => {
|
|
176
|
+
if (!url) return '';
|
|
177
|
+
if (url.startsWith('http://') || url.startsWith('https://')) return url;
|
|
178
|
+
return `${Linodeurl}${url}`;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const buildCategoryHref = (item: CategoryItem): string | null => {
|
|
182
|
+
if (item.pages && item.pages.length > 0) {
|
|
183
|
+
const firstPage = item.pages[0];
|
|
184
|
+
console.log(firstPage.page_id);
|
|
185
|
+
// Return only if page is active
|
|
186
|
+
if (firstPage.page_id) {
|
|
187
|
+
return `/page/${encodeURIComponent(firstPage.page_id)}?type=category`;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// No valid active page — don't return href
|
|
192
|
+
return null;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const Card = ({ item, large = false }: { item: CategoryItem; large?: boolean }) => {
|
|
196
|
+
const href = buildCategoryHref(item);
|
|
197
|
+
const Wrapper: React.FC<{ children: React.ReactNode }> = ({ children }) =>
|
|
198
|
+
href ? (
|
|
199
|
+
<a href={href} style={{ textDecoration: 'none', color: 'inherit' }}>
|
|
200
|
+
{children}
|
|
201
|
+
</a>
|
|
202
|
+
) : (
|
|
203
|
+
<>{children}</>
|
|
204
|
+
);
|
|
205
|
+
return (
|
|
206
|
+
<Wrapper>
|
|
207
|
+
<div
|
|
208
|
+
className="categoryCard"
|
|
209
|
+
style={{
|
|
210
|
+
height:'100%',
|
|
211
|
+
|
|
212
|
+
borderRadius: '8px',
|
|
213
|
+
overflow: 'hidden',
|
|
214
|
+
border: '1px solid #eee',
|
|
215
|
+
backgroundColor: '#fff',
|
|
216
|
+
display: 'flex',
|
|
217
|
+
flexDirection: 'column',
|
|
218
|
+
alignItems: 'center',
|
|
219
|
+
justifyContent: 'center',
|
|
220
|
+
padding: large ? '16px' : '12px',
|
|
221
|
+
boxShadow: '0 2px 4px rgba(0,0,0,0.1)',
|
|
222
|
+
transition: 'transform 0.2s ease',
|
|
223
|
+
cursor: href ? 'pointer' : 'default',
|
|
224
|
+
}}
|
|
225
|
+
onMouseOver={(e) => {
|
|
226
|
+
(e.currentTarget as HTMLDivElement).style.transform = 'translateY(-2px)';
|
|
227
|
+
(e.currentTarget as HTMLDivElement).style.boxShadow = '0 4px 8px rgba(0,0,0,0.15)';
|
|
228
|
+
}}
|
|
229
|
+
onMouseOut={(e) => {
|
|
230
|
+
(e.currentTarget as HTMLDivElement).style.transform = 'translateY(0)';
|
|
231
|
+
(e.currentTarget as HTMLDivElement).style.boxShadow = '0 2px 4px rgba(0,0,0,0.1)';
|
|
232
|
+
}}
|
|
233
|
+
>
|
|
234
|
+
{item.image && (
|
|
235
|
+
<div
|
|
236
|
+
style={{
|
|
237
|
+
height: large ? '160px' : '120px',
|
|
238
|
+
width: '100%',
|
|
239
|
+
display: 'flex',
|
|
240
|
+
alignItems: 'center',
|
|
241
|
+
justifyContent: 'center',
|
|
242
|
+
marginBottom: large ? '12px' : '8px',
|
|
243
|
+
}}
|
|
244
|
+
>
|
|
245
|
+
<img
|
|
246
|
+
src={getImageUrl(item.image.url)}
|
|
247
|
+
alt={item.image.alt || item.name?.all || ''}
|
|
248
|
+
style={{ width: '100%', height: '100%', objectFit: 'contain' }}
|
|
249
|
+
/>
|
|
250
|
+
</div>
|
|
251
|
+
)}
|
|
252
|
+
|
|
253
|
+
{showCategoryName && (
|
|
254
|
+
<div
|
|
255
|
+
style={{
|
|
256
|
+
textAlign: 'center',
|
|
257
|
+
fontSize: large ? '16px' : '14px',
|
|
258
|
+
fontWeight: large ? 600 : 500,
|
|
259
|
+
color: '#333',
|
|
260
|
+
lineHeight: '1.4',
|
|
261
|
+
height: large ? 'auto' : '40px',
|
|
262
|
+
overflow: 'hidden',
|
|
263
|
+
display: large ? 'block' : '-webkit-box',
|
|
264
|
+
WebkitLineClamp: large ? undefined : 2,
|
|
265
|
+
WebkitBoxOrient: 'vertical',
|
|
266
|
+
}}
|
|
267
|
+
>
|
|
268
|
+
{item.name}
|
|
269
|
+
</div>
|
|
270
|
+
)}
|
|
271
|
+
</div>
|
|
272
|
+
</Wrapper>
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
return (
|
|
277
|
+
<div
|
|
278
|
+
style={{
|
|
279
|
+
border: '1px solid #e1e1e1',
|
|
280
|
+
width: '100%',
|
|
281
|
+
maxWidth: '100%',
|
|
282
|
+
borderRadius: '0px',
|
|
283
|
+
minHeight: '100px',
|
|
284
|
+
position: 'relative',
|
|
285
|
+
overflow: 'hidden',
|
|
286
|
+
marginBottom: '20px',
|
|
287
|
+
marginTop: '0px',
|
|
288
|
+
height:'100%'
|
|
289
|
+
}}
|
|
290
|
+
className='GroupCategoryComponent'
|
|
291
|
+
>
|
|
292
|
+
{showHeader && (
|
|
293
|
+
<div
|
|
294
|
+
className="groupCategoryHeader"
|
|
295
|
+
style={{
|
|
296
|
+
backgroundColor: props.headerBackground,
|
|
297
|
+
padding: '12px 16px',
|
|
298
|
+
borderRadius: '0px',
|
|
299
|
+
marginBottom: '4px',
|
|
300
|
+
display: 'flex',
|
|
301
|
+
alignItems: 'center',
|
|
302
|
+
justifyContent: 'space-between',
|
|
303
|
+
flexWrap: 'wrap',
|
|
304
|
+
gap: '12px',
|
|
305
|
+
}}
|
|
306
|
+
>
|
|
307
|
+
<p style={{
|
|
308
|
+
color: props.headerTextStyle.fontColor,
|
|
309
|
+
fontSize: `${props.headerTextStyle.fontSize}px`,
|
|
310
|
+
fontWeight: props.headerTextStyle.isBold ? 'bold' : 'normal',
|
|
311
|
+
fontStyle: props.headerTextStyle.isItalic ? 'italic' : 'normal',
|
|
312
|
+
textDecoration: props.headerTextStyle.isUnderline ? 'underline' : 'none',
|
|
313
|
+
margin: 0
|
|
314
|
+
}}>
|
|
315
|
+
{props.nameData || 'Categories'}
|
|
316
|
+
</p>
|
|
317
|
+
|
|
318
|
+
{currentLayout === 'NONE' && categories.length > 0 && (
|
|
319
|
+
<div style={{ display: 'flex', gap: '8px' }}>
|
|
320
|
+
<button
|
|
321
|
+
onClick={scrollLeft}
|
|
322
|
+
style={{
|
|
323
|
+
width: '32px',
|
|
324
|
+
height: '32px',
|
|
325
|
+
borderRadius: '50%',
|
|
326
|
+
border: '1px solid #ddd',
|
|
327
|
+
backgroundColor: '#fff',
|
|
328
|
+
cursor: 'pointer',
|
|
329
|
+
display: 'flex',
|
|
330
|
+
alignItems: 'center',
|
|
331
|
+
justifyContent: 'center',
|
|
332
|
+
fontSize: '16px',
|
|
333
|
+
fontWeight: 'bold'
|
|
334
|
+
}}
|
|
335
|
+
onMouseOver={(e) => { e.currentTarget.style.backgroundColor = '#f8f9fa'; }}
|
|
336
|
+
onMouseOut={(e) => { e.currentTarget.style.backgroundColor = '#fff'; }}
|
|
337
|
+
>
|
|
338
|
+
‹
|
|
339
|
+
</button>
|
|
340
|
+
<button
|
|
341
|
+
onClick={scrollRight}
|
|
342
|
+
style={{
|
|
343
|
+
width: '32px',
|
|
344
|
+
height: '32px',
|
|
345
|
+
borderRadius: '50%',
|
|
346
|
+
border: '1px solid #ddd',
|
|
347
|
+
backgroundColor: '#fff',
|
|
348
|
+
cursor: 'pointer',
|
|
349
|
+
display: 'flex',
|
|
350
|
+
alignItems: 'center',
|
|
351
|
+
justifyContent: 'center',
|
|
352
|
+
fontSize: '16px',
|
|
353
|
+
fontWeight: 'bold'
|
|
354
|
+
}}
|
|
355
|
+
onMouseOver={(e) => { e.currentTarget.style.backgroundColor = '#f8f9fa'; }}
|
|
356
|
+
onMouseOut={(e) => { e.currentTarget.style.backgroundColor = '#fff'; }}
|
|
357
|
+
>
|
|
358
|
+
›
|
|
359
|
+
</button>
|
|
360
|
+
</div>
|
|
361
|
+
)}
|
|
362
|
+
</div>
|
|
363
|
+
)}
|
|
364
|
+
|
|
365
|
+
<div
|
|
366
|
+
style={{
|
|
367
|
+
display: currentLayout === 'NONE' ? 'flex' : 'block',
|
|
368
|
+
overflowX: currentLayout === 'NONE' ? (isHorizontalScroll ? 'auto' : 'hidden') : 'visible',
|
|
369
|
+
gap: currentLayout === 'NONE' ? '12px' : '0',
|
|
370
|
+
padding: '12px',
|
|
371
|
+
scrollBehavior: 'smooth',
|
|
372
|
+
backgroundColor: props.carouselBackground || '#fff',
|
|
373
|
+
scrollbarWidth: 'thin',
|
|
374
|
+
borderRadius: '8px',
|
|
375
|
+
position: 'relative',
|
|
376
|
+
scrollbarColor: '#c1c1c1 transparent'
|
|
377
|
+
, height:'100%'
|
|
378
|
+
|
|
379
|
+
}}
|
|
380
|
+
className="groupCategoryCarousel"
|
|
381
|
+
>
|
|
382
|
+
{categories.length > 0 ? (
|
|
383
|
+
currentLayout === 'NONE' ? (
|
|
384
|
+
categories.map((category) => (
|
|
385
|
+
<div key={category.code} style={{ minWidth: '150px' ,height:'30%'}}>
|
|
386
|
+
<Card item={category} />
|
|
387
|
+
</div>
|
|
388
|
+
))
|
|
389
|
+
) : currentLayout === 'SMALL' ? (
|
|
390
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '16px', padding: '8px' }}>
|
|
391
|
+
{categories.map((category) => (
|
|
392
|
+
<Card key={category.code} item={category} />
|
|
393
|
+
))}
|
|
394
|
+
</div>
|
|
395
|
+
) : currentLayout === 'MEDIUM' ? (
|
|
396
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: '16px', padding: '8px' }}>
|
|
397
|
+
{categories.map((category) => (
|
|
398
|
+
<Card key={category.code} item={category} />
|
|
399
|
+
))}
|
|
400
|
+
</div>
|
|
401
|
+
) : currentLayout === 'MEDIUM_THREE' ? (
|
|
402
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', padding: '8px' }}>
|
|
403
|
+
{categories.length > 0 && (
|
|
404
|
+
<Card item={categories[0]} large />
|
|
405
|
+
)}
|
|
406
|
+
{categories.length > 1 && (
|
|
407
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '16px' }}>
|
|
408
|
+
{categories.slice(1).map((category) => (
|
|
409
|
+
<Card key={category.code} item={category} />
|
|
410
|
+
))}
|
|
411
|
+
</div>
|
|
412
|
+
)}
|
|
413
|
+
</div>
|
|
414
|
+
) : null
|
|
415
|
+
) : (
|
|
416
|
+
<div style={{ textAlign: 'center', color: '#666', padding: '40px', width: '100%', border: '2px dashed #ddd', borderRadius: '8px', backgroundColor: '#f9f9f9' }}>
|
|
417
|
+
<p>No categories available.</p>
|
|
418
|
+
</div>
|
|
419
|
+
)}
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
);
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
export default GroupCategoryComponent;
|