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

Function mapStateToControlProps

packages/core/src/mappers/renderer.ts:588–678  ·  view source on GitHub ↗
(
  state: JsonFormsState,
  ownProps: OwnPropsOfControl
)

Source from the content-addressed store, hash-verified

586 * @returns {StatePropsOfControl} state props for a control
587 */
588export const mapStateToControlProps = (
589 state: JsonFormsState,
590 ownProps: OwnPropsOfControl
591): StatePropsOfControl => {
592 const { uischema } = ownProps;
593 const rootData = getData(state);
594 const path = composeWithUi(uischema, ownProps.path);
595 const config = getConfig(state);
596
597 const visible: boolean =
598 ownProps.visible === undefined || hasShowRule(uischema)
599 ? isVisible(uischema, rootData, ownProps.path, getAjv(state), config)
600 : ownProps.visible;
601 const controlElement = uischema as ControlElement;
602 const id = ownProps.id;
603 const rootSchema = getSchema(state);
604 const required =
605 controlElement.scope !== undefined &&
606 isRequired(ownProps.schema, controlElement.scope, rootSchema);
607 const resolvedSchema = Resolve.schema(
608 ownProps.schema || rootSchema,
609 controlElement.scope,
610 rootSchema
611 );
612 const errors = getErrorAt(path, resolvedSchema)(state);
613
614 const description =
615 resolvedSchema !== undefined ? resolvedSchema.description : '';
616 const data = Resolve.data(rootData, path);
617 const labelDesc = createLabelDescriptionFrom(uischema, resolvedSchema);
618 const label = labelDesc.show ? labelDesc.text : '';
619 const enabled: boolean = isInherentlyEnabled(
620 state,
621 ownProps,
622 uischema,
623 resolvedSchema || rootSchema,
624 rootData,
625 config
626 );
627 const readonly: boolean = isInherentlyReadonly(
628 state,
629 ownProps,
630 uischema,
631 resolvedSchema || rootSchema,
632 rootData,
633 config
634 );
635
636 const schema = resolvedSchema ?? rootSchema;
637 const t = getTranslator()(state);
638 const te = getErrorTranslator()(state);
639 const i18nKeyPrefix = getI18nKeyPrefix(schema, uischema, path);
640 const i18nLabel = t(getI18nKey(schema, uischema, path, 'label'), label, {
641 schema,
642 uischema,
643 path,
644 errors,
645 });

Callers 8

ctxToControlPropsFunction · 0.90
mapToPropsMethod · 0.90
renderer.test.tsFile · 0.90

Calls 15

getDataFunction · 0.90
composeWithUiFunction · 0.90
getConfigFunction · 0.90
hasShowRuleFunction · 0.90
isVisibleFunction · 0.90
getAjvFunction · 0.90
getSchemaFunction · 0.90
getErrorAtFunction · 0.90
isInherentlyEnabledFunction · 0.90
isInherentlyReadonlyFunction · 0.90
getTranslatorFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…