UNPKG

@progress/sitefinity-nextjs-sdk

Version:

Provides OOB widgets developed using the Next.js framework, which includes an abstraction layer for Sitefinity communication. Additionally, it offers an expanded API, typings, and tools for further development and integration.

66 lines (65 loc) 2.87 kB
'use client'; import { jsx as _jsx } from "react/jsx-runtime"; import { SectionType } from './section-type'; import { RenderView } from '../../common/render-view'; import { IntentDrivenContentDefaultView } from './intent-driven-content-default.view'; import { getMinimumWidgetContext } from '../../../editor/widget-framework/widget-context'; import { htmlAttributes } from '../../../editor/widget-framework/attributes'; export function IntentDrivenContent(props) { const attr = htmlAttributes(props); const model = props.model.Properties; const sections = model.SectionsConfiguration || [{ sectionType: SectionType.TitleAndSummary }]; const query = model.DefaultQuery; const noIntentAction = model.NoProvidedIntent; const siteId = props.requestContext.layout.SiteId; const pageId = props.requestContext.layout.Id; const language = props.requestContext.culture; const cssClasses = { Content: model.ContentCssClass, PageTitleAndSummary: model.PageTitleAndSummaryCssClass, SectionTitleAndSummary: model.SectionTitleAndSummaryCssClass, RichText: model.RichTextCssClass, ContentItemsList: model.ContentItemsListCssClass, ContentItemsCards: model.ContentItemsCardsCssClass, Hero: model.HeroCssClass, Faq: model.FaqCssClass }; attr['className'] = cssClasses?.Content || ''; const viewProps = { attributes: attr, defaultQuery: query, widgetContext: getMinimumWidgetContext(props), noIntentAction: noIntentAction, siteId: siteId, pageId: pageId, language: language, sections: sections, isEdit: props.requestContext.isEdit }; sections.forEach(section => { switch (section.sectionType) { case SectionType.TitleAndSummary: section.cssClassName = cssClasses?.PageTitleAndSummary || ''; break; case SectionType.RichText: section.cssClassName = cssClasses?.RichText || ''; break; case SectionType.FAQ: section.cssClassName = cssClasses?.Faq || ''; break; case SectionType.Hero: section.cssClassName = cssClasses?.Hero || ''; break; case SectionType.ContentList: section.cssClassName = cssClasses?.ContentItemsList || ''; break; case SectionType.ContentListCards: section.cssClassName = cssClasses?.ContentItemsCards || ''; break; default: section.cssClassName = ''; break; } }); return (_jsx(RenderView, { viewProps: viewProps, widgetKey: props.model.Name, viewName: model.SfViewName, children: _jsx(IntentDrivenContentDefaultView, { ...viewProps }) })); }