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

Function mapStateToArrayLayoutProps

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

Source from the content-addressed store, hash-verified

1260 * @returns {StatePropsOfArrayControl} state props for a table control
1261 */
1262export 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.

Callers 3

ctxToArrayLayoutPropsFunction · 0.90
renderer.test.tsFile · 0.90
mapToPropsMethod · 0.90

Calls 5

getTranslatorFunction · 0.90
getCombinedErrorMessageFunction · 0.90
getSubErrorsAtFunction · 0.90
getErrorTranslatorFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…