tee3apps-cms-sdk-react 0.0.19 → 0.0.22

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 (27) hide show
  1. package/dist/index.js +2 -2
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +2 -2
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/src/Page.tsx +2 -2
  7. package/src/PageComponents/BoxComponent.tsx +142 -92
  8. package/src/PageComponents/Visual-Components/CarouselComponent.tsx +497 -364
  9. package/src/PageComponents/Visual-Components/GroupBrandComponent.tsx +396 -390
  10. package/src/PageComponents/Visual-Components/GroupCategoryComponent.tsx +21 -13
  11. package/src/PageComponents/Visual-Components/GroupImageList.tsx +642 -668
  12. package/src/PageComponents/Visual-Components/GroupProductComponent.tsx +46 -20
  13. package/src/PageComponents/Visual-Components/GroupVideoList.tsx +693 -589
  14. package/src/PageComponents/Visual-Components/ImageComponent.tsx +72 -17
  15. package/src/PageComponents/Visual-Components/LottieComponent.tsx +14 -8
  16. package/src/PageComponents/Visual-Components/NavigationComponent.tsx +74 -27
  17. package/src/PageComponents/Visual-Components/RichTextComponent.tsx +1 -1
  18. package/src/PageComponents/Visual-Components/TabComponent.tsx +1625 -875
  19. package/src/PageComponents/Visual-Components/TextComponent.tsx +24 -10
  20. package/src/PageComponents/Visual-Components/VideoComponent.tsx +33 -11
  21. package/src/PageComponents/Visual-Components/tab.css +645 -611
  22. package/src/index.css +126 -80
  23. package/src/Components/BoxRenderer.tsx +0 -108
  24. package/src/Components/ComponentRenderer.tsx +0 -29
  25. package/src/Components/ImageComponent.tsx +0 -68
  26. package/src/Components/RowComponent.tsx +0 -66
  27. package/src/Components/TextComponent.tsx +0 -47
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tee3apps-cms-sdk-react",
3
- "version": "0.0.19",
3
+ "version": "0.0.22",
4
4
  "description": "Uses JSON to dynamically generate and render UI pages in a website",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/Page.tsx CHANGED
