@the-control-group/ui
Advanced tools
Comparing version
@@ -60,2 +60,3 @@ /** | ||
'disabled', | ||
'checked', | ||
'type', | ||
@@ -62,0 +63,0 @@ 'placeholder', |
@@ -28,2 +28,5 @@ /** | ||
bare, | ||
name, | ||
id, | ||
checked, | ||
...other | ||
@@ -62,2 +65,24 @@ }) => { | ||
if(type === 'radio' || type === 'checkbox') { | ||
return ( | ||
<Fragment> | ||
<Common | ||
{...other} | ||
classes={combinedClasses} | ||
tag="input" | ||
type={type} | ||
name={name} | ||
label={label} | ||
id={id} | ||
checked={checked} | ||
/> | ||
{label && | ||
<label htmlFor={id}> | ||
{label} | ||
</label> | ||
} | ||
</Fragment> | ||
); | ||
} | ||
return ( | ||
@@ -88,8 +113,4 @@ <Fragment> | ||
type: PropTypes.string, | ||
/** Text label for input */ | ||
label: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.object | ||
]), | ||
bare: PropTypes.bool, | ||
name: PropTypes.string.isRequired, | ||
/** Placeholder for input */ | ||
@@ -104,2 +125,23 @@ placeholder: PropTypes.string, | ||
} | ||
}, | ||
label: (props, propName) => { | ||
if ((props.type === 'radio' || props.type === 'checkbox') && (props[propName] === undefined)) { | ||
return new Error( | ||
'Label is required for radio and checkbox inputs' | ||
); | ||
} | ||
}, | ||
id: (props, propName) => { | ||
if ((props.type === 'radio' || props.type === 'checkbox') && (props[propName] === undefined)) { | ||
return new Error( | ||
'Id attribute is required for radio and checkbox inputs' | ||
); | ||
} | ||
}, | ||
checked: (props, propName) => { | ||
if ((props.type === 'radio' || props.type === 'checkbox') && (props[propName] === undefined)) { | ||
return new Error( | ||
'Checked attribute is required for radio and checkbox inputs' | ||
); | ||
} | ||
} | ||
@@ -106,0 +148,0 @@ }; |
{ | ||
"name": "@the-control-group/ui", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "UI kit based on ReactJS for TCG projects", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
56910
6.34%1176
3.7%