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.
Files changed (43) hide show
  1. package/.env +11 -0
  2. package/README.md +255 -0
  3. package/dist/index.d.ts +5 -0
  4. package/dist/index.js +13 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +13 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +33 -0
  9. package/rollup.config.js +43 -0
  10. package/src/Components/BoxRenderer.tsx +108 -0
  11. package/src/Components/ComponentRenderer.tsx +29 -0
  12. package/src/Components/ImageComponent.tsx +68 -0
  13. package/src/Components/RowComponent.tsx +66 -0
  14. package/src/Components/TextComponent.tsx +47 -0
  15. package/src/ErrorBoundary.tsx +35 -0
  16. package/src/Page.tsx +124 -0
  17. package/src/PageComponents/BoxComponent.tsx +397 -0
  18. package/src/PageComponents/RowComponent.tsx +113 -0
  19. package/src/PageComponents/Visual-Components/CarouselComponent.tsx +366 -0
  20. package/src/PageComponents/Visual-Components/GroupBrandComponent.tsx +391 -0
  21. package/src/PageComponents/Visual-Components/GroupCategoryComponent.tsx +425 -0
  22. package/src/PageComponents/Visual-Components/GroupImageList.tsx +669 -0
  23. package/src/PageComponents/Visual-Components/GroupProductComponent.tsx +671 -0
  24. package/src/PageComponents/Visual-Components/GroupVideoList.tsx +590 -0
  25. package/src/PageComponents/Visual-Components/ImageComponent.tsx +163 -0
  26. package/src/PageComponents/Visual-Components/LinkComponent.tsx +68 -0
  27. package/src/PageComponents/Visual-Components/LottieComponent.tsx +213 -0
  28. package/src/PageComponents/Visual-Components/NavigationComponent.tsx +178 -0
  29. package/src/PageComponents/Visual-Components/Styles/ProductListViewOne.tsx +102 -0
  30. package/src/PageComponents/Visual-Components/Styles/ProductListViewTwo.tsx +104 -0
  31. package/src/PageComponents/Visual-Components/Styles/product-list-view-one.css +166 -0
  32. package/src/PageComponents/Visual-Components/Styles/product-list-view-two.css +182 -0
  33. package/src/PageComponents/Visual-Components/TabComponent.tsx +1169 -0
  34. package/src/PageComponents/Visual-Components/TextComponent.tsx +114 -0
  35. package/src/PageComponents/Visual-Components/VideoComponent.tsx +191 -0
  36. package/src/PageComponents/Visual-Components/tab.css +697 -0
  37. package/src/common.interface.ts +216 -0
  38. package/src/const.ts +6 -0
  39. package/src/env.d.ts +15 -0
  40. package/src/index.css +82 -0
  41. package/src/index.ts +2 -0
  42. package/src/types.ts +234 -0
  43. package/tsconfig.json +20 -0
