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

Function createLabelDescriptionFrom

packages/core/src/util/label.ts:57–78  ·  view source on GitHub ↗
(
  withLabel: ControlElement,
  schema?: JsonSchema
)

Source from the content-addressed store, hash-verified

55 * @returns {LabelDescription}
56 */
57export const createLabelDescriptionFrom = (
58 withLabel: ControlElement,
59 schema?: JsonSchema
60): LabelDescription => {
61 const labelProperty = withLabel.label;
62 if (typeof labelProperty === 'boolean') {
63 return labelDescription(deriveLabel(withLabel, schema), labelProperty);
64 }
65 if (typeof labelProperty === 'string') {
66 return labelDescription(labelProperty, true);
67 }
68 if (typeof labelProperty === 'object') {
69 const label =
70 typeof labelProperty.text === 'string'
71 ? labelProperty.text
72 : deriveLabel(withLabel, schema);
73 const show =
74 typeof labelProperty.show === 'boolean' ? labelProperty.show : true;
75 return labelDescription(label, show);
76 }
77 return labelDescription(deriveLabel(withLabel, schema), true);
78};
79
80const labelDescription = (text: string, show: boolean): LabelDescription => ({
81 text: text,

Callers 2

label.test.tsFile · 0.90
mapStateToControlPropsFunction · 0.90

Calls 2

labelDescriptionFunction · 0.85
deriveLabelFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…