Skip to content

Commit 77b8143

Browse files
author
Rachel Killackey
authored
Merge pull request #109 from LaunchPadLab/omit-label-props
Add `omitLabelProps` helper
2 parents f477613 + 0dc68b8 commit 77b8143

File tree

13 files changed

+36
-21
lines changed

13 files changed

+36
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@launchpadlab/lp-components",
3-
"version": "1.18.3",
3+
"version": "1.18.4",
44
"description": "Our Components",
55
"main": "lib/index.js",
66
"repository": "launchpadlab/lp-components",

src/forms/helpers/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ export {
33
default as fieldPropTypes,
44
fieldPropTypesWithValue,
55
fieldOptionsType
6-
} from './field-proptypes'
6+
} from './field-proptypes'
7+
export { default as omitLabelProps } from './omit-label-props'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { omit } from '../../utils'
2+
3+
// A function that omits the `InputLabel` props from form component props
4+
5+
function omitLabelProps (props) {
6+
return omit([
7+
'hint',
8+
'tooltip',
9+
'label'
10+
], props)
11+
}
12+
13+
export default omitLabelProps

src/forms/inputs/checkbox-group.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
33
import Checkbox from './checkbox'
4-
import { fieldPropTypesWithValue, fieldOptionsType } from '../helpers'
4+
import { fieldPropTypesWithValue, fieldOptionsType, omitLabelProps } from '../helpers'
55
import { LabeledField } from '../labels'
66
import { addToArray, removeFromArray, objectify } from '../../utils'
77

@@ -79,7 +79,7 @@ function CheckboxGroup (props) {
7979
meta, // eslint-disable-line no-unused-vars
8080
options,
8181
...rest
82-
} = props
82+
} = omitLabelProps(props)
8383
const optionObjects = objectify(options)
8484
// Build change handler
8585
const handleChange = function (option) {

src/forms/inputs/checkbox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import { blurDirty, fieldPropTypesWithValue } from '../helpers'
3+
import { blurDirty, fieldPropTypesWithValue, omitLabelProps } from '../helpers'
44
import { LabeledField } from '../labels'
55
import { compose } from '../../utils'
66

@@ -51,7 +51,7 @@ function Checkbox (props) {
5151
input: { name, value, onBlur, onChange },
5252
meta, // eslint-disable-line no-unused-vars
5353
...rest
54-
} = props
54+
} = omitLabelProps(props)
5555
return (
5656
<LabeledField className="checkbox" { ...props }>
5757
<input {...{

src/forms/inputs/date-input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import DatePicker from 'react-datepicker'
44
import moment from 'moment'
5-
import { blurDirty, fieldPropTypesWithValue } from '../helpers'
5+
import { blurDirty, fieldPropTypesWithValue, omitLabelProps } from '../helpers'
66
import { LabeledField } from '../labels'
77
import { compose } from '../../utils'
88

@@ -58,7 +58,7 @@ function DateInput (props) {
5858
meta, // eslint-disable-line no-unused-vars,
5959
className, // eslint-disable-line no-unused-vars
6060
...rest
61-
} = props
61+
} = omitLabelProps(props)
6262
const momentValue = value ? moment(value) : null
6363
return (
6464
<LabeledField { ...props }>

src/forms/inputs/file-input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
33
import { Button } from '../buttons'
4-
import { fieldPropTypes } from '../helpers'
4+
import { fieldPropTypes, omitLabelProps } from '../helpers'
55
import { LabeledField } from '../labels'
66

77
class FileInput extends React.Component {
@@ -43,7 +43,7 @@ class FileInput extends React.Component {
4343
hidePreview,
4444
thumbnail,
4545
...rest
46-
} = this.props
46+
} = omitLabelProps(this.props)
4747

4848
return (
4949
<LabeledField { ...this.props }>

src/forms/inputs/icon-input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import { blurDirty, fieldPropTypes } from '../helpers'
3+
import { blurDirty, fieldPropTypes, omitLabelProps } from '../helpers'
44
import { LabeledField } from '../labels'
55
import { compose } from '../../utils'
66

@@ -22,7 +22,7 @@ function IconInput (props) {
2222
type,
2323
icon,
2424
...rest
25-
} = props
25+
} = omitLabelProps(props)
2626
return (
2727
<LabeledField { ...props }>
2828
<div className="icon-label">

src/forms/inputs/input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import { blurDirty, fieldPropTypes } from '../helpers'
3+
import { blurDirty, fieldPropTypes, omitLabelProps } from '../helpers'
44
import { LabeledField } from '../labels'
55
import { compose } from '../../utils'
66

@@ -20,7 +20,7 @@ function Input (props) {
2020
className, // eslint-disable-line no-unused-vars
2121
type,
2222
...rest
23-
} = props
23+
} = omitLabelProps(props)
2424
return (
2525
<LabeledField { ...props }>
2626
<div className="input-wrapper">

src/forms/inputs/range-input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import { blurDirty, fieldPropTypes } from '../helpers'
3+
import { blurDirty, fieldPropTypes, omitLabelProps } from '../helpers'
44
import { LabeledField } from '../labels'
55
import { compose } from '../../utils'
66

@@ -29,7 +29,7 @@ function RangeInput (props) {
2929
step,
3030
hideLabel,
3131
...rest
32-
} = props
32+
} = omitLabelProps(props)
3333
return (
3434
<LabeledField { ...props }>
3535
<div>

0 commit comments

Comments
 (0)