( state: JsonFormsState, ownProps: OwnPropsOfLayout )
| 1055 | * @returns {StatePropsOfLayout} |
| 1056 | */ |
| 1057 | export const mapStateToLayoutProps = ( |
| 1058 | state: JsonFormsState, |
| 1059 | ownProps: OwnPropsOfLayout |
| 1060 | ): LayoutProps => { |
| 1061 | const rootData = getData(state); |
| 1062 | const { uischema } = ownProps; |
| 1063 | const visible: boolean = |
| 1064 | ownProps.visible === undefined || hasShowRule(uischema) |
| 1065 | ? isVisible( |
| 1066 | ownProps.uischema, |
| 1067 | rootData, |
| 1068 | ownProps.path, |
| 1069 | getAjv(state), |
| 1070 | getConfig(state) |
| 1071 | ) |
| 1072 | : ownProps.visible; |
| 1073 | |
| 1074 | const data = Resolve.data(rootData, ownProps.path); |
| 1075 | const config = getConfig(state); |
| 1076 | const enabled: boolean = isInherentlyEnabled( |
| 1077 | state, |
| 1078 | ownProps, |
| 1079 | uischema, |
| 1080 | undefined, // layouts have no associated schema |
| 1081 | rootData, |
| 1082 | config |
| 1083 | ); |
| 1084 | const readonly: boolean = isInherentlyReadonly( |
| 1085 | state, |
| 1086 | ownProps, |
| 1087 | uischema, |
| 1088 | undefined, // layouts have no associated schema |
| 1089 | rootData, |
| 1090 | config |
| 1091 | ); |
| 1092 | |
| 1093 | // some layouts have labels which might need to be translated |
| 1094 | const t = getTranslator()(state); |
| 1095 | const label = isLabelable(uischema) |
| 1096 | ? deriveLabelForUISchemaElement(uischema, t) |
| 1097 | : undefined; |
| 1098 | |
| 1099 | return { |
| 1100 | ...layoutDefaultProps, |
| 1101 | renderers: ownProps.renderers || getRenderers(state), |
| 1102 | cells: ownProps.cells || getCells(state), |
| 1103 | visible, |
| 1104 | enabled, |
| 1105 | readonly, |
| 1106 | path: ownProps.path, |
| 1107 | data, |
| 1108 | uischema: ownProps.uischema, |
| 1109 | schema: ownProps.schema, |
| 1110 | direction: ownProps.direction ?? getDirection(uischema), |
| 1111 | config, |
| 1112 | label, |
| 1113 | }; |
| 1114 | }; |
no test coverage detected
searching dependent graphs…