@@ -63,7 +63,7 @@ const Page = ({data}:any) => {
63
63
  key={boxIndex}
64
64
  props={box.props}
65
65
  deviceMode={deviceMode}
66
- autoAdjustForImages={true}
66
+ autoAdjustForImages={false}
67
67
  >
68
68
  {box.components.map((component: { name: string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined; props: TextProps | LinkProps | ImageComponentProps | GroupProductComponentProps | VideoComponentProps | GroupBrandComponentProps | LottieComponentProps | CarouselProps | NavigationProps | GroupVideoListProps | GroupCategoryComponentProps | GroupImageListProps | TabComponentProps | RichTextComponentProps; }, compIndex: React.Key | null | undefined) => {
69
69
  const getCurrentBoxHeight = () => {
@@ -103,7 +103,7 @@ const Page = ({data}:any) => {
103
103
  return <GroupImageList key={compIndex} props={component.props as GroupImageListProps} deviceMode={deviceMode} />;
104
104
  case 'TabComponent':
105
105
  return <TabComponent key={compIndex} props={component.props as TabComponentProps} deviceMode={deviceMode} />;
106
- case 'RichTextComponent':
106
+ case 'RichTextBoxComponent':
107
107
  return <RichTextComponent key={compIndex} props={component.props as RichTextComponentProps} />;
108
108
  default:
109
109
  return null;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { Linodeurl } from '../const';
2
3
 
3
4
  interface ModeProps {
4
5
  isScroll?: boolean;
@@ -23,9 +24,10 @@ interface DeviceModes {
23
24
 
24
25
  interface BoxProps {
25
26
  bgColor: string;
27
+ bgImage?: string;
26
28
  align: React.CSSProperties['alignItems'];
27
29
  justify: string;
28
- compOrder: string[];
30
+ compOrder: string | string[];
29
31
  bgsize: React.CSSProperties['backgroundSize'];
30
32
  layout: string;
31
33
  mode: DeviceModes;
@@ -71,63 +73,18 @@ const BoxComponent: React.FC<BoxComponentProps> = ({
71
73
  return null;
72
74
  }
73
75
 
74
- // Check if children contain image/video components for dynamic height
75
- const hasMediaComponents = (): boolean => {
76
- const checkChild = (child: React.ReactNode): boolean => {
77
- if (!React.isValidElement(child)) return false;
78
-
79
- const componentName = (child.type as any)?.name || (child.type as any)?.displayName;
80
- const mediaComponents = [
81
- 'ImageComponent',
82
- 'CarouselComponent',
83
- 'VideoComponent',
84
- 'TabComponent',
85
- 'GroupImageComponent',
86
- 'GroupVideoComponent'
87
- ];
88
-
89
- if (componentName && mediaComponents.includes(componentName)) {
90
- return true;
91
- }
92
-
93
- // Check nested children
94
- if (child.props && typeof child.props === 'object' && 'children' in child.props) {
95
- const children = (child.props as any).children;
96
- if (children) {
97
- const nestedChildren = React.Children.toArray(children);
98
- return nestedChildren.some(checkChild);
99
- }
100
- }
101
-
102
- return false;
103
- };
104
-
105
- return React.Children.toArray(children).some(checkChild);
106
- };
107
-
108
- // Check if we have media components
109
- const hasMedia = hasMediaComponents();
110
-
111
- const getBoxHeight = (): string | undefined => {
76
+ const getBoxHeight = (): string => {
112
77
  if (!autoAdjustForImages) {
113
78
  return currentMode.height || 'auto';
114
79
  }
115
80
 
116
- if (hasMedia) {
117
- return 'auto';
118
- }
119
-
120
- return currentMode.height || 'auto';
121
- };
122
-
123
- // Get dynamic minHeight based on media components
124
- const getBoxMinHeight = (): string | undefined => {
125
- if (!autoAdjustForImages) {
126
- return currentMode.height || 'auto';
127
- }
81
+ const hasImageComponent = React.Children.toArray(children).some(child =>
82
+ React.isValidElement(child) &&
83
+ (child.type as any)?.name === 'ImageComponent' || 'CarouselComponent'
84
+ );
128
85
 
129
- if (hasMedia) {
130
- return undefined; // Remove minHeight constraint for media components
86
+ if (hasImageComponent) {
87
+ return 'auto';
131
88
  }
132
89
 
133
90
  return currentMode.height || 'auto';
@@ -166,6 +123,19 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
166
123
  return (typeof align === 'string' && alignMap[align]) || align || 'flex-start'; // Default to flex-start
167
124
  };
168
125
 
126
+ // Build background image URL with Linode URL prefix
127
+ const getBackgroundImageUrl = (): string => {
128
+ if (!props.bgImage) return 'none';
129
+
130
+ const bgImage = props.bgImage;
131
+ // If the image URL already starts with http:// or https://, use it as is
132
+ if (typeof bgImage === 'string' && (bgImage.startsWith('http://') || bgImage.startsWith('https://'))) {
133
+ return `url(${bgImage})`;
134
+ }
135
+ // Otherwise, prepend the Linode URL
136
+ return `url(${Linodeurl}${bgImage})`;
137
+ };
138
+
169
139
  // Check if children is empty
170
140
  const isEmpty = (children: any): boolean => {
171
141
  if (!children) return true;
@@ -174,17 +144,71 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
174
144
  };
175
145
 
176
146
  // Get children as array
177
- const childrenArray = React.Children.toArray(children);
178
-
179
- // Check if we should use auto height for layouts
180
- const useAutoHeight = autoAdjustForImages && hasMedia;
147
+ const originalChildrenArray = React.Children.toArray(children);
181
148
 
149
+ // Parse compOrder and reorder children accordingly
150
+ const getOrderedChildren = (): React.ReactNode[] => {
151
+ if (!props.compOrder || originalChildrenArray.length === 0) {
152
+ return originalChildrenArray;
153
+ }
154
+
155
+ // Parse compOrder - can be string like "2,3,1" or array like ["2","3","1"]
156
+ let orderArray: string[];
157
+ if (typeof props.compOrder === 'string') {
158
+ orderArray = props.compOrder.split(',').map(item => item.trim()).filter(item => item !== '');
159
+ } else {
160
+ orderArray = props.compOrder.map(item => String(item).trim()).filter(item => item !== '');
161
+ }
162
+
163
+ // If no valid order, return original order
164
+ if (orderArray.length === 0) {
165
+ return originalChildrenArray;
166
+ }
167
+
168
+ // Reorder children based on compOrder
169
+ // compOrder is 1-indexed (1 = first component, 2 = second component, etc.)
170
+ const orderedChildren: React.ReactNode[] = [];
171
+ const usedIndices = new Set<number>();
172
+
173
+ for (const orderIndex of orderArray) {
174
+ const oneIndexed = parseInt(orderIndex, 10);
175
+ if (isNaN(oneIndexed) || oneIndexed < 1) {
176
+ continue; // Skip invalid indices
177
+ }
178
+
179
+ // Convert from 1-indexed to 0-indexed
180
+ const zeroIndexed = oneIndexed - 1;
181
+
182
+ // Check if index is valid and not already used
183
+ if (zeroIndexed >= 0 && zeroIndexed < originalChildrenArray.length && !usedIndices.has(zeroIndexed)) {
184
+ orderedChildren.push(originalChildrenArray[zeroIndexed]);
185
+ usedIndices.add(zeroIndexed);
186
+ }
187
+ }
188
+
189
+ // Add any remaining children that weren't in compOrder (in their original order)
190
+ for (let i = 0; i < originalChildrenArray.length; i++) {
191
+ if (!usedIndices.has(i)) {
192
+ orderedChildren.push(originalChildrenArray[i]);
193
+ }
194
+ }
195
+
196
+ // If we got no valid children, return original order
197
+ if (orderedChildren.length === 0) {
198
+ return originalChildrenArray;
199
+ }
200
+
201
+ return orderedChildren;
202
+ };
203
+
204
+ const childrenArray = getOrderedChildren();
205
+
182
206
  // Layout styles
183
207
  const rowLayout = {
184
208
  display: 'flex',
185
209
  flexDirection: 'row' as const,
186
210
  width: '100%',
187
- height: useAutoHeight ? 'auto' : '100%',
211
+ height: '100%',
188
212
  margin: 0,
189
213
  padding: 0,
190
214
  boxSizing: 'border-box' as const
@@ -193,11 +217,15 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
193
217
  const colLayout = {
194
218
  display: 'flex',
195
219
  flexDirection: 'column' as const,
196
- alignItems: 'center',
197
- justifyContent: 'center',
198
- padding: '5px',
220
+ alignItems: 'stretch',
221
+ justifyContent: 'stretch',
222
+ padding: 0,
199
223
  boxSizing: 'border-box' as const,
200
- flex: useAutoHeight ? 'none' : 1
224
+ flex: 1,
225
+ minWidth: 0,
226
+ minHeight: 0,
227
+ overflow: 'hidden' as const,
228
+ position: 'relative' as const
201
229
  };
202
230
 
203
231
  // Render layout based on the layout prop
@@ -224,7 +252,7 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
224
252
  return (
225
253
  <div style={{
226
254
  width: "100%",
227
- height: useAutoHeight ? 'auto' : "100%",
255
+ height: "100%",
228
256
  minHeight: "50px",
229
257
  boxSizing: "border-box",
230
258
  overflow: "hidden",
@@ -232,15 +260,14 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
232
260
  alignItems:props.align,
233
261
 
234
262
  }}>
235
- {/* {children} */}
236
263
  <div style={{
237
264
 
238
265
  display:"flex",
239
266
  justifyContent:props.justify,
240
267
  alignItems:props.align,
241
- height: useAutoHeight ? 'auto' : "100%"
268
+ height: "100%"
242
269
  }}>
243
- <div style={{width:'100%'}}> {children}</div>
270
+ <div style={{width:'100%'}}> {childrenArray}</div>
244
271
  </div>
245
272
  </div>
246
273
  );
@@ -249,9 +276,9 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
249
276
  return (
250
277
  <div style={{
251
278
  display: 'flex',
252
- flexDirection: 'column', // Changed to column to stack vertically
279
+ flexDirection: 'row', // Display in row (side by side)
253
280
  width: '100%',
254
- height: useAutoHeight ? 'auto' : '100%',
281
+ height: '100%',
255
282
  margin: 0,
256
283
  padding: 0,
257
284
  boxSizing: 'border-box'
@@ -261,13 +288,15 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
261
288
  key={`BOX-LAYOUT2-${idx}`}
262
289
  style={{
263
290
  ...colLayout,
264
- minHeight: useAutoHeight ? "50px" : "50%",
265
- width: '100%',
266
- flex: useAutoHeight ? 'none' : 1
291
+ minWidth: "50%",
292
+ width: '50%',
293
+ flex: 1
267
294
  }}
268
295
  >
269
296
  {!isEmpty(childrenArray[idx]) ? (
270
- childrenArray[idx]
297
+ <div style={{ width: '100%', height: '100%', position: 'relative' }}>
298
+ {childrenArray[idx]}
299
+ </div>
271
300
  ) : (
272
301
  <div style={{ textAlign: 'center', color: '#999' }}>
273
302
  No component here
@@ -279,19 +308,22 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
279
308
  );
280
309
  case "layout3":
281
310
  return (
282
- <div style={{ ...rowLayout, flexDirection: 'column' }}>
283
- <div style={{ ...rowLayout, flex: useAutoHeight ? 'none' : 1 }}>
311
+ <div style={{ ...rowLayout, flexDirection: 'column', height: '100%', minHeight: 0 }}>
312
+ <div style={{ ...rowLayout, flex: 1, minHeight: 0 }}>
284
313
  {[0, 1].map((idx) => (
285
314
  <div
286
315
  key={`BOX-LAYOUT3-TOP-${idx}`}
287
316
  style={{
288
317
  ...colLayout,
289
318
  minHeight: "50px",
290
- flex: useAutoHeight ? 'none' : 1
319
+ flex: 1,
320
+ width: '50%'
291
321
  }}
292
322
  >
293
323
  {!isEmpty(childrenArray[idx]) ? (
294
- childrenArray[idx]
324
+ <div style={{ width: '100%', height: '100%', position: 'relative' }}>
325
+ {childrenArray[idx]}
326
+ </div>
295
327
  ) : (
296
328
  <div style={{ textAlign: 'center', color: '#999' }}>
297
329
  No component here
@@ -300,18 +332,21 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
300
332
  </div>
301
333
  ))}
302
334
  </div>
303
- <div style={{ ...rowLayout, flex: useAutoHeight ? 'none' : 1 }}>
335
+ <div style={{ ...rowLayout, flex: 1, minHeight: 0 }}>
304
336
  {[2, 3].map((idx) => (
305
337
  <div
306
338
  key={`BOX-LAYOUT3-BOTTOM-${idx}`}
307
339
  style={{
308
340
  ...colLayout,
309
341
  minHeight: "50px",
310
- flex: useAutoHeight ? 'none' : 1
342
+ flex: 1,
343
+ width: '50%'
311
344
  }}
312
345
  >
313
346
  {!isEmpty(childrenArray[idx]) ? (
314
- childrenArray[idx]
347
+ <div style={{ width: '100%', height: '100%', position: 'relative' }}>
348
+ {childrenArray[idx]}
349
+ </div>
315
350
  ) : (
316
351
  <div style={{ textAlign: 'center', color: '#999' }}>
317
352
  No component here
@@ -330,29 +365,33 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
330
365
  style={{
331
366
  ...colLayout,
332
367
  minHeight: "50px",
333
- flex: useAutoHeight ? 'none' : 1
368
+ flex: 1
334
369
  }}
335
370
  >
336
371
  {!isEmpty(childrenArray[0]) ? (
337
- childrenArray[0]
372
+ <div style={{ width: '100%', height: '100%', display: 'flex', alignItems: 'stretch', justifyContent: 'stretch' }}>
373
+ {childrenArray[0]}
374
+ </div>
338
375
  ) : (
339
376
  <div style={{ textAlign: 'center', color: '#999' }}>
340
377
  No component here
341
378
  </div>
342
379
  )}
343
380
  </div>
344
- <div style={{ display: 'flex', flexDirection: 'column', flex: useAutoHeight ? 'none' : 1 }}>
381
+ <div style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
345
382
  {[1, 2].map((idx) => (
346
383
  <div
347
384
  key={`BOX-LAYOUT4-${idx}`}
348
385
  style={{
349
386
  ...colLayout,
350
387
  minHeight: "50px",
351
- flex: useAutoHeight ? 'none' : 1
388
+ flex: 1
352
389
  }}
353
390
  >
354
391
  {!isEmpty(childrenArray[idx]) ? (
355
- childrenArray[idx]
392
+ <div style={{ width: '100%', height: '100%', position: 'relative' }}>
393
+ {childrenArray[idx]}
394
+ </div>
356
395
  ) : (
357
396
  <div style={{ textAlign: 'center', color: '#999' }}>
358
397
  No component here
@@ -367,18 +406,20 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
367
406
  case "layout5":
368
407
  return (
369
408
  <div style={rowLayout}>
370
- <div style={{ display: 'flex', flexDirection: 'column', flex: useAutoHeight ? 'none' : 1 }}>
409
+ <div style={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
371
410
  {[0, 1].map((idx) => (
372
411
  <div
373
412
  key={`BOX-LAYOUT5-${idx}`}
374
413
  style={{
375
414
  ...colLayout,
376
415
  minHeight: "50px",
377
- flex: useAutoHeight ? 'none' : 1
416
+ flex: 1
378
417
  }}
379
418
  >
380
419
  {!isEmpty(childrenArray[idx]) ? (
381
- childrenArray[idx]
420
+ <div style={{ width: '100%', height: '100%', position: 'relative' }}>
421
+ {childrenArray[idx]}
422
+ </div>
382
423
  ) : (
383
424
  <div style={{ textAlign: 'center', color: '#999' }}>
384
425
  No component here
@@ -391,11 +432,13 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
391
432
  style={{
392
433
  ...colLayout,
393
434
  minHeight: "50px",
394
- flex: useAutoHeight ? 'none' : 1
435
+ flex: 1
395
436
  }}
396
437
  >
397
438
  {!isEmpty(childrenArray[2]) ? (
398
- childrenArray[2]
439
+ <div style={{ width: '100%', height: '100%', display: 'flex', alignItems: 'stretch', justifyContent: 'stretch' }}>
440
+ {childrenArray[2]}
441
+ </div>
399
442
  ) : (
400
443
  <div style={{ textAlign: 'center', color: '#999' }}>
401
444
  No component here
@@ -406,17 +449,24 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
406
449
  );
407
450
 
408
451
  default:
409
- return children;
452
+ return childrenArray;
410
453
  }
411
454
  };
412
455
 
456
+ const backgroundImageUrl = getBackgroundImageUrl();
457
+ const hasBackgroundImage = backgroundImageUrl !== 'none';
458
+
413
459
  return (
414
460
  <div
415
461
  style={{
416
- backgroundColor: props.bgColor,
462
+ // bgImage takes priority over bgColor
463
+ backgroundColor: hasBackgroundImage ? 'transparent' : props.bgColor,
464
+ backgroundImage: backgroundImageUrl,
417
465
  backgroundSize: props.bgsize || 'cover',
466
+ backgroundPosition: 'center',
467
+ backgroundRepeat: 'no-repeat',
418
468
  height: getBoxHeight(),
419
- minHeight: getBoxMinHeight(),
469
+ minHeight: autoAdjustForImages ? 'auto' : (currentMode.height || 'auto'),
420
470
  borderRadius: currentMode.radius || '0px',
421
471
  width: `calc(${(colspan / 12) * 100}% - 1px)`,
422
472
  maxWidth: `calc(${(colspan / 12) * 100}% - 1px)`,