@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.
34 lines (33 loc) • 2.51 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { StyleGenerator } from '../styling/style-generator.service';
import { Horizontal } from './horizontal';
import { Accordion } from './accordion';
import { Vertical } from './vertical';
import { Tabs } from './tabs';
import { RestClient } from '../../rest-sdk/rest-client';
import { combineClassNames } from '../../editor/utils/classNames';
import { htmlAttributes, getCustomAttributes } from '../../editor/widget-framework/attributes';
import { getMinimumWidgetContext } from '../../editor/widget-framework/widget-context';
import { RenderView } from '../common/render-view';
import { Tracer } from '@progress/sitefinity-nextjs-sdk/diagnostics/empty';
export async function Navigation(props) {
const { span, ctx } = Tracer.traceWidget(props, true);
const entity = props.model.Properties;
const dataAttributes = htmlAttributes(props);
const navItems = await RestClient.getNavigation({
currentPage: props.requestContext.layout.Id,
levelsToInclude: entity.LevelsToInclude,
selectedPageId: entity.SelectedPage && entity.SelectedPage.ItemIdsOrdered && entity.SelectedPage.ItemIdsOrdered.length > 0 ? entity.SelectedPage.ItemIdsOrdered[0] : undefined,
selectedPages: entity.CustomSelectedPages && entity.CustomSelectedPages.ItemIdsOrdered && entity.CustomSelectedPages.ItemIdsOrdered.length > 0 ? entity.CustomSelectedPages.ItemIdsOrdered : undefined,
selectionMode: entity.SelectionMode,
showParentPage: entity.ShowParentPage,
culture: props.requestContext.culture,
traceContext: ctx
}) || [];
const marginClass = entity.Margins && StyleGenerator.getMarginClasses(entity.Margins);
const customAttributes = getCustomAttributes(entity.Attributes, 'SitefinityNavigation');
dataAttributes['className'] = combineClassNames(marginClass, entity.WrapperCssClass);
const viewName = props.model.Properties.SfViewName;
const viewProps = { navCustomAttributes: customAttributes, items: navItems, attributes: dataAttributes, widgetContext: getMinimumWidgetContext(props) };
return (_jsxs(RenderView, { viewName: viewName, widgetKey: props.model.Name, traceSpan: span, viewProps: viewProps, children: [viewName === 'Accordion' && _jsx(Accordion, { ...viewProps }), viewName === 'Horizontal' && _jsx(Horizontal, { ...viewProps }), viewName === 'Tabs' && _jsx(Tabs, { ...viewProps }), viewName === 'Vertical' && _jsx(Vertical, { ...viewProps })] }));
}