@@ -0,0 +1,397 @@
1
+ import React from 'react';
2
+
3
+ interface ModeProps {
4
+ isScroll?: boolean;
5
+ isVisible: boolean;
6
+ top: string;
7
+ bottom: string;
8
+ flexView?: boolean;
9
+ colspan?: number;
10
+ height?: string;
11
+ width?: string;
12
+ left?: string;
13
+ right?: string;
14
+ radius?: string;
15
+ }
16
+
17
+ interface DeviceModes {
18
+ web: ModeProps;
19
+ mobileweb: ModeProps;
20
+ mobileapp: ModeProps;
21
+ tablet: ModeProps;
22
+ }
23
+
24
+ interface BoxProps {
25
+ bgColor: string;
26
+ align: React.CSSProperties['alignItems'];
27
+ justify: string;
28
+ compOrder: string[];
29
+ bgsize: React.CSSProperties['backgroundSize'];
30
+ layout: string;
31
+ mode: DeviceModes;
32
+ }
33
+
34
+ interface BoxComponentProps {
35
+ props: BoxProps;
36
+ children?: React.ReactNode;
37
+ deviceMode?: string;
38
+ autoAdjustForImages?: boolean;
39
+ isSelected?: boolean;
40
+ setShowLayoutDialog?: (show: boolean) => void;
41
+ }
42
+
43
+ const BoxComponent: React.FC<BoxComponentProps> = ({
44
+ props,
45
+ children,
46
+ deviceMode = 'web',
47
+ autoAdjustForImages = true,
48
+ isSelected = false,
49
+ setShowLayoutDialog
50
+ }) => {
51
+ // Safely get the device mode with fallback
52
+ const getCurrentMode = (): ModeProps => {
53
+ const validModes = ['web', 'mobileweb', 'mobileapp', 'tablet'] as const;
54
+ const safeDeviceMode = validModes.includes(deviceMode as any)
55
+ ? deviceMode as keyof DeviceModes
56
+ : 'web';
57
+
58
+ return props.mode[safeDeviceMode] || props.mode.web;
59
+ };
60
+
61
+ const getColspan = (): number => {
62
+ const currentMode = getCurrentMode();
63
+ return currentMode?.colspan ?? 12;
64
+ };
65
+
66
+ const currentMode = getCurrentMode();
67
+ const colspan = getColspan();
68
+
69
+ // Apply visibility
70
+ if (!currentMode.isVisible) {
71
+ return null;
72
+ }
73
+
74
+ const getBoxHeight = (): string => {
75
+ if (!autoAdjustForImages) {
76
+ return currentMode.height || 'auto';
77
+ }
78
+
79
+ const hasImageComponent = React.Children.toArray(children).some(child =>
80
+ React.isValidElement(child) &&
81
+ (child.type as any)?.name === 'ImageComponent' || 'CarouselComponent'
82
+ );
83
+
84
+ if (hasImageComponent) {
85
+ return 'auto';
86
+ }
87
+
88
+ return currentMode.height || 'auto';
89
+ };
90
+
91
+ // Handle content justification with proper CSS values
92
+ const getJustifyContent = (justify: string): React.CSSProperties['justifyContent'] => {
93
+ if (justify === 'initial') return 'initial';
94
+
95
+ const justifyMap: Record<string, React.CSSProperties['justifyContent']> = {
96
+ around: 'space-around',
97
+ between: 'space-between',
98
+ evenly: 'space-evenly',
99
+ start: 'flex-start',
100
+ end: 'flex-end',
101
+ center: 'center',
102
+ 'flex-start': 'flex-start', // Add this
103
+ };
104
+
105
+ return justifyMap[justify] || justify || 'flex-start'; // Default to flex-start
106
+ };
107
+
108
+ // Handle alignment with proper CSS values
109
+ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSProperties['alignItems'] => {
110
+ if (align === 'initial') return 'initial';
111
+
112
+ const alignMap: Record<string, React.CSSProperties['alignItems']> = {
113
+ start: 'flex-start',
114
+ end: 'flex-end',
115
+ center: 'center',
116
+ stretch: 'stretch',
117
+ baseline: 'baseline',
118
+ 'flex-start': 'flex-start', // Add this
119
+ };
120
+
121
+ return (typeof align === 'string' && alignMap[align]) || align || 'flex-start'; // Default to flex-start
122
+ };
123
+
124
+ // Check if children is empty
125
+ const isEmpty = (children: any): boolean => {
126
+ if (!children) return true;
127
+ if (Array.isArray(children)) return children.length === 0;
128
+ return false;
129
+ };
130
+
131
+ // Get children as array
132
+ const childrenArray = React.Children.toArray(children);
133
+
134
+ // Layout styles
135
+ const rowLayout = {
136
+ display: 'flex',
137
+ flexDirection: 'row' as const,
138
+ width: '100%',
139
+ height: '100%',
140
+ margin: 0,
141
+ padding: 0,
142
+ boxSizing: 'border-box' as const
143
+ };
144
+
145
+ const colLayout = {
146
+ display: 'flex',
147
+ flexDirection: 'column' as const,
148
+ alignItems: 'center',
149
+ justifyContent: 'center',
150
+ padding: '5px',
151
+ boxSizing: 'border-box' as const,
152
+ flex: 1
153
+ };
154
+
155
+ // Render layout based on the layout prop
156
+ const renderLayout = () => {
157
+ if (!props.layout) {
158
+ return (
159
+ <div style={{
160
+ display: 'flex',
161
+ flexDirection: 'column',
162
+ alignItems: 'center',
163
+ justifyContent: 'center',
164
+ height: '100%',
165
+ color: '#666',
166
+ width: '100%',
167
+ boxSizing: 'border-box'
168
+ }}>
169
+ <h1>No Layout</h1>
170
+ </div>
171
+ );
172
+ }
173
+
174
+ switch(props.layout) {
175
+ case "layout1":
176
+ return (
177
+ <div style={{
178
+ width: "100%",
179
+ height: "100%",
180
+ minHeight: "50px",
181
+ boxSizing: "border-box",
182
+ overflow: "hidden",
183
+ justifyContent:"center",
184
+ alignItems:props.align,
185
+
186
+ }}>
187
+ {/* {children} */}
188
+ <div style={{
189
+
190
+ display:"flex",
191
+ justifyContent:props.justify,
192
+ alignItems:props.align,
193
+ height: "100%"
194
+ }}>
195
+ <div style={{width:'100%'}}> {children}</div>
196
+ </div>
197
+ </div>
198
+ );
199
+
200
+ case "layout2":
201
+ return (
202
+ <div style={{
203
+ display: 'flex',
204
+ flexDirection: 'column', // Changed to column to stack vertically
205
+ width: '100%',
206
+ height: '100%',
207
+ margin: 0,
208
+ padding: 0,
209
+ boxSizing: 'border-box'
210
+ }}>
211
+ {[0, 1].map((idx) => (
212
+ <div
213
+ key={`BOX-LAYOUT2-${idx}`}
214
+ style={{
215
+ ...colLayout,
216
+ minHeight: "50%",
217
+ width: '100%',
218
+ flex: 1
219
+ }}
220
+ >
221
+ {!isEmpty(childrenArray[idx]) ? (
222
+ childrenArray[idx]
223
+ ) : (
224
+ <div style={{ textAlign: 'center', color: '#999' }}>
225
+ No component here
226
+ </div>
227
+ )}
228
+ </div>
229
+ ))}
230
+ </div>
231
+ );
232
+ case "layout3":
233
+ return (
234
+ <div style={{ ...rowLayout, flexDirection: 'column', height: '100%' }}>
235
+ <div style={{ ...rowLayout, flex: 1 }}>
236
+ {[0, 1].map((idx) => (
237
+ <div
238
+ key={`BOX-LAYOUT3-TOP-${idx}`}
239
+ style={{
240
+ ...colLayout,
241
+ minHeight: "50px",
242
+ flex: 1
243
+ }}
244
+ >
245
+ {!isEmpty(childrenArray[idx]) ? (
246
+ childrenArray[idx]
247
+ ) : (
248
+ <div style={{ textAlign: 'center', color: '#999' }}>
249
+ No component here
250
+ </div>
251
+ )}
252
+ </div>
253
+ ))}
254
+ </div>
255
+ <div style={{ ...rowLayout, flex: 1 }}>
256
+ {[2, 3].map((idx) => (
257
+ <div
258
+ key={`BOX-LAYOUT3-BOTTOM-${idx}`}
259
+ style={{
260
+ ...colLayout,
261
+ minHeight: "50px",
262
+ flex: 1
263
+ }}
264
+ >
265
+ {!isEmpty(childrenArray[idx]) ? (
266
+ childrenArray[idx]
267
+ ) : (
268
+ <div style={{ textAlign: 'center', color: '#999' }}>
269
+ No component here
270
+ </div>
271
+ )}
272
+ </div>
273
+ ))}
274
+ </div>
275
+ </div>
276
+ );
277
+
278
+ case "layout4":
279
+ return (
280
+ <div style={rowLayout}>
281
+ <div
282
+ style={{
283
+ ...colLayout,
284
+ minHeight: "50px",
285
+ flex: 1
286
+ }}
287
+ >
288
+ {!isEmpty(childrenArray[0]) ? (
289
+ childrenArray[0]
290
+ ) : (
291
+ <div style={{ textAlign: 'center', color: '#999' }}>
292
+ No component here
293
+ </div>
294
+ )}
295
+ </div>
296
+ <div style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
297
+ {[1, 2].map((idx) => (
298
+ <div
299
+ key={`BOX-LAYOUT4-${idx}`}
300
+ style={{
301
+ ...colLayout,
302
+ minHeight: "50px",
303
+ flex: 1
304
+ }}
305
+ >
306
+ {!isEmpty(childrenArray[idx]) ? (
307
+ childrenArray[idx]
308
+ ) : (
309
+ <div style={{ textAlign: 'center', color: '#999' }}>
310
+ No component here
311
+ </div>
312
+ )}
313
+ </div>
314
+ ))}
315
+ </div>
316
+ </div>
317
+ );
318
+
319
+ case "layout5":
320
+ return (
321
+ <div style={rowLayout}>
322
+ <div style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
323
+ {[0, 1].map((idx) => (
324
+ <div
325
+ key={`BOX-LAYOUT5-${idx}`}
326
+ style={{
327
+ ...colLayout,
328
+ minHeight: "50px",
329
+ flex: 1
330
+ }}
331
+ >
332
+ {!isEmpty(childrenArray[idx]) ? (
333
+ childrenArray[idx]
334
+ ) : (
335
+ <div style={{ textAlign: 'center', color: '#999' }}>
336
+ No component here
337
+ </div>
338
+ )}
339
+ </div>
340
+ ))}
341
+ </div>
342
+ <div
343
+ style={{
344
+ ...colLayout,
345
+ minHeight: "50px",
346
+ flex: 1
347
+ }}
348
+ >
349
+ {!isEmpty(childrenArray[2]) ? (
350
+ childrenArray[2]
351
+ ) : (
352
+ <div style={{ textAlign: 'center', color: '#999' }}>
353
+ No component here
354
+ </div>
355
+ )}
356
+ </div>
357
+ </div>
358
+ );
359
+
360
+ default:
361
+ return children;
362
+ }
363
+ };
364
+
365
+ return (
366
+ <div
367
+ style={{
368
+ backgroundColor: props.bgColor,
369
+ backgroundSize: props.bgsize || 'cover',
370
+ height: getBoxHeight(),
371
+ minHeight: autoAdjustForImages ? 'auto' : (currentMode.height || 'auto'),
372
+ borderRadius: currentMode.radius || '0px',
373
+ width: `calc(${(colspan / 12) * 100}% - 1px)`,
374
+ maxWidth: `calc(${(colspan / 12) * 100}% - 1px)`,
375
+ minWidth: `calc(${(colspan / 12) * 100}% - 1px)`,
376
+ flex: 'none',
377
+ boxSizing: 'border-box',
378
+ margin: '5px 0px',
379
+ overflow: 'hidden',
380
+ position: 'relative',
381
+ marginTop: currentMode.top,
382
+ marginBottom: currentMode.bottom,
383
+ marginLeft: currentMode.left,
384
+ marginRight: currentMode.right,
385
+ // Flex container for children
386
+ display: 'flex',
387
+ flexDirection: 'column',
388
+ alignItems: props.align === 'initial' ? 'initial' : getAlignItems(props.align),
389
+ justifyContent: props.justify === 'initial' ? 'initial' : getJustifyContent(props.justify)
390
+ }}
391
+ >
392
+ {renderLayout()}
393
+ </div>
394
+ );
395
+ };
396
+
397
+ export default BoxComponent;
@@ -0,0 +1,113 @@
1
+ import React from 'react';
2
+
3
+ interface ModeProps {
4
+ isScroll: boolean;
5
+ isVisible: boolean;
6
+ top: string;
7
+ bottom: string;
8
+ flexView?: boolean;
9
+ colspan?: number;
10
+ height?: string;
11
+ width?: string;
12
+ left?: string;
13
+ right?: string;
14
+ radius?: string;
15
+ }
16
+
17
+ interface DeviceModes {
18
+ web: ModeProps;
19
+ mobileweb: ModeProps;
20
+ mobileapp: ModeProps;
21
+ tablet: ModeProps;
22
+ }
23
+
24
+ interface RowProps {
25
+ minHeight: string;
26
+ bgColor: string;
27
+ bgImage: string;
28
+ align: React.CSSProperties['alignItems'];
29
+ justify: string;
30
+ nowrap: boolean;
31
+ bgsize: React.CSSProperties['backgroundSize'];
32
+ mode: DeviceModes;
33
+ }
34
+
35
+ interface RowComponentProps {
36
+ props: RowProps;
37
+ children?: React.ReactNode;
38
+ deviceMode?: string;
39
+ }
40
+
41
+ const RowComponent: React.FC<RowComponentProps> = ({
42
+ props,
43
+ children,
44
+ deviceMode = 'web'
45
+ }) => {
46
+ // Safely get the device mode with fallback
47
+ const getCurrentMode = (): ModeProps => {
48
+ const validModes = ['web', 'mobileweb', 'mobileapp', 'tablet'] as const;
49
+ const safeDeviceMode = validModes.includes(deviceMode as any)
50
+ ? deviceMode as keyof DeviceModes
51
+ : 'web';
52
+
53
+ return props.mode[safeDeviceMode] || props.mode.web;
54
+ };
55
+
56
+ // Get the current device mode configuration
57
+ const currentMode = getCurrentMode();
58
+
59
+ // Apply visibility
60
+ if (!currentMode.isVisible) {
61
+ return null;
62
+ }
63
+
64
+ // Handle content justification with proper CSS values
65
+ const getJustifyContent = (): React.CSSProperties['justifyContent'] => {
66
+ const justifyMap: Record<string, React.CSSProperties['justifyContent']> = {
67
+ around: 'space-around',
68
+ between: 'space-between',
69
+ evenly: 'space-evenly',
70
+ start: 'flex-start',
71
+ end: 'flex-end',
72
+ center: 'center',
73
+ 'flex-start': 'flex-start',
74
+ 'flex-end': 'flex-end',
75
+ initial: 'initial'
76
+ };
77
+
78
+ return justifyMap[props.justify] || props.justify || 'flex-start';
79
+ };
80
+
81
+ return (
82
+ <div
83
+ style={{
84
+ minHeight: props.minHeight,
85
+ backgroundColor: props.bgColor,
86
+ backgroundImage: props.bgImage ? `url(${props.bgImage})` : 'none',
87
+ backgroundSize: props.bgsize,
88
+ backgroundPosition: 'center',
89
+ backgroundRepeat: 'no-repeat',
90
+ width: currentMode.width || '100%',
91
+ height: currentMode.height,
92
+ marginTop: currentMode.top,
93
+ marginBottom: currentMode.bottom,
94
+ marginLeft: currentMode.left,
95
+ marginRight: currentMode.right,
96
+ borderRadius: currentMode.radius,
97
+ boxSizing: 'border-box',
98
+ overflow: currentMode.isScroll ? 'auto' : 'visible',
99
+ position: 'relative',
100
+ // Flexbox properties like the old code
101
+ display: currentMode.flexView ? 'flex' : 'block',
102
+ flexDirection: currentMode.flexView ? 'row' as const : undefined,
103
+ flexWrap: currentMode.flexView ? (props.nowrap ? 'nowrap' as const : 'wrap' as const) : undefined,
104
+ justifyContent: currentMode.flexView ? getJustifyContent() : undefined,
105
+ alignItems: props.align
106
+ }}
107
+ >
108
+ {children}
109
+ </div>
110
+ );
111
+ };
112
+
113
+ export default RowComponent;