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

Function oneOfToEnumOptionMapper

packages/core/src/mappers/renderer.ts:341–363  ·  view source on GitHub ↗
(
  e: any,
  t?: Translator,
  fallbackI18nKey?: string
)

Source from the content-addressed store, hash-verified

339};
340
341export const oneOfToEnumOptionMapper = (
342 e: any,
343 t?: Translator,
344 fallbackI18nKey?: string
345): EnumOption => {
346 let label =
347 e.title ??
348 (typeof e.const === 'string' ? e.const : JSON.stringify(e.const));
349 if (t) {
350 // prefer schema keys as they can be more specialized
351 if (e.i18n) {
352 label = t(e.i18n, label, { schema: e });
353 } else if (fallbackI18nKey) {
354 label = t(`${fallbackI18nKey}.${label}`, label, { schema: e });
355 } else {
356 label = t(label, label, { schema: e });
357 }
358 }
359 return {
360 label,
361 value: e.const,
362 };
363};
364
365export interface OwnPropsOfRenderer {
366 /**

Callers 5

cell.test.tsFile · 0.90
computeChildLabelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…