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.

32 lines (31 loc) 1.63 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { htmlAttributes } from '../../../editor/widget-framework/attributes'; import { getMinimumWidgetContext } from '../../../editor/widget-framework/widget-context'; import { Tracer } from '@progress/sitefinity-nextjs-sdk/diagnostics/empty'; import { RenderView } from '../../common/render-view'; import { DropdownDefaultView } from './dropdown.view'; import { classNames } from '../../../editor/utils/classNames'; import { StylingConfig } from '../../styling/styling-config'; export function Dropdown(props) { const { span } = Tracer.traceWidget(props, false); const entity = props.model.Properties; let choices = entity.Choices || []; if (entity.Sorting === 'Alphabetical') { choices = choices.sort((a, b) => a.Name.localeCompare(b.Name)); } const cssClass = entity.CssClass || ''; const viewProps = { choices: choices, cssClass: classNames(cssClass, StylingConfig.FieldSizeClasses[('Width' + entity.FieldSize)]) || '', instructionalText: entity.InstructionalText, label: entity.Label || '', required: entity.Required, requiredErrorMessage: entity.RequiredErrorMessage || '', sorting: entity.Sorting, sfFieldName: entity.SfFieldName, fieldSize: entity.FieldSize, attributes: { ...htmlAttributes(props) }, widgetContext: getMinimumWidgetContext(props) }; return (_jsx(RenderView, { viewName: entity.SfViewName, widgetKey: props.model.Name, traceSpan: span, viewProps: viewProps, children: _jsx(DropdownDefaultView, { ...viewProps }) })); }