@@ -32,7 +32,7 @@ export class CarouselComponent extends ContentstackComponent {
3232 * Store a component schema for later reuse
3333 */
3434 static storeComponentSchema ( componentType : string , schema : any ) : void {
35- if ( ! globalComponentSchemas . has ( componentType ) ) {
35+ if ( ! globalComponentSchemas ? .has ( componentType ) ) {
3636 globalComponentSchemas . set ( componentType , schema ) ;
3737 }
3838 }
@@ -41,16 +41,16 @@ export class CarouselComponent extends ContentstackComponent {
4141 * Get a stored component schema
4242 */
4343 static getStoredComponentSchema ( componentType : string ) : any | null {
44- return globalComponentSchemas . get ( componentType ) || null ;
44+ return globalComponentSchemas ? .get ( componentType ) || null ;
4545 }
4646
4747 static isCarousel ( component : any ) : boolean {
4848 const properties = component ?. convertedSchema ?. properties ;
4949 if ( properties && typeof properties === 'object' ) {
5050 const typeField = properties [ ":type" ] ;
5151 if (
52- ( typeof typeField === "string" && typeField . includes ( "/components/carousel" ) ) ||
53- ( typeof typeField === "object" && typeField . value ?. includes ( "/components/carousel" ) )
52+ ( typeof typeField === "string" && typeField ? .includes ( "/components/carousel" ) ) ||
53+ ( typeof typeField === "object" && typeField ? .value ?. includes ( "/components/carousel" ) )
5454 ) {
5555 return true ;
5656 }
@@ -87,7 +87,7 @@ export class CarouselComponent extends ContentstackComponent {
8787 const isCarouselItems = normalizedUid === 'items' || fieldKey === 'items' || fieldKey === ':items' ;
8888
8989 if ( isCarouselItems ) {
90- const typesToProcess = globalCarouselItemTypes && globalCarouselItemTypes . size > 0
90+ const typesToProcess = globalCarouselItemTypes && globalCarouselItemTypes ? .size > 0
9191 ? globalCarouselItemTypes
9292 : new Set ( Object . keys ( countObject ) . map ( t => t . split ( '/' ) . pop ( ) ) . filter ( Boolean ) ) ;
9393
@@ -101,15 +101,15 @@ export class CarouselComponent extends ContentstackComponent {
101101 if ( componentType === 'teaser' || componentType === 'heroTeaser' || componentType === 'overlayBoxTeaser' ) {
102102
103103 let teaserData = null ;
104- if ( currentComponent && TeaserComponent . isTeaser ( currentComponent ) ) {
105- teaserData = TeaserComponent . mapTeaserToContentstack ( currentComponent , "teaser" ) ;
104+ if ( currentComponent && TeaserComponent ? .isTeaser ( currentComponent ) ) {
105+ teaserData = TeaserComponent ? .mapTeaserToContentstack ( currentComponent , "teaser" ) ;
106106 if ( teaserData ) {
107107 //store for reuse
108- CarouselComponent . storeComponentSchema ( 'teaser' , teaserData ) ;
108+ CarouselComponent ? .storeComponentSchema ( 'teaser' , teaserData ) ;
109109 }
110110 } else {
111111 // Try to get from stored schemas
112- teaserData = CarouselComponent . getStoredComponentSchema ( 'teaser' ) ;
112+ teaserData = CarouselComponent ? .getStoredComponentSchema ( 'teaser' ) ;
113113 if ( teaserData ) {
114114 console . log ( 'Reusing previously stored teaser schema' ) ;
115115 } else {
@@ -129,15 +129,15 @@ export class CarouselComponent extends ContentstackComponent {
129129 } else if ( componentType === 'image' ) {
130130
131131 let imageData = null ;
132- if ( currentComponent && ImageComponent . isImage ( currentComponent ) ) {
132+ if ( currentComponent && ImageComponent ? .isImage ( currentComponent ) ) {
133133 imageData = ImageComponent . mapImageToContentstack ( currentComponent , "image" ) ;
134134 if ( imageData ) {
135135 // Store for future reuse
136- CarouselComponent . storeComponentSchema ( 'image' , imageData ) ;
136+ CarouselComponent ? .storeComponentSchema ( 'image' , imageData ) ;
137137 }
138138 } else {
139139 // Try to get from stored schemas
140- imageData = CarouselComponent . getStoredComponentSchema ( 'image' ) ;
140+ imageData = CarouselComponent ? .getStoredComponentSchema ( 'image' ) ;
141141 if ( imageData ) {
142142 console . log ( 'Reusing previously stored image schema' ) ;
143143 }
@@ -155,13 +155,13 @@ export class CarouselComponent extends ContentstackComponent {
155155 } else if ( componentType === 'button' ) {
156156 let buttonData = null ;
157157
158- if ( currentComponent && ButtonComponent . isButton ( currentComponent ) ) {
158+ if ( currentComponent && ButtonComponent ? .isButton ( currentComponent ) ) {
159159 buttonData = ButtonComponent . mapButtonToContentstack ( currentComponent , "button" ) ;
160160 if ( buttonData ) {
161- CarouselComponent . storeComponentSchema ( 'button' , buttonData ) ;
161+ CarouselComponent ? .storeComponentSchema ( 'button' , buttonData ) ;
162162 }
163163 } else {
164- buttonData = CarouselComponent . getStoredComponentSchema ( 'button' ) ;
164+ buttonData = CarouselComponent ? .getStoredComponentSchema ( 'button' ) ;
165165 }
166166
167167 if ( buttonData ) {
@@ -176,13 +176,13 @@ export class CarouselComponent extends ContentstackComponent {
176176 } else if ( componentType === 'textbanner' || componentType === 'textBanner' ) {
177177 let textBannerData = null ;
178178
179- if ( currentComponent && TextBannerComponent . isTextBanner ( currentComponent ) ) {
180- textBannerData = TextBannerComponent . mapTextBannerToContentstack ( currentComponent , "textBanner" ) ;
179+ if ( currentComponent && TextBannerComponent ? .isTextBanner ( currentComponent ) ) {
180+ textBannerData = TextBannerComponent ? .mapTextBannerToContentstack ( currentComponent , "textBanner" ) ;
181181 if ( textBannerData ) {
182- CarouselComponent . storeComponentSchema ( 'textbanner' , textBannerData ) ;
182+ CarouselComponent ? .storeComponentSchema ( 'textbanner' , textBannerData ) ;
183183 }
184184 } else {
185- textBannerData = CarouselComponent . getStoredComponentSchema ( 'textbanner' ) ;
185+ textBannerData = CarouselComponent ? .getStoredComponentSchema ( 'textbanner' ) ;
186186 }
187187
188188 if ( textBannerData ) {
@@ -197,13 +197,13 @@ export class CarouselComponent extends ContentstackComponent {
197197 } else if ( componentType === 'text' ) {
198198 let textData = null ;
199199
200- if ( currentComponent && TextComponent . isText ( currentComponent ) ) {
201- textData = TextComponent . mapTextToContentstack ( currentComponent ) ;
200+ if ( currentComponent && TextComponent ? .isText ( currentComponent ) ) {
201+ textData = TextComponent ? .mapTextToContentstack ( currentComponent ) ;
202202 if ( textData ) {
203- CarouselComponent . storeComponentSchema ( 'text' , textData ) ;
203+ CarouselComponent ? .storeComponentSchema ( 'text' , textData ) ;
204204 }
205205 } else {
206- textData = CarouselComponent . getStoredComponentSchema ( 'text' ) ;
206+ textData = CarouselComponent ? .getStoredComponentSchema ( 'text' ) ;
207207 }
208208
209209 if ( textData ) {
@@ -214,13 +214,13 @@ export class CarouselComponent extends ContentstackComponent {
214214 } else if ( componentType === 'title' ) {
215215 let titleData = null ;
216216
217- if ( currentComponent && TitleComponent . isTitle ( currentComponent ) ) {
218- titleData = TitleComponent . mapTitleToContentstack ( currentComponent , "title" ) ;
217+ if ( currentComponent && TitleComponent ? .isTitle ( currentComponent ) ) {
218+ titleData = TitleComponent ? .mapTitleToContentstack ( currentComponent , "title" ) ;
219219 if ( titleData ) {
220- CarouselComponent . storeComponentSchema ( 'title' , titleData ) ;
220+ CarouselComponent ? .storeComponentSchema ( 'title' , titleData ) ;
221221 }
222222 } else {
223- titleData = CarouselComponent . getStoredComponentSchema ( 'title' ) ;
223+ titleData = CarouselComponent ? .getStoredComponentSchema ( 'title' ) ;
224224 }
225225
226226 if ( titleData ) {
@@ -231,13 +231,13 @@ export class CarouselComponent extends ContentstackComponent {
231231 } else if ( componentType === 'search' ) {
232232 let searchData = null ;
233233
234- if ( currentComponent && SearchComponent . isSearch ( currentComponent ) ) {
235- searchData = SearchComponent . mapSearchToContentstack ( currentComponent , "search" ) ;
234+ if ( currentComponent && SearchComponent ? .isSearch ( currentComponent ) ) {
235+ searchData = SearchComponent ? .mapSearchToContentstack ( currentComponent , "search" ) ;
236236 if ( searchData ) {
237- CarouselComponent . storeComponentSchema ( 'search' , searchData ) ;
237+ CarouselComponent ? .storeComponentSchema ( 'search' , searchData ) ;
238238 }
239239 } else {
240- searchData = CarouselComponent . getStoredComponentSchema ( 'search' ) ;
240+ searchData = CarouselComponent ? .getStoredComponentSchema ( 'search' ) ;
241241 }
242242
243243 if ( searchData ) {
@@ -248,13 +248,13 @@ export class CarouselComponent extends ContentstackComponent {
248248 } else if ( componentType === 'spacer' ) {
249249 let spacerData = null ;
250250
251- if ( currentComponent && SpacerComponent . isSpacer ( currentComponent ) ) {
252- spacerData = SpacerComponent . mapSpacerToContentstack ( currentComponent , "spacer" ) ;
251+ if ( currentComponent && SpacerComponent ? .isSpacer ( currentComponent ) ) {
252+ spacerData = SpacerComponent ? .mapSpacerToContentstack ( currentComponent , "spacer" ) ;
253253 if ( spacerData ) {
254- CarouselComponent . storeComponentSchema ( 'spacer' , spacerData ) ;
254+ CarouselComponent ? .storeComponentSchema ( 'spacer' , spacerData ) ;
255255 }
256256 } else {
257- spacerData = CarouselComponent . getStoredComponentSchema ( 'spacer' ) ;
257+ spacerData = CarouselComponent ? .getStoredComponentSchema ( 'spacer' ) ;
258258 }
259259
260260 if ( spacerData ) {
@@ -265,13 +265,13 @@ export class CarouselComponent extends ContentstackComponent {
265265 } else if ( componentType === 'separator' ) {
266266 let separatorData = null ;
267267
268- if ( currentComponent && SeparatorComponent . isSeparator ( currentComponent ) ) {
269- separatorData = SeparatorComponent . mapSeparatorToContentstack ( currentComponent , "separator" ) ;
268+ if ( currentComponent && SeparatorComponent ? .isSeparator ( currentComponent ) ) {
269+ separatorData = SeparatorComponent ? .mapSeparatorToContentstack ( currentComponent , "separator" ) ;
270270 if ( separatorData ) {
271- CarouselComponent . storeComponentSchema ( 'separator' , separatorData ) ;
271+ CarouselComponent ? .storeComponentSchema ?. ( 'separator' , separatorData ) ;
272272 }
273273 } else {
274- separatorData = CarouselComponent . getStoredComponentSchema ( 'separator' ) ;
274+ separatorData = CarouselComponent ? .getStoredComponentSchema ?. ( 'separator' ) ;
275275 }
276276
277277 if ( separatorData ) {
@@ -284,7 +284,7 @@ export class CarouselComponent extends ContentstackComponent {
284284 }
285285 }
286286 }
287- if ( schema . length === 0 ) {
287+ if ( schema ? .length === 0 ) {
288288 console . warn ( 'Carousel items schema is empty! No components were mapped.' ) ;
289289 }
290290
@@ -303,11 +303,11 @@ export class CarouselComponent extends ContentstackComponent {
303303 const componentSchema = component ?. convertedSchema ;
304304 if ( componentSchema ?. type === 'object' && componentSchema ?. properties ) {
305305 const fields : any [ ] = [ ] ;
306- for ( const [ key , value ] of Object . entries ( componentSchema . properties ) ) {
306+ for ( const [ key , value ] of Object . entries ( componentSchema ? .properties ) ) {
307307 if ( ! carouselExclude . includes ( key ) ) {
308308 const schemaProp = value as SchemaProperty ;
309- if ( schemaProp ?. type && CarouselComponent . fieldTypeMap [ schemaProp . type ] ) {
310- const mappedField = CarouselComponent . fieldTypeMap [ schemaProp . type ] ( key , schemaProp ) ;
309+ if ( schemaProp ?. type && CarouselComponent ? .fieldTypeMap ?. [ schemaProp ? .type ] ) {
310+ const mappedField = CarouselComponent ? .fieldTypeMap ?. [ schemaProp ? .type ] ( key , schemaProp ) ;
311311 if ( mappedField ) {
312312 fields . push ( mappedField ) ;
313313 }
0 commit comments