tee3apps-cms-sdk-react 0.0.31 → 0.0.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tee3apps-cms-sdk-react",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
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",
@@ -53,10 +53,10 @@ const BoxComponent: React.FC<BoxComponentProps> = ({
53
53
  // Safely get the device mode with fallback
54
54
  const getCurrentMode = (): ModeProps => {
55
55
  const validModes = ['web', 'mobileweb', 'mobileapp', 'tablet'] as const;
56
- const safeDeviceMode = validModes.includes(deviceMode as any)
57
- ? deviceMode as keyof DeviceModes
56
+ const safeDeviceMode = validModes.includes(deviceMode as any)
57
+ ? deviceMode as keyof DeviceModes
58
58
  : 'web';
59
-
59
+
60
60
  return props.mode[safeDeviceMode] || props.mode.web;
61
61
  };
62
62
 
@@ -77,56 +77,56 @@ const BoxComponent: React.FC<BoxComponentProps> = ({
77
77
  if (!autoAdjustForImages) {
78
78
  return currentMode.height || 'auto';
79
79
  }
80
-
81
- const hasImageComponent = React.Children.toArray(children).some(child =>
82
- React.isValidElement(child) &&
80
+
81
+ const hasImageComponent = React.Children.toArray(children).some(child =>
82
+ React.isValidElement(child) &&
83
83
  (child.type as any)?.name === 'ImageComponent' || 'CarouselComponent'
84
84
  );
85
-
85
+
86
86
  if (hasImageComponent) {
87
87
  return 'auto';
88
88
  }
89
-
89
+
90
90
  return currentMode.height || 'auto';
91
91
  };
92
92
 
93
93
  // Handle content justification with proper CSS values
94
- const getJustifyContent = (justify: string): React.CSSProperties['justifyContent'] => {
95
- if (justify === 'initial') return 'initial';
96
-
97
- const justifyMap: Record<string, React.CSSProperties['justifyContent']> = {
98
- around: 'space-around',
99
- between: 'space-between',
100
- evenly: 'space-evenly',
101
- start: 'flex-start',
102
- end: 'flex-end',
103
- center: 'center',
104
- 'flex-start': 'flex-start', // Add this
94
+ const getJustifyContent = (justify: string): React.CSSProperties['justifyContent'] => {
95
+ if (justify === 'initial') return 'initial';
96
+
97
+ const justifyMap: Record<string, React.CSSProperties['justifyContent']> = {
98
+ around: 'space-around',
99
+ between: 'space-between',
100
+ evenly: 'space-evenly',
101
+ start: 'flex-start',
102
+ end: 'flex-end',
103
+ center: 'center',
104
+ 'flex-start': 'flex-start', // Add this
105
+ };
106
+
107
+ return justifyMap[justify] || justify || 'flex-start'; // Default to flex-start
105
108
  };
106
-
107
- return justifyMap[justify] || justify || 'flex-start'; // Default to flex-start
108
- };
109
109
 
110
110
  // Handle alignment with proper CSS values
111
- const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSProperties['alignItems'] => {
112
- if (align === 'initial') return 'initial';
113
-
114
- const alignMap: Record<string, React.CSSProperties['alignItems']> = {
115
- start: 'flex-start',
116
- end: 'flex-end',
117
- center: 'center',
118
- stretch: 'stretch',
119
- baseline: 'baseline',
120
- 'flex-start': 'flex-start', // Add this
111
+ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSProperties['alignItems'] => {
112
+ if (align === 'initial') return 'initial';
113
+
114
+ const alignMap: Record<string, React.CSSProperties['alignItems']> = {
115
+ start: 'flex-start',
116
+ end: 'flex-end',
117
+ center: 'center',
118
+ stretch: 'stretch',
119
+ baseline: 'baseline',
120
+ 'flex-start': 'flex-start', // Add this
121
+ };
122
+
123
+ return (typeof align === 'string' && alignMap[align]) || align || 'flex-start'; // Default to flex-start
121
124
  };
122
-
123
- return (typeof align === 'string' && alignMap[align]) || align || 'flex-start'; // Default to flex-start
124
- };
125
125
 
126
126
  // Build background image URL with Linode URL prefix
127
127
  const getBackgroundImageUrl = (): string => {
128
128
  if (!props.bgImage) return 'none';
129
-
129
+
130
130
  const bgImage = props.bgImage;
131
131
  // If the image URL already starts with http:// or https://, use it as is
132
132
  if (typeof bgImage === 'string' && (bgImage.startsWith('http://') || bgImage.startsWith('https://'))) {
@@ -169,16 +169,16 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
169
169
  // compOrder is 1-indexed (1 = first component, 2 = second component, etc.)
170
170
  const orderedChildren: React.ReactNode[] = [];
171
171
  const usedIndices = new Set<number>();
172
-
172
+
173
173
  for (const orderIndex of orderArray) {
174
174
  const oneIndexed = parseInt(orderIndex, 10);
175
175
  if (isNaN(oneIndexed) || oneIndexed < 1) {
176
176
  continue; // Skip invalid indices
177
177
  }
178
-
178
+
179
179
  // Convert from 1-indexed to 0-indexed
180
180
  const zeroIndexed = oneIndexed - 1;
181
-
181
+
182
182
  // Check if index is valid and not already used
183
183
  if (zeroIndexed >= 0 && zeroIndexed < originalChildrenArray.length && !usedIndices.has(zeroIndexed)) {
184
184
  orderedChildren.push(originalChildrenArray[zeroIndexed]);
@@ -202,7 +202,7 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
202
202
  };
203
203
 
204
204
  const childrenArray = getOrderedChildren();
205
-
205
+
206
206
  // Layout styles
207
207
  const rowLayout = {
208
208
  display: 'flex',
@@ -232,10 +232,10 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
232
232
  const renderLayout = () => {
233
233
  if (!props.layout) {
234
234
  return (
235
- <div style={{
236
- display: 'flex',
237
- flexDirection: 'column',
238
- alignItems: 'center',
235
+ <div style={{
236
+ display: 'flex',
237
+ flexDirection: 'column',
238
+ alignItems: 'center',
239
239
  justifyContent: 'center',
240
240
  height: '100%',
241
241
  color: '#666',
@@ -246,66 +246,67 @@ const getAlignItems = (align: React.CSSProperties['alignItems']): React.CSSPrope
246
246
  </div>
247
247
  );
248
248
  }
249
-
250
- switch(props.layout) {
249
+
250
+ switch (props.layout) {
251
251
  case "layout1":
252
252
  return (
253
- <div style={{
253
+ <div style={{
254
254
  width: "100%",
255
- height: "100%",
256
- minHeight: "50px",
257
- boxSizing: "border-box",
258
- overflow: "hidden",
259
- justifyContent:"center",
260
- alignItems:props.align,
261
-
255
+ height: "100%",
256
+ minHeight: "50px",
257
+ boxSizing: "border-box",
258
+ overflow: "hidden",
259
+ // justifyContent: "center",
260
+ // alignItems: props.align,
261
+
262
262
  }}>
263
- <div style={{
264
-
265
- display:"flex",
266
- justifyContent:props.justify,
267
- alignItems:props.align,
268
- height: "100%"
269
- }}>
270
- <div style={{width:'100%'}}> {childrenArray}</div>
271
- </div>
263
+ <div style={{
264
+ display: "flex",
265
+ flexDirection: "column",
266
+ justifyContent: getJustifyContent(props.justify),
267
+ alignItems: getAlignItems(props.align),
268
+ height: "100%",
269
+ width: "100%"
270
+ }}>
271
+ <div style={{ width: '100%' }}> {childrenArray}</div>
272
+ </div>
272
273
  </div>
273
274
  );
274
-
275
+
275
276
  case "layout2":
276
- return (
277
- <div style={{
278
- display: 'flex',
279
- flexDirection: 'row', // Display in row (side by side)
280
- width: '100%',
281
- height: '100%',
282
- margin: 0,
283
- padding: 0,
284
- boxSizing: 'border-box'
285
- }}>
286
- {[0, 1].map((idx) => (
287
- <div
288
- key={`BOX-LAYOUT2-${idx}`}
289
- style={{
290
- ...colLayout,
291
- minWidth: "50%",
292
- width: '50%',
293
- flex: 1
294
- }}
295
- >
296
- {!isEmpty(childrenArray[idx]) ? (
297
- <div style={{ width: '100%', height: '100%', position: 'relative' }}>
298
- {childrenArray[idx]}
299
- </div>
300
- ) : (
301
- <div style={{ textAlign: 'center', color: '#999' }}>
302
- No component here
303
- </div>
304
- )}
305
- </div>
306
- ))}
307
- </div>
308
- );
277
+ return (
278
+ <div style={{
279
+ display: 'flex',
280
+ flexDirection: 'row', // Display in row (side by side)
281
+ width: '100%',
282
+ height: '100%',
283
+ margin: 0,
284
+ padding: 0,
285
+ boxSizing: 'border-box'
286
+ }}>
287
+ {[0, 1].map((idx) => (
288
+ <div
289
+ key={`BOX-LAYOUT2-${idx}`}
290
+ style={{
291
+ ...colLayout,
292
+ minWidth: "50%",
293
+ width: '50%',
294
+ flex: 1
295
+ }}
296
+ >
297
+ {!isEmpty(childrenArray[idx]) ? (
298
+ <div style={{ width: '100%', height: '100%', position: 'relative' }}>
299
+ {childrenArray[idx]}
300
+ </div>
301
+ ) : (
302
+ <div style={{ textAlign: 'center', color: '#999' }}>
303
+ No component here
304
+ </div>
305
+ )}
306
+ </div>
307
+ ))}
308
+ </div>
309
+ );
309
310
  case "layout3":
310
311
  return (
311
312
  <div style={{ ...rowLayout, flexDirection: 'column', height: '100%', minHeight: 0 }}>
@@ -457,7 +458,7 @@ height: "100%"
457
458
  const hasBackgroundImage = backgroundImageUrl !== 'none';
458
459
 
459
460
  return (
460
- <div
461
+ <div
461
462
  style={{
462
463
  // bgImage takes priority over bgColor
463
464
  backgroundColor: hasBackgroundImage ? 'transparent' : props.bgColor,
@@ -41,7 +41,7 @@ interface PageData {
41
41
  pg_type?: string | null;
42
42
 
43
43
  page_id?: any;
44
- page_data?:any;
44
+ page_data?: any;
45
45
  }
46
46
 
47
47
  interface ImageItem {
@@ -169,7 +169,7 @@ const ImageComponentInternal: React.FC<ImageComponentProps> = ({
169
169
  const buildLink = () => {
170
170
  console.warn(linkData)
171
171
  switch (linkData.linktype) {
172
-
172
+
173
173
  case 'NONE':
174
174
  return null;
175
175
  case 'EXTERNAL_LINK':
@@ -187,21 +187,21 @@ const ImageComponentInternal: React.FC<ImageComponentProps> = ({
187
187
  case 'TAG':
188
188
  return `/tag/${linkData.tag?.tag_id?.code || linkData?.tag?.tag_data?.code}`;
189
189
  case 'PAGE':
190
- return `/page/${linkData.page?.page_id?._id || linkData.page?.page_data?._id }?type=${linkData.page?.page_type || linkData.page?.pg_type}`;
190
+ return `/page/${linkData.page?.page_id?._id || linkData.page?.page_data?._id}?type=${linkData.page?.page_type || linkData.page?.pg_type}`;
191
191
  default:
192
192
  return null;
193
193
  }
194
194
  };
195
195
 
196
196
  // const handleImageClick = () => {
197
- // const link = buildLink();
198
- // if (link === null) return;
199
-
200
- // if (link.startsWith('http')) {
201
- // window.open(link, linkData.link?.target || '_blank');
202
- // } else {
203
- // window.location.href = link;
204
- // }
197
+ // const link = buildLink();
198
+ // if (link === null) return;
199
+
200
+ // if (link.startsWith('http')) {
201
+ // window.open(link, linkData.link?.target || '_blank');
202
+ // } else {
203
+ // window.location.href = link;
204
+ // }
205
205
  // };
206
206
 
207
207
  const imageStyle: React.CSSProperties = {
@@ -214,16 +214,16 @@ const ImageComponentInternal: React.FC<ImageComponentProps> = ({
214
214
  };
215
215
 
216
216
  return (
217
- <a
217
+ <a
218
218
  href={buildLink() ?? undefined}
219
219
  target={
220
220
  linkData?.linktype === 'EXTERNAL'
221
- ? (linkData?.link?.target ?? '_blank')
221
+ ? (linkData?.link?.target ?? '_blank')
222
222
  : '_self'
223
223
  }
224
- style={{
225
- display: 'block',
226
- width: '100%',
224
+ style={{
225
+ display: 'block',
226
+ width: '100%',
227
227
  height: '100%',
228
228
  textDecoration: 'none',
229
229
  color: 'inherit'
@@ -261,10 +261,10 @@ const ImageComponentInternal: React.FC<ImageComponentProps> = ({
261
261
  };
262
262
 
263
263
  // Main GroupImageList Component
264
- const GroupImageList: React.FC<GroupImageListMainProps> = ({
265
- props,
266
- deviceMode = 'web',
267
- boxHeight
264
+ const GroupImageList: React.FC<GroupImageListMainProps> = ({
265
+ props,
266
+ deviceMode = 'web',
267
+ boxHeight
268
268
  }) => {
269
269
  const getCurrentBooleanProp = (prop?: DeviceBooleanProps) => {
270
270
  if (!prop) return false;
@@ -319,22 +319,22 @@ const GroupImageList: React.FC<GroupImageListMainProps> = ({
319
319
  }
320
320
  };
321
321
 
322
- const ImageCard = ({ item, large = false }: { item: ImageItem; large?: boolean }) => {
322
+ const ImageCard = ({ item }: { item: ImageItem }) => {
323
323
  const [isHovered, setIsHovered] = useState(false);
324
-
324
+
325
325
  return (
326
326
  <div
327
327
  className="imageCard"
328
328
  style={{
329
329
  height: '100%',
330
- minHeight: large ? '280px' : '260px',
330
+ minHeight: '260px',
331
331
  borderRadius: '8px',
332
332
  overflow: 'hidden',
333
333
  border: '1px solid #eee',
334
334
  backgroundColor: props.cardcolor || '#fff',
335
335
  display: 'flex',
336
336
  flexDirection: 'column',
337
- padding: large ? '16px' : '12px',
337
+ padding: '12px',
338
338
  boxShadow: isHovered ? '0 4px 8px rgba(0,0,0,0.15)' : '0 2px 4px rgba(0,0,0,0.1)',
339
339
  transition: 'all 0.2s ease',
340
340
  cursor: item.linktype !== 'NONE' ? 'pointer' : 'default',
@@ -343,14 +343,16 @@ const GroupImageList: React.FC<GroupImageListMainProps> = ({
343
343
  onMouseOver={() => setIsHovered(true)}
344
344
  onMouseOut={() => setIsHovered(false)}
345
345
  >
346
- <div style={{
347
- width: '100%',
348
- height: large ? '200px' : '180px',
349
- minHeight: large ? '200px' : '180px',
350
- maxHeight: large ? '200px' : '180px',
351
- marginBottom: large ? '12px' : '8px',
352
- display: 'flex',
353
- alignItems: 'center',
346
+ <div style={{
347
+ // width: '100%',
348
+ // height: '180px',
349
+ minHeight: '180px',
350
+ maxHeight: '180px',
351
+ minWidth:'200px',
352
+ maxWidth:'400px',
353
+ marginBottom: '8px',
354
+ display: 'flex',
355
+ alignItems: 'center',
354
356
  justifyContent: 'center',
355
357
  overflow: 'hidden',
356
358
  flexShrink: 0
@@ -369,21 +371,21 @@ const GroupImageList: React.FC<GroupImageListMainProps> = ({
369
371
  width="100%"
370
372
  />
371
373
  </div>
372
- <div style={{
373
- display: 'flex',
374
- flexDirection: 'column',
374
+ <div style={{
375
+ display: 'flex',
376
+ flexDirection: 'column',
375
377
  flexShrink: 0,
376
378
  minHeight: 0
377
379
  }}>
378
380
  {showTitle && item.title && (
379
- <div style={{
380
- textAlign: 'center',
381
- fontSize: props.titleStyle ? `${props.titleStyle.fontSize}px` : (large ? '16px' : '14px'),
382
- fontWeight: props.titleStyle?.isBold ? 'bold' : (large ? 600 : 500),
383
- color: props.titleStyle?.fontColor || '#333',
381
+ <div style={{
382
+ textAlign: 'center',
383
+ fontSize: props.titleStyle ? `${props.titleStyle.fontSize}px` : '14px',
384
+ fontWeight: props.titleStyle?.isBold ? 'bold' : 500,
385
+ color: props.titleStyle?.fontColor || '#333',
384
386
  fontStyle: props.titleStyle?.isItalic ? 'italic' : 'normal',
385
387
  textDecoration: props.titleStyle?.isUnderline ? 'underline' : 'none',
386
- lineHeight: '1.4',
388
+ lineHeight: '1.4',
387
389
  marginBottom: showSubtitle && item.subTitle ? '4px' : '0',
388
390
  overflow: 'hidden',
389
391
  textOverflow: 'ellipsis',
@@ -396,11 +398,11 @@ const GroupImageList: React.FC<GroupImageListMainProps> = ({
396
398
  </div>
397
399
  )}
398
400
  {showSubtitle && item.subTitle && (
399
- <div style={{
400
- textAlign: 'center',
401
- fontSize: props.subtitleStyle ? `${props.subtitleStyle.fontSize}px` : (large ? '14px' : '12px'),
402
- fontWeight: props.subtitleStyle?.isBold ? 'bold' : 400,
403
- color: props.subtitleStyle?.fontColor || '#666',
401
+ <div style={{
402
+ textAlign: 'center',
403
+ fontSize: props.subtitleStyle ? `${props.subtitleStyle.fontSize}px` : '12px',
404
+ fontWeight: props.subtitleStyle?.isBold ? 'bold' : 400,
405
+ color: props.subtitleStyle?.fontColor || '#666',
404
406
  fontStyle: props.subtitleStyle?.isItalic ? 'italic' : 'normal',
405
407
  textDecoration: props.subtitleStyle?.isUnderline ? 'underline' : 'none',
406
408
  lineHeight: '1.3',
@@ -530,11 +532,11 @@ const GroupImageList: React.FC<GroupImageListMainProps> = ({
530
532
  >
531
533
  {images.length > 0 ? (
532
534
  currentLayout === 'NONE' ? (
533
- <div
535
+ <div
534
536
  className="scrollable-container"
535
- style={{
536
- display: 'flex',
537
- gap: '12px',
537
+ style={{
538
+ display: 'flex',
539
+ gap: '12px',
538
540
  overflowX: isHorizontalScroll ? 'auto' : 'hidden',
539
541
  overflowY: 'hidden',
540
542
  alignItems: 'stretch',
@@ -545,8 +547,8 @@ const GroupImageList: React.FC<GroupImageListMainProps> = ({
545
547
  <div
546
548
  key={image.id}
547
549
  style={{
548
- minWidth: '250px',
549
- width: '250px',
550
+ minWidth: '400px',
551
+ width: '400px',
550
552
  flexShrink: 0,
551
553
  display: 'flex',
552
554
  flexDirection: 'column',
@@ -559,15 +561,15 @@ const GroupImageList: React.FC<GroupImageListMainProps> = ({
559
561
  </div>
560
562
 
561
563
  ) : currentLayout === 'SMALL' ? (
562
- <div style={{
563
- display: 'grid',
564
- gridTemplateColumns: 'repeat(2, 1fr)',
565
- gap: '16px',
564
+ <div style={{
565
+ display: 'grid',
566
+ gridTemplateColumns: 'repeat(2, 1fr)',
567
+ gap: '16px',
566
568
  padding: '8px',
567
569
  height: '100%'
568
570
  }}>
569
571
  {images.map((image) => (
570
- <div key={image.id} style={{
572
+ <div key={image.id} style={{
571
573
  height: '100%',
572
574
  display: 'flex',
573
575
  flexDirection: 'column'
@@ -577,17 +579,17 @@ const GroupImageList: React.FC<GroupImageListMainProps> = ({
577
579
  ))}
578
580
  </div>
579
581
  ) : currentLayout === 'MEDIUM' ? (
580
- <div style={{
581
- display: 'grid',
582
- gridTemplateColumns: 'repeat(3, 1fr)',
583
- gap: '16px',
582
+ <div style={{
583
+ display: 'grid',
584
+ gridTemplateColumns: 'repeat(3, 1fr)',
585
+ gap: '16px',
584
586
  padding: '8px',
585
587
  height: 'auto',
586
588
  overflowX: 'auto',
587
589
 
588
590
  }}>
589
591
  {images.map((image) => (
590
- <div key={image.id} style={{
592
+ <div key={image.id} style={{
591
593
  height: '100%',
592
594
  display: 'flex',
593
595
  flexDirection: 'column'
@@ -598,27 +600,27 @@ const GroupImageList: React.FC<GroupImageListMainProps> = ({
598
600
  ))}
599
601
  </div>
600
602
  ) : currentLayout === 'MEDIUM_THREE' ? (
601
- <div style={{
602
- display: 'flex',
603
- flexDirection: 'column',
604
- gap: '16px',
603
+ <div style={{
604
+ display: 'flex',
605
+ flexDirection: 'column',
606
+ gap: '16px',
605
607
  padding: '8px',
606
608
  height: '100%'
607
609
  }}>
608
610
  {images.length > 0 && (
609
611
  <div style={{ flex: '2', minHeight: '200px' }}>
610
- <ImageCard item={images[0]} large />
612
+ <ImageCard item={images[0]} />
611
613
  </div>
612
614
  )}
613
615
  {images.length > 1 && (
614
- <div style={{
615
- display: 'grid',
616
- gridTemplateColumns: 'repeat(2, 1fr)',
616
+ <div style={{
617
+ display: 'grid',
618
+ gridTemplateColumns: 'repeat(2, 1fr)',
617
619
  gap: '16px',
618
620
  flex: '1'
619
621
  }}>
620
622
  {images.slice(1).map((image) => (
621
- <div key={image.id} style={{
623
+ <div key={image.id} style={{
622
624
  height: '100%',
623
625
  display: 'flex',
624
626
  flexDirection: 'column'