( state: JsonFormsState, ownProps: OwnPropsOfControl )
| 1260 | * @returns {StatePropsOfArrayControl} state props for a table control |
| 1261 | */ |
| 1262 | export const mapStateToArrayLayoutProps = ( |
| 1263 | state: JsonFormsState, |
| 1264 | ownProps: OwnPropsOfControl |
| 1265 | ): StatePropsOfArrayLayout => { |
| 1266 | const { path, schema, uischema, errors, label, ...props } = |
| 1267 | mapStateToControlWithDetailProps(state, ownProps); |
| 1268 | |
| 1269 | const resolvedSchema = Resolve.schema(schema, 'items', props.rootSchema); |
| 1270 | const t = getTranslator()(state); |
| 1271 | // TODO Does not consider 'i18n' keys which are specified in the ui schemas of the sub errors |
| 1272 | const childErrors = getCombinedErrorMessage( |
| 1273 | getSubErrorsAt(path, resolvedSchema)(state), |
| 1274 | getErrorTranslator()(state), |
| 1275 | t, |
| 1276 | undefined, |
| 1277 | undefined, |
| 1278 | undefined |
| 1279 | ); |
| 1280 | |
| 1281 | const allErrors = |
| 1282 | errors + |
| 1283 | (errors.length > 0 && childErrors.length > 0 ? '\n' : '') + |
| 1284 | childErrors; |
| 1285 | return { |
| 1286 | ...props, |
| 1287 | label, |
| 1288 | path, |
| 1289 | uischema, |
| 1290 | schema: resolvedSchema, |
| 1291 | arraySchema: schema, |
| 1292 | data: props.data ? props.data.length : 0, |
| 1293 | errors: allErrors, |
| 1294 | minItems: schema.minItems, |
| 1295 | }; |
| 1296 | }; |
| 1297 | |
| 1298 | /** |
| 1299 | * Props of an array control. |
no test coverage detected
searching dependent graphs…