tee3apps-cms-sdk-react 0.0.33 → 0.0.34

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.33",
3
+ "version": "0.0.34",
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",
@@ -61,6 +61,7 @@ export interface CarouselProps {
61
61
  pagingDotVisible: boolean;
62
62
  objectFit: string;
63
63
  slides: SlidesData[] | Slide[][]; // Support both formats: SlidesData[] or nested array Slide[][]
64
+ mode?: SlideMode;
64
65
  }
65
66
 
66
67
  interface CarouselComponentMainProps {
@@ -77,20 +78,20 @@ const CarouselComponent: React.FC<CarouselComponentMainProps> = ({
77
78
  const [isHovered, setIsHovered] = useState(false);
78
79
  const [prevButtonHovered, setPrevButtonHovered] = useState(false);
79
80
  const [nextButtonHovered, setNextButtonHovered] = useState(false);
80
-
81
+
81
82
  // Detect data structure and safely get slides with fallback
82
83
  // Check if slides[0] is an array of Slide objects (new format) or has 'all' property (old format)
83
84
  const firstSlideItem = props.slides && props.slides[0] ? props.slides[0] : null;
84
-
85
+
85
86
  // Check if it's the new nested array format (array of Slide objects)
86
- const isNestedArrayFormat = Array.isArray(firstSlideItem) &&
87
- firstSlideItem.length > 0 &&
88
- typeof firstSlideItem[0] === 'object' &&
89
- 'sl_id' in (firstSlideItem[0] as any);
90
-
87
+ const isNestedArrayFormat = Array.isArray(firstSlideItem) &&
88
+ firstSlideItem.length > 0 &&
89
+ typeof firstSlideItem[0] === 'object' &&
90
+ 'sl_id' in (firstSlideItem[0] as any);
91
+
91
92
  let slides: Slide[] = [];
92
93
  let slidesData: SlidesData | null = null;
93
-
94
+
94
95
  if (isNestedArrayFormat) {
95
96
  // New format: slides is Slide[][] - first element is an array of Slide objects
96
97
  slides = (firstSlideItem as Slide[]) || [];
@@ -102,29 +103,36 @@ const CarouselComponent: React.FC<CarouselComponentMainProps> = ({
102
103
  // Fallback: empty array
103
104
  slides = [];
104
105
  }
105
-
106
+
106
107
  const totalSlides = slides.length;
107
108
 
108
109
  // Get current mode settings
109
110
  const getCurrentMode = () => {
110
- // If using nested array format, mode data doesn't exist, use defaults
111
- if (isNestedArrayFormat || !slidesData || !slidesData.mode) {
111
+ // 1. Check if mode is at the root (props.mode)
112
+ const rootMode = props.mode;
113
+
114
+ // 2. Check if mode is inside slides (old format - slidesData.mode)
115
+ const nestedMode = (!isNestedArrayFormat && slidesData) ? slidesData.mode : null;
116
+
117
+ const activeMode = rootMode || nestedMode;
118
+
119
+ if (!activeMode) {
112
120
  // Return default mode based on device
113
- const defaultSlidesToShow = deviceMode === 'mobileweb' || deviceMode === 'mobileapp' ? 1 :
114
- deviceMode === 'tablet' ? 2 : 1;
121
+ const defaultSlidesToShow = deviceMode === 'mobileweb' || deviceMode === 'mobileapp' ? 1 :
122
+ deviceMode === 'tablet' ? 2 : 1;
115
123
  return { slidesToShow: defaultSlidesToShow };
116
124
  }
117
-
118
- switch(deviceMode) {
125
+
126
+ switch (deviceMode) {
119
127
  case 'mobileweb':
120
- return slidesData.mode.mobileweb || { slidesToShow: 1 };
128
+ return activeMode.mobileweb || { slidesToShow: 1 };
121
129
  case 'mobileapp':
122
- return slidesData.mode.mobileapp || { slidesToShow: 1 };
130
+ return activeMode.mobileapp || { slidesToShow: 1 };
123
131
  case 'tablet':
124
- return slidesData.mode.tablet || { slidesToShow: 1 };
132
+ return activeMode.tablet || { slidesToShow: 1 };
125
133
  case 'web':
126
134
  default:
127
- return slidesData.mode.web || { slidesToShow: 1 };
135
+ return activeMode.web || { slidesToShow: 1 };
128
136
  }
129
137
  };
130
138
 
@@ -254,7 +262,7 @@ const CarouselComponent: React.FC<CarouselComponentMainProps> = ({
254
262
  };
255
263
 
256
264
  return (
257
- <div
265
+ <div
258
266
  className="carousel-container"
259
267
  style={{
260
268
  position: 'relative',
@@ -286,7 +294,7 @@ const CarouselComponent: React.FC<CarouselComponentMainProps> = ({
286
294
  const startIndex = groupIndex * slidesToShow;
287
295
  // Calculate how many slides are in this group (last group may have fewer)
288
296
  const slidesInGroup = Math.min(slidesToShow, totalSlides - startIndex);
289
-
297
+
290
298
  return (
291
299
  <div
292
300
  key={groupIndex}
@@ -303,7 +311,7 @@ const CarouselComponent: React.FC<CarouselComponentMainProps> = ({
303
311
  >
304
312
  {Array.from({ length: slidesToShow }).map((_, offset) => {
305
313
  const slideIndex = startIndex + offset;
306
-
314
+
307
315
  // If this position is beyond available slides, render empty space
308
316
  if (slideIndex >= totalSlides) {
309
317
  return (
@@ -319,9 +327,9 @@ const CarouselComponent: React.FC<CarouselComponentMainProps> = ({
319
327
  />
320
328
  );
321
329
  }
322
-
330
+
323
331
  const slide = slides[slideIndex];
324
-
332
+
325
333
  return (
326
334
  <div
327
335
  key={`${slide.sl_id}-${offset}`}
@@ -343,9 +351,9 @@ const CarouselComponent: React.FC<CarouselComponentMainProps> = ({
343
351
  {slide.sl_type === 'video' ? (
344
352
  <video
345
353
  src={resolveAssetUrl(slide.video?.url)}
346
- style={{
347
- width: '100%',
348
- height: '100%',
354
+ style={{
355
+ width: '100%',
356
+ height: '100%',
349
357
  objectFit: props.objectFit as any,
350
358
  display: 'block',
351
359
  pointerEvents: 'none'
@@ -359,9 +367,9 @@ const CarouselComponent: React.FC<CarouselComponentMainProps> = ({
359
367
  <img
360
368
  src={resolveAssetUrl(slide.image?.url)}
361
369
  alt={slide.image?.alt || ''}
362
- style={{
363
- width: '100%',
364
- height: '100%',
370
+ style={{
371
+ width: '100%',
372
+ height: '100%',
365
373
  objectFit: props.objectFit as any,
366
374
  display: 'block',
367
375
  pointerEvents: 'none'
@@ -470,7 +478,7 @@ const CarouselComponent: React.FC<CarouselComponentMainProps> = ({
470
478
  const firstSlideInGroup = groupIndex * slidesToShow;
471
479
  goToSlide(firstSlideInGroup);
472
480
  };
473
-
481
+
474
482
  return (
475
483
  <button
476
484
  key={groupIndex}
@@ -8,27 +8,27 @@ interface PageImage {
8
8
  url: string;
9
9
  width: number;
10
10
  height: number;
11
- }
12
-
13
- interface PageId {
11
+ }
12
+
13
+ interface PageId {
14
14
  _id: string;
15
15
  name: string;
16
16
  code: string;
17
17
  image: PageImage;
18
18
  isActive: boolean;
19
- }
20
-
21
- interface Channel {
19
+ }
20
+
21
+ interface Channel {
22
22
  _id: string;
23
23
  name: string;
24
24
  code: string;
25
25
  isActive: boolean;
26
- }
27
-
28
- interface PageDataItem {
26
+ }
27
+
28
+ interface PageDataItem {
29
29
  page_id: any;
30
30
  channel: Channel;
31
- }
31
+ }
32
32
  interface BrandImage {
33
33
  shapeImageId: string;
34
34
  shape: string;
@@ -64,7 +64,7 @@ interface GroupBrandDynamic {
64
64
  interface GroupBrandData {
65
65
  static: GroupBrandStatic;
66
66
  dynamic: GroupBrandDynamic;
67
- showItems:BrandItem[];
67
+ showItems: BrandItem[];
68
68
  }
69
69
 
70
70
  interface HeaderTextStyle {
@@ -93,7 +93,7 @@ export interface GroupBrandComponentProps {
93
93
  headerText: any;
94
94
  type: string;
95
95
  groupbrand: GroupBrandData;
96
- showItems?:BrandItem[];
96
+ showItems?: BrandItem[];
97
97
  selectedBrands?: BrandItem[];
98
98
  items?: BrandItem[];
99
99
  cardColor: string;
@@ -127,15 +127,15 @@ const GroupBrandComponent: React.FC<GroupBrandComponentMainProps> = ({ props, de
127
127
  // Safely fall back to web, then to 'NONE' if the specific layout is missing
128
128
  if (!props.layout) return 'NONE';
129
129
  switch (deviceMode) {
130
- case 'mobileweb': return props.layout.mobileweb || 'NONE';
131
- case 'mobileapp': return props.layout.mobileapp || 'NONE';
132
- case 'tablet': return props.layout.tablet || 'NONE';
130
+ case 'mobileweb': return props.layout.mobileweb || 'NONE';
131
+ case 'mobileapp': return props.layout.mobileapp || 'NONE';
132
+ case 'tablet': return props.layout.tablet || 'NONE';
133
133
  case 'web':
134
134
  default: return props.layout.web || 'NONE';
135
135
  }
136
136
  };
137
137
 
138
-
138
+
139
139
 
140
140
  const showHeader = getCurrentBooleanProp(props.showHeader);
141
141
  const showBrandName = getCurrentBooleanProp(props.showProductName);
@@ -184,25 +184,25 @@ const GroupBrandComponent: React.FC<GroupBrandComponentMainProps> = ({ props, de
184
184
 
185
185
  const buildBrandHref = (item: BrandItem): string | null => {
186
186
  console.log(item);
187
-
187
+
188
188
  // Check if item has pages and at least one page exists
189
189
  if (item.pages && item.pages.length > 0) {
190
190
  const firstPage = item.pages[0];
191
-
191
+
192
192
  // Check if the page is active
193
- console.log(firstPage.page_id?._id);
194
- // If page is active, use the brand page format
195
- return `/page/${encodeURIComponent(firstPage.page_id)}`;
196
-
193
+ console.log(firstPage.page_id?._id);
194
+ // If page is active, use the brand page format
195
+ return `/page/${encodeURIComponent(firstPage.page_id)}`;
196
+
197
197
  }
198
-
198
+
199
199
  // Fallback if no pages exist
200
200
  return null;
201
201
  };
202
202
 
203
203
  const Card = ({ item, large = false }: { item: BrandItem; large?: boolean }) => (
204
204
  <a
205
- href={buildBrandHref(item)|| undefined}
205
+ href={buildBrandHref(item) || undefined}
206
206
  style={{ textDecoration: 'none', color: 'inherit', height: '100%', display: 'block' }}
207
207
  >
208
208
  <div
@@ -244,154 +244,167 @@ const GroupBrandComponent: React.FC<GroupBrandComponentMainProps> = ({ props, de
244
244
  );
245
245
 
246
246
  return (
247
- <div
248
- style={{
249
- border: '1px solid #e1e1e1',
250
- width: '100%',
251
- maxWidth: '100%',
252
- borderRadius: '0px',
253
- minHeight: '100px',
254
- position: 'relative',
255
- overflow: 'visible',
256
- marginBottom: '20px',
257
- marginTop: '0px',
258
- display: 'flex',
259
- flexDirection: 'column',
260
- height: '100%'
261
- }}
262
- className='GroupBrandComponent'
263
- >
264
- {showHeader && (
265
- <div
266
- className="groupBrandHeader"
267
- style={{
268
- backgroundColor: props.headerBackground,
269
- padding: '12px 16px',
270
- borderRadius: '0px',
271
- marginBottom: '4px',
272
- display: 'flex',
273
- alignItems: 'center',
274
- justifyContent: 'space-between',
275
- flexWrap: 'wrap',
276
- gap: '12px',
277
- }}
278
- >
279
- <p style={{
280
- color: props.headerTextStyle.fontColor,
281
- fontSize: `${props.headerTextStyle.fontSize}px`,
282
- fontWeight: props.headerTextStyle.isBold ? 'bold' : 'normal',
283
- fontStyle: props.headerTextStyle.isItalic ? 'italic' : 'normal',
284
- textDecoration: props.headerTextStyle.isUnderline ? 'underline' : 'none',
285
- margin: 0
286
- }}>
287
- {props.headerText || 'Brands'}
288
- </p>
289
-
290
- {currentLayout === 'NONE' && brands.length > 0 && (
291
- <div style={{ display: 'flex', gap: '8px' }}>
292
- <button
293
- onClick={scrollLeft}
294
- style={{
295
- width: '32px',
296
- height: '32px',
297
- borderRadius: '50%',
298
- border: '1px solid #ddd',
299
- backgroundColor: '#fff',
300
- cursor: 'pointer',
301
- display: 'flex',
302
- alignItems: 'center',
303
- justifyContent: 'center',
304
- fontSize: '16px',
305
- fontWeight: 'bold'
306
- }}
307
- onMouseOver={(e) => { e.currentTarget.style.backgroundColor = '#f8f9fa'; }}
308
- onMouseOut={(e) => { e.currentTarget.style.backgroundColor = '#fff'; }}
309
- >
310
-
311
- </button>
312
- <button
313
- onClick={scrollRight}
314
- style={{
315
- width: '32px',
316
- height: '32px',
317
- borderRadius: '50%',
318
- border: '1px solid #ddd',
319
- backgroundColor: '#fff',
320
- cursor: 'pointer',
321
- display: 'flex',
322
- alignItems: 'center',
323
- justifyContent: 'center',
324
- fontSize: '16px',
325
- fontWeight: 'bold'
326
- }}
327
- onMouseOver={(e) => { e.currentTarget.style.backgroundColor = '#f8f9fa'; }}
328
- onMouseOut={(e) => { e.currentTarget.style.backgroundColor = '#fff'; }}
329
- >
330
-
331
- </button>
332
- </div>
333
- )}
334
- </div>
335
- )}
336
-
247
+ <>
248
+ <style>
249
+ {`
250
+ .groupBrandCarousel::-webkit-scrollbar {
251
+ display: none;
252
+ }
253
+ .groupBrandCarousel {
254
+ scrollbar-width: none;
255
+ -ms-overflow-style: none;
256
+ }
257
+ `}
258
+ </style>
337
259
  <div
338
260
  style={{
339
- display: currentLayout === 'NONE' ? 'flex' : 'block',
340
- overflowX: currentLayout === 'NONE' ? (isHorizontalScroll ? 'auto' : 'hidden') : 'visible',
341
- overflowY: currentLayout === 'NONE' ? 'hidden' : 'visible',
342
- alignItems: currentLayout === 'NONE' ? 'stretch' : undefined,
343
- gap: currentLayout === 'NONE' ? '12px' : '0',
344
- padding: '12px',
345
- scrollBehavior: 'smooth',
346
- backgroundColor: props.cardColor || '#fff',
347
- borderRadius: '8px',
261
+ border: '1px solid #e1e1e1',
262
+ width: '100%',
263
+ maxWidth: '100%',
264
+ borderRadius: '0px',
265
+ minHeight: '100px',
348
266
  position: 'relative',
349
- flex: 1,
350
- minHeight: 0,
267
+ overflow: 'visible',
268
+ marginBottom: '20px',
269
+ marginTop: '0px',
270
+ display: 'flex',
271
+ flexDirection: 'column',
272
+ height: '100%'
351
273
  }}
352
- className="groupBrandCarousel"
274
+ className='GroupBrandComponent'
353
275
  >
354
- {brands.length > 0 ? (
355
- currentLayout === 'NONE' ? (
356
- brands.map((brand) => (
357
- <div key={brand.code} style={{ minWidth: '150px', width: '150px', flexShrink: 0, display: 'flex', flexDirection: 'column', height: '100%' }}>
358
- <Card item={brand} />
276
+ {showHeader && (
277
+ <div
278
+ className="groupBrandHeader"
279
+ style={{
280
+ backgroundColor: props.headerBackground,
281
+ padding: '12px 16px',
282
+ borderRadius: '0px',
283
+ marginBottom: '4px',
284
+ display: 'flex',
285
+ alignItems: 'center',
286
+ justifyContent: 'space-between',
287
+ flexWrap: 'wrap',
288
+ gap: '12px',
289
+ }}
290
+ >
291
+ <p style={{
292
+ color: props.headerTextStyle.fontColor,
293
+ fontSize: `${props.headerTextStyle.fontSize}px`,
294
+ fontWeight: props.headerTextStyle.isBold ? 'bold' : 'normal',
295
+ fontStyle: props.headerTextStyle.isItalic ? 'italic' : 'normal',
296
+ textDecoration: props.headerTextStyle.isUnderline ? 'underline' : 'none',
297
+ margin: 0
298
+ }}>
299
+ {props.headerText || 'Brands'}
300
+ </p>
301
+
302
+ {currentLayout === 'NONE' && brands.length > 0 && (
303
+ <div style={{ display: 'flex', gap: '8px' }}>
304
+ <button
305
+ onClick={scrollLeft}
306
+ style={{
307
+ width: '32px',
308
+ height: '32px',
309
+ borderRadius: '50%',
310
+ border: '1px solid #ddd',
311
+ backgroundColor: '#fff',
312
+ cursor: 'pointer',
313
+ display: 'flex',
314
+ alignItems: 'center',
315
+ justifyContent: 'center',
316
+ fontSize: '16px',
317
+ fontWeight: 'bold'
318
+ }}
319
+ onMouseOver={(e) => { e.currentTarget.style.backgroundColor = '#f8f9fa'; }}
320
+ onMouseOut={(e) => { e.currentTarget.style.backgroundColor = '#fff'; }}
321
+ >
322
+
323
+ </button>
324
+ <button
325
+ onClick={scrollRight}
326
+ style={{
327
+ width: '32px',
328
+ height: '32px',
329
+ borderRadius: '50%',
330
+ border: '1px solid #ddd',
331
+ backgroundColor: '#fff',
332
+ cursor: 'pointer',
333
+ display: 'flex',
334
+ alignItems: 'center',
335
+ justifyContent: 'center',
336
+ fontSize: '16px',
337
+ fontWeight: 'bold'
338
+ }}
339
+ onMouseOver={(e) => { e.currentTarget.style.backgroundColor = '#f8f9fa'; }}
340
+ onMouseOut={(e) => { e.currentTarget.style.backgroundColor = '#fff'; }}
341
+ >
342
+
343
+ </button>
359
344
  </div>
360
- ))
361
- ) : currentLayout === 'SMALL' ? (
362
- <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '16px', padding: '8px' }}>
363
- {brands.map((brand) => (
364
- <Card key={brand.code} item={brand} />
365
- ))}
366
- </div>
367
- ) : currentLayout === 'MEDIUM' ? (
368
- <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: '16px', padding: '8px' }}>
369
- {brands.map((brand) => (
370
- <Card key={brand.code} item={brand} />
371
- ))}
372
- </div>
373
- ) : currentLayout === 'MEDIUM_THREE' ? (
374
- <div style={{ display: 'flex', flexDirection: 'column', gap: '16px', padding: '8px' }}>
375
- {brands.length > 0 && (
376
- <Card item={brands[0]} large />
377
- )}
378
- {brands.length > 1 && (
379
- <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '16px' }}>
380
- {brands.slice(1).map((brand) => (
381
- <Card key={brand.code} item={brand} />
382
- ))}
383
- </div>
384
- )}
385
- </div>
386
- ) : null
387
- ) : (
388
- <div style={{ textAlign: 'center', color: '#666', padding: '40px', width: '100%', border: '2px dashed #ddd', borderRadius: '8px', backgroundColor: '#f9f9f9' }}>
389
- <p>No brands available.</p>
345
+ )}
390
346
  </div>
391
347
  )}
348
+
349
+ <div
350
+ style={{
351
+ display: currentLayout === 'NONE' ? 'flex' : 'block',
352
+ overflowX: currentLayout === 'NONE' ? (isHorizontalScroll ? 'auto' : 'hidden') : 'visible',
353
+ overflowY: currentLayout === 'NONE' ? 'hidden' : 'visible',
354
+ alignItems: currentLayout === 'NONE' ? 'stretch' : undefined,
355
+ gap: currentLayout === 'NONE' ? '12px' : '0',
356
+ padding: '12px',
357
+ scrollBehavior: 'smooth',
358
+ backgroundColor: props.cardColor || '#fff',
359
+ borderRadius: '8px',
360
+ position: 'relative',
361
+ flex: 1,
362
+ minHeight: 0,
363
+ }}
364
+ className="groupBrandCarousel"
365
+ >
366
+ {brands.length > 0 ? (
367
+ currentLayout === 'NONE' ? (
368
+ brands.map((brand) => (
369
+ <div key={brand.code} style={{ minWidth: '150px', width: '150px', flexShrink: 0, display: 'flex', flexDirection: 'column', height: '100%' }}>
370
+ <Card item={brand} />
371
+ </div>
372
+ ))
373
+ ) : currentLayout === 'SMALL' ? (
374
+ <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '16px', padding: '8px' }}>
375
+ {brands.map((brand) => (
376
+ <Card key={brand.code} item={brand} />
377
+ ))}
378
+ </div>
379
+ ) : currentLayout === 'MEDIUM' ? (
380
+ <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: '16px', padding: '8px' }}>
381
+ {brands.map((brand) => (
382
+ <Card key={brand.code} item={brand} />
383
+ ))}
384
+ </div>
385
+ ) : currentLayout === 'MEDIUM_THREE' ? (
386
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '16px', padding: '8px' }}>
387
+ {brands.length > 0 && (
388
+ <Card item={brands[0]} large />
389
+ )}
390
+ {brands.length > 1 && (
391
+ <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '16px' }}>
392
+ {brands.slice(1).map((brand) => (
393
+ <Card key={brand.code} item={brand} />
394
+ ))}
395
+ </div>
396
+ )}
397
+ </div>
398
+ ) : null
399
+ ) : (
400
+ <div style={{ textAlign: 'center', color: '#666', padding: '40px', width: '100%', border: '2px dashed #ddd', borderRadius: '8px', backgroundColor: '#f9f9f9' }}>
401
+ <p>No brands available.</p>
402
+ </div>
403
+ )}
404
+ </div>
392
405
  </div>
393
- </div>
406
+ </>
394
407
  );
395
408
  };
396
409
 
397
- export default GroupBrandComponent
410
+ export default GroupBrandComponent;