MCPcopy Create free account
hub / github.com/eclipsesource/jsonforms / defaultMapStateToEnumCellProps

Function defaultMapStateToEnumCellProps

packages/core/src/mappers/cell.ts:218–243  ·  view source on GitHub ↗
(
  state: JsonFormsState,
  ownProps: OwnPropsOfEnumCell
)

Source from the content-addressed store, hash-verified

216 * @returns {StatePropsOfEnumCell}
217 */
218export const defaultMapStateToEnumCellProps = (
219 state: JsonFormsState,
220 ownProps: OwnPropsOfEnumCell
221): StatePropsOfEnumCell => {
222 const props: StatePropsOfCell = mapStateToCellProps(state, ownProps);
223 const options: EnumOption[] =
224 ownProps.options ||
225 props.schema.enum?.map((e) =>
226 enumToEnumOptionMapper(
227 e,
228 getTranslator()(state),
229 getI18nKeyPrefix(props.schema, props.uischema, props.path)
230 )
231 ) ||
232 (props.schema.const && [
233 enumToEnumOptionMapper(
234 props.schema.const,
235 getTranslator()(state),
236 getI18nKeyPrefix(props.schema, props.uischema, props.path)
237 ),
238 ]);
239 return {
240 ...props,
241 options,
242 };
243};
244
245/**
246 * mapStateToOneOfEnumCellProps for one of enum cell. Options is used for populating dropdown list from oneOf

Callers 2

ctxToEnumCellPropsFunction · 0.90
cell.test.tsFile · 0.90

Calls 4

enumToEnumOptionMapperFunction · 0.90
getTranslatorFunction · 0.90
getI18nKeyPrefixFunction · 0.90
mapStateToCellPropsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…