tee3apps-cms-sdk-react 0.0.20 → 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 +123 -25
  8. package/src/PageComponents/Visual-Components/CarouselComponent.tsx +300 -167
  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 +74 -18
  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 -877
  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 -81
  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.20",
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;
@@ -121,6 +123,19 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
121
123
  return (typeof align === 'string' && alignMap[align]) || align || 'flex-start'; // Default to flex-start
122
124
  };
123
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
+
124
139
  // Check if children is empty
125
140
  const isEmpty = (children: any): boolean => {
126
141
  if (!children) return true;
@@ -129,7 +144,64 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
129
144
  };
130
145
 
131
146
  // Get children as array
132
- const childrenArray = React.Children.toArray(children);
147
+ const originalChildrenArray = React.Children.toArray(children);
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();
133
205
 
134
206
  // Layout styles
135
207
  const rowLayout = {
@@ -145,11 +217,15 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
145
217
  const colLayout = {
146
218
  display: 'flex',
147
219
  flexDirection: 'column' as const,
148
- alignItems: 'center',
149
- justifyContent: 'center',
150
- padding: '5px',
220
+ alignItems: 'stretch',
221
+ justifyContent: 'stretch',
222
+ padding: 0,
151
223
  boxSizing: 'border-box' as const,
152
- flex: 1
224
+ flex: 1,
225
+ minWidth: 0,
226
+ minHeight: 0,
227
+ overflow: 'hidden' as const,
228
+ position: 'relative' as const
153
229
  };
154
230
 
155
231
  // Render layout based on the layout prop
@@ -184,7 +260,6 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
184
260
  alignItems:props.align,
185
261
 
186
262
  }}>
187
- {/* {children} */}
188
263
  <div style={{
189
264
 
190
265
  display:"flex",
@@ -192,7 +267,7 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
192
267
  alignItems:props.align,
193
268
  height: "100%"
194
269
  }}>
195
- <div style={{width:'100%'}}> {children}</div>
270
+ <div style={{width:'100%'}}> {childrenArray}</div>
196
271
  </div>
197
272
  </div>
198
273
  );
