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

Function mapStateToEnumControlProps

packages/core/src/mappers/renderer.ts:701–726  ·  view source on GitHub ↗
(
  state: JsonFormsState,
  ownProps: OwnPropsOfControl & OwnPropsOfEnum
)

Source from the content-addressed store, hash-verified

699 * @returns {StatePropsOfControl & OwnPropsOfEnum}
700 */
701export const mapStateToEnumControlProps = (
702 state: JsonFormsState,
703 ownProps: OwnPropsOfControl & OwnPropsOfEnum
704): StatePropsOfControl & OwnPropsOfEnum => {
705 const props: StatePropsOfControl = mapStateToControlProps(state, ownProps);
706 const options: EnumOption[] =
707 ownProps.options ||
708 props.schema.enum?.map((e) =>
709 enumToEnumOptionMapper(
710 e,
711 getTranslator()(state),
712 getI18nKeyPrefix(props.schema, props.uischema, props.path)
713 )
714 ) ||
715 (props.schema.const && [
716 enumToEnumOptionMapper(
717 props.schema.const,
718 getTranslator()(state),
719 getI18nKeyPrefix(props.schema, props.uischema, props.path)
720 ),
721 ]);
722 return {
723 ...props,
724 options,
725 };
726};
727
728/**
729 * Default mapStateToCellProps for enum control based on oneOf. Options is used for populating dropdown list

Callers 3

ctxToEnumControlPropsFunction · 0.90
renderer.test.tsFile · 0.90
mapToPropsMethod · 0.90

Calls 4

getTranslatorFunction · 0.90
getI18nKeyPrefixFunction · 0.90
mapStateToControlPropsFunction · 0.85
enumToEnumOptionMapperFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…