@open-tender/ui
Version:
A component library for use with the Open Tender web app
15 lines (14 loc) • 852 B
JavaScript
import React from 'react';
import { makeProps } from '../utils';
import Text from './Text';
import View from './View';
const Label = ({ config, children, label, isRequired, hasValue, style }) => {
const props = makeProps(config, 'label', style);
const missingInput = isRequired && !hasValue && hasValue !== undefined;
return (React.createElement("label", Object.assign({}, props),
label && (React.createElement(View, Object.assign({ as: "span" }, makeProps(config, 'label__label')),
React.createElement(Text, Object.assign({}, makeProps(config, missingInput ? 'label__text' : 'label__textMissing'), { text: label })),
isRequired ? (React.createElement(Text, Object.assign({}, makeProps(config, 'label__required'), { text: label ? '' : '(required)' }))) : null)),
children));
};
export default Label;