Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Ref): implement innerRef on all components #1879

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5dfc617
feat(Ref): add component
layershifter Jul 20, 2017
48c6b57
feat(Ref): add component
Jul 27, 2017
c7ebfe4
style(mixed): fix lint issues
Aug 31, 2017
1f7ef3e
fix(mixed): fix broken tests
Aug 31, 2017
a1bad06
fix(shallow): fix shallow test util
Aug 31, 2017
d464514
fix(Menu): fix broken test, remove cruft
Sep 1, 2017
b296008
fix(getElementType): fix broken test
Sep 1, 2017
d1576a4
fix(Accordion): fix broken test
Sep 1, 2017
51e5cce
fix(Checkbox|Embed|Transition): fix broken tests
Sep 1, 2017
8da1e3b
feat(getElementType): add original
Sep 11, 2017
c6129f3
revert(mixed): remove rawShallow
Sep 11, 2017
749f654
Merge branch 'master' of https://github.com/Semantic-Org/Semantic-UI-…
Sep 25, 2017
d25c2d4
fix(Transition): fix component wrapping inside Transition.Group
Sep 27, 2017
841c876
Merge branch 'master' of https://github.com/Semantic-Org/Semantic-UI-…
Sep 28, 2017
c47c784
Merge branch 'fix/transition-group' of https://github.com/Semantic-Or…
Sep 28, 2017
20f1dcf
wip
Sep 28, 2017
8ccf696
Merge branches 'feat/ref' and 'master' of https://github.com/Semantic…
Oct 2, 2017
d09f519
test(mixed): remove useless content tests
Oct 2, 2017
df2f197
wip
Oct 2, 2017
3bfbadb
merge with master
layershifter Oct 18, 2017
807cdcd
Merge branch 'master' of https://github.com/Semantic-Org/Semantic-UI-…
layershifter Nov 5, 2017
7f7b8ad
Merge branches 'feat/ref' and 'master' of https://github.com/Semantic…
layershifter Nov 5, 2017
c1a840d
fix(Image): make Image stateless again
layershifter Nov 5, 2017
20bbbfa
test(common): restore tests
layershifter Nov 5, 2017
9fcdf3c
feat(innerRef): use ElementType as child
layershifter Nov 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/addons/Radio/Radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Checkbox from '../../modules/Checkbox'
function Radio(props) {
const { slider, toggle, type } = props
const rest = getUnhandledProps(Radio, props)
// const ElementType = getElementType(Radio, props)
// radio, slider, toggle are exclusive
// use an undefined radio if slider or toggle are present
const radio = !(slider || toggle) || undefined
Expand Down
4 changes: 1 addition & 3 deletions src/addons/Responsive/Responsive.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React, { Component } from 'react'

import {
customPropTypes,
ElementType,
eventStack,
getElementType,
getUnhandledProps,
isBrowser,
META,
Expand Down Expand Up @@ -119,8 +119,6 @@ export default class Responsive extends Component {

render() {
const { children } = this.props

const ElementType = getElementType(Responsive, this.props)
const rest = getUnhandledProps(Responsive, this.props)

if (this.isVisible()) return <ElementType {...rest}>{children}</ElementType>
Expand Down
6 changes: 2 additions & 4 deletions src/addons/TextArea/TextArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { Component } from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
} from '../../lib'
Expand Down Expand Up @@ -123,16 +123,14 @@ class TextArea extends Component {
render() {
const { autoHeight, rows, style, value } = this.props
const rest = getUnhandledProps(TextArea, this.props)
const ElementType = getElementType(TextArea, this.props)

const resize = autoHeight ? 'none' : ''

return (
<ElementType
{...rest}
innerRef={this.handleRef}
onChange={this.handleChange}
onInput={this.handleInput}
ref={this.handleRef}
rows={rows}
style={{ resize, ...style }}
value={value}
Expand Down
5 changes: 2 additions & 3 deletions src/behaviors/Visibility/Visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, { Component } from 'react'
import {
eventStack,
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
normalizeOffset,
Expand Down Expand Up @@ -371,9 +371,8 @@ export default class Visibility extends Component {

render() {
const { children } = this.props
const ElementType = getElementType(Visibility, this.props)
const rest = getUnhandledProps(Visibility, this.props)

return <ElementType {...rest} ref={this.handleRef}>{children}</ElementType>
return <ElementType {...rest} innerRef={this.handleRef}>{children}</ElementType>
}
}
3 changes: 1 addition & 2 deletions src/collections/Breadcrumb/Breadcrumb.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import React from 'react'
import {
childrenUtils,
customPropTypes,
ElementType,
getUnhandledProps,
getElementType,
META,
SUI,
} from '../../lib'
Expand All @@ -34,7 +34,6 @@ function Breadcrumb(props) {
className,
)
const rest = getUnhandledProps(Breadcrumb, props)
const ElementType = getElementType(Breadcrumb, props)

if (!childrenUtils.isNil(children)) return <ElementType {...rest} className={classes}>{children}</ElementType>

Expand Down
3 changes: 1 addition & 2 deletions src/collections/Breadcrumb/BreadcrumbDivider.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
childrenUtils,
createShorthandFactory,
customPropTypes,
ElementType,
getUnhandledProps,
getElementType,
META,
} from '../../lib'
import Icon from '../../elements/Icon'
Expand All @@ -26,7 +26,6 @@ function BreadcrumbDivider(props) {

const classes = cx('divider', className)
const rest = getUnhandledProps(BreadcrumbDivider, props)
const ElementType = getElementType(BreadcrumbDivider, props)

if (!_.isNil(icon)) return Icon.create(icon, { defaultProps: { ...rest, className: classes } })
if (!_.isNil(content)) return <ElementType {...rest} className={classes}>{content}</ElementType>
Expand Down
7 changes: 3 additions & 4 deletions src/collections/Breadcrumb/BreadcrumbSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
childrenUtils,
createShorthandFactory,
customPropTypes,
ElementType,
getUnhandledProps,
getElementType,
META,
useKeyOnly,
} from '../../lib'
Expand Down Expand Up @@ -61,7 +61,7 @@ export default class BreadcrumbSection extends Component {
parent: 'Breadcrumb',
}

computeElementType = () => {
computeType = () => {
const { link, onClick } = this.props

if (link || onClick) return 'a'
Expand All @@ -84,10 +84,9 @@ export default class BreadcrumbSection extends Component {
className,
)
const rest = getUnhandledProps(BreadcrumbSection, this.props)
const ElementType = getElementType(BreadcrumbSection, this.props, this.computeElementType)

return (
<ElementType {...rest} className={classes} href={href} onClick={this.handleClick}>
<ElementType {...rest} className={classes} computeType={this.computeType} href={href} onClick={this.handleClick}>
{childrenUtils.isNil(children) ? content : children}
</ElementType>
)
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Form/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, { Component } from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
SUI,
Expand Down Expand Up @@ -137,7 +137,6 @@ class Form extends Component {
className,
)
const rest = getUnhandledProps(Form, this.props)
const ElementType = getElementType(Form, this.props)

return (
<ElementType
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Form/FormButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
} from '../../lib'
Expand All @@ -17,7 +17,6 @@ import FormField from './FormField'
function FormButton(props) {
const { control } = props
const rest = getUnhandledProps(FormButton, props)
const ElementType = getElementType(FormButton, props)

return <ElementType {...rest} control={control} />
}
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Form/FormCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
} from '../../lib'
Expand All @@ -17,7 +17,6 @@ import FormField from './FormField'
function FormCheckbox(props) {
const { control } = props
const rest = getUnhandledProps(FormCheckbox, props)
const ElementType = getElementType(FormCheckbox, props)

return <ElementType {...rest} control={control} />
}
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Form/FormDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
} from '../../lib'
Expand All @@ -17,7 +17,6 @@ import FormField from './FormField'
function FormDropdown(props) {
const { control } = props
const rest = getUnhandledProps(FormDropdown, props)
const ElementType = getElementType(FormDropdown, props)

return <ElementType {...rest} control={control} />
}
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Form/FormField.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
childrenUtils,
createHTMLLabel,
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
SUI,
Expand Down Expand Up @@ -53,7 +53,6 @@ function FormField(props) {
className,
)
const rest = getUnhandledProps(FormField, props)
const ElementType = getElementType(FormField, props)

// ----------------------------------------
// No Control
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Form/FormGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
SUI,
Expand Down Expand Up @@ -35,7 +35,6 @@ function FormGroup(props) {
className,
)
const rest = getUnhandledProps(FormGroup, props)
const ElementType = getElementType(FormGroup, props)

return <ElementType {...rest} className={classes}>{children}</ElementType>
}
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Form/FormInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
} from '../../lib'
Expand All @@ -17,7 +17,6 @@ import FormField from './FormField'
function FormInput(props) {
const { control } = props
const rest = getUnhandledProps(FormInput, props)
const ElementType = getElementType(FormInput, props)

return <ElementType {...rest} control={control} />
}
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Form/FormRadio.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
} from '../../lib'
Expand All @@ -17,7 +17,6 @@ import FormField from './FormField'
function FormRadio(props) {
const { control } = props
const rest = getUnhandledProps(FormRadio, props)
const ElementType = getElementType(FormRadio, props)

return <ElementType {...rest} control={control} />
}
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Form/FormSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
} from '../../lib'
Expand All @@ -17,7 +17,6 @@ import FormField from './FormField'
function FormSelect(props) {
const { control } = props
const rest = getUnhandledProps(FormSelect, props)
const ElementType = getElementType(FormSelect, props)

return <ElementType {...rest} control={control} />
}
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Form/FormTextArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
} from '../../lib'
Expand All @@ -17,7 +17,6 @@ import FormField from './FormField'
function FormTextArea(props) {
const { control } = props
const rest = getUnhandledProps(FormTextArea, props)
const ElementType = getElementType(FormTextArea, props)

return <ElementType {...rest} control={control} />
}
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Grid/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
SUI,
Expand Down Expand Up @@ -61,7 +61,6 @@ function Grid(props) {
className,
)
const rest = getUnhandledProps(Grid, props)
const ElementType = getElementType(Grid, props)

return <ElementType {...rest} className={classes}>{children}</ElementType>
}
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Grid/GridColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react'
import {
customPropTypes,
createShorthandFactory,
getElementType,
ElementType,
getUnhandledProps,
META,
SUI,
Expand Down Expand Up @@ -55,7 +55,6 @@ function GridColumn(props) {
className,
)
const rest = getUnhandledProps(GridColumn, props)
const ElementType = getElementType(GridColumn, props)

return <ElementType {...rest} className={classes}>{children}</ElementType>
}
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Grid/GridRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'

import {
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
SUI,
Expand Down Expand Up @@ -47,7 +47,6 @@ function GridRow(props) {
className,
)
const rest = getUnhandledProps(GridRow, props)
const ElementType = getElementType(GridRow, props)

return <ElementType {...rest} className={classes}>{children}</ElementType>
}
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
childrenUtils,
customPropTypes,
createShorthandFactory,
getElementType,
ElementType,
getUnhandledProps,
META,
SUI,
Expand Down Expand Up @@ -213,7 +213,6 @@ class Menu extends Component {
'menu',
)
const rest = getUnhandledProps(Menu, this.props)
const ElementType = getElementType(Menu, this.props)

return (
<ElementType {...rest} className={classes}>
Expand Down
3 changes: 1 addition & 2 deletions src/collections/Menu/MenuHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react'
import {
childrenUtils,
customPropTypes,
getElementType,
ElementType,
getUnhandledProps,
META,
} from '../../lib'
Expand All @@ -17,7 +17,6 @@ function MenuHeader(props) {
const { children, className, content } = props
const classes = cx('header', className)
const rest = getUnhandledProps(MenuHeader, props)
const ElementType = getElementType(MenuHeader, props)

return (
<ElementType {...rest} className={classes}>
Expand Down
Loading