@@ -201,7 +276,7 @@ height: "100%"
201
276
  return (
202
277
  <div style={{
203
278
  display: 'flex',
204
- flexDirection: 'column', // Changed to column to stack vertically
279
+ flexDirection: 'row', // Display in row (side by side)
205
280
  width: '100%',
206
281
  height: '100%',
207
282
  margin: 0,
@@ -213,13 +288,15 @@ height: "100%"
213
288
  key={`BOX-LAYOUT2-${idx}`}
214
289
  style={{
215
290
  ...colLayout,
216
- minHeight: "50%",
217
- width: '100%',
291
+ minWidth: "50%",
292
+ width: '50%',
218
293
  flex: 1
219
294
  }}
220
295
  >
221
296
  {!isEmpty(childrenArray[idx]) ? (
222
- childrenArray[idx]
297
+ <div style={{ width: '100%', height: '100%', position: 'relative' }}>
298
+ {childrenArray[idx]}
299
+ </div>
223
300
  ) : (
224
301
  <div style={{ textAlign: 'center', color: '#999' }}>
225
302
  No component here
@@ -231,19 +308,22 @@ height: "100%"
231
308
  );
232
309
  case "layout3":
233
310
  return (
234
- <div style={{ ...rowLayout, flexDirection: 'column', height: '100%' }}>
235
- <div style={{ ...rowLayout, flex: 1 }}>
311
+ <div style={{ ...rowLayout, flexDirection: 'column', height: '100%', minHeight: 0 }}>
312
+ <div style={{ ...rowLayout, flex: 1, minHeight: 0 }}>
236
313
  {[0, 1].map((idx) => (
237
314
  <div
238
315
  key={`BOX-LAYOUT3-TOP-${idx}`}
239
316
  style={{
240
317
  ...colLayout,
241
318
  minHeight: "50px",
242
- flex: 1
319
+ flex: 1,
320
+ width: '50%'
243
321
  }}
244
322
  >
245
323
  {!isEmpty(childrenArray[idx]) ? (
246
- childrenArray[idx]
324
+ <div style={{ width: '100%', height: '100%', position: 'relative' }}>
325
+ {childrenArray[idx]}
326
+ </div>
247
327
  ) : (
248
328
  <div style={{ textAlign: 'center', color: '#999' }}>
249
329
  No component here
@@ -252,18 +332,21 @@ height: "100%"
252
332
  </div>
253
333
  ))}
254
334
  </div>
255
- <div style={{ ...rowLayout, flex: 1 }}>
335
+ <div style={{ ...rowLayout, flex: 1, minHeight: 0 }}>
256
336
  {[2, 3].map((idx) => (
257
337
  <div
258
338
  key={`BOX-LAYOUT3-BOTTOM-${idx}`}
259
339
  style={{
260
340
  ...colLayout,
261
341
  minHeight: "50px",
262
- flex: 1
342
+ flex: 1,
343
+ width: '50%'
263
344
  }}
264
345
  >
265
346
  {!isEmpty(childrenArray[idx]) ? (
266
- childrenArray[idx]
347
+ <div style={{ width: '100%', height: '100%', position: 'relative' }}>
348
+ {childrenArray[idx]}
349
+ </div>
267
350
  ) : (
268
351
  <div style={{ textAlign: 'center', color: '#999' }}>
269
352
  No component here
@@ -286,7 +369,9 @@ height: "100%"
286
369
  }}
287
370
  >
288
371
  {!isEmpty(childrenArray[0]) ? (
289
- childrenArray[0]
372
+ <div style={{ width: '100%', height: '100%', display: 'flex', alignItems: 'stretch', justifyContent: 'stretch' }}>
373
+ {childrenArray[0]}
374
+ </div>
290
375
  ) : (
291
376
  <div style={{ textAlign: 'center', color: '#999' }}>
292
377
  No component here
@@ -304,7 +389,9 @@ height: "100%"
304
389
  }}
305
390
  >
306
391
  {!isEmpty(childrenArray[idx]) ? (
307
- childrenArray[idx]
392
+ <div style={{ width: '100%', height: '100%', position: 'relative' }}>
393
+ {childrenArray[idx]}
394
+ </div>
308
395
  ) : (
309
396
  <div style={{ textAlign: 'center', color: '#999' }}>
310
397
  No component here
@@ -330,7 +417,9 @@ height: "100%"
330
417
  }}
331
418
  >
332
419
  {!isEmpty(childrenArray[idx]) ? (
333
- childrenArray[idx]
420
+ <div style={{ width: '100%', height: '100%', position: 'relative' }}>
421
+ {childrenArray[idx]}
422
+ </div>
334
423
  ) : (
335
424
  <div style={{ textAlign: 'center', color: '#999' }}>
336
425
  No component here
@@ -347,7 +436,9 @@ height: "100%"
347
436
  }}
348
437
  >
349
438
  {!isEmpty(childrenArray[2]) ? (
350
- childrenArray[2]
439
+ <div style={{ width: '100%', height: '100%', display: 'flex', alignItems: 'stretch', justifyContent: 'stretch' }}>
440
+ {childrenArray[2]}
441
+ </div>
351
442
  ) : (
352
443
  <div style={{ textAlign: 'center', color: '#999' }}>
353
444
  No component here
@@ -358,15 +449,22 @@ height: "100%"
358
449
  );
359
450
 
360
451
  default:
361
- return children;
452
+ return childrenArray;
362
453
  }
363
454
  };
364
455
 
456
+ const backgroundImageUrl = getBackgroundImageUrl();
457
+ const hasBackgroundImage = backgroundImageUrl !== 'none';
458
+
365
459
  return (
366
460
  <div
367
461
  style={{
368
- backgroundColor: props.bgColor,
462
+ // bgImage takes priority over bgColor
463
+ backgroundColor: hasBackgroundImage ? 'transparent' : props.bgColor,
464
+ backgroundImage: backgroundImageUrl,
369
465
  backgroundSize: props.bgsize || 'cover',
466
+ backgroundPosition: 'center',
467
+ backgroundRepeat: 'no-repeat',
370
468
  height: getBoxHeight(),
371
469
  minHeight: autoAdjustForImages ? 'auto' : (currentMode.height || 'auto'),
372
470
  borderRadius: currentMode.radius || '0px',