Skip to content

Commit

Permalink
remove transform
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter committed Dec 29, 2023
1 parent 0a43c3d commit baed0af
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 54 deletions.
25 changes: 10 additions & 15 deletions src/modules/Tab/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'

import {
customPropTypes,
getElementType,
getComponentType,
getUnhandledProps,
useAutoControlledValue,
} from '../../lib'
Expand All @@ -18,9 +18,14 @@ import TabPane from './TabPane'
* @see Menu
* @see Segment
*/
const Tab = React.forwardRef(function (partialProps, ref) {
const props = _.defaults(partialProps, getDefaultProps())
const { grid, menu, panes, menuPosition, renderActiveOnly } = props
const Tab = React.forwardRef(function (props, ref) {
const {
grid = { paneWidth: 12, tabWidth: 4 },
menu = { attached: true, tabular: true },
menuPosition,
panes,
renderActiveOnly = true,
} = props

const [activeIndex, setActiveIndex] = useAutoControlledValue({
state: props.activeIndex,
Expand Down Expand Up @@ -87,7 +92,7 @@ const Tab = React.forwardRef(function (partialProps, ref) {

const menuElement = renderMenu()
const rest = getUnhandledProps(Tab, props)
const ElementType = getElementType(Tab, props)
const ElementType = getComponentType(props)

if (menuElement.props.vertical) {
return (
Expand Down Expand Up @@ -156,16 +161,6 @@ Tab.propTypes = {
renderActiveOnly: PropTypes.bool,
}

Tab.autoControlledProps = ['activeIndex']

function getDefaultProps() {
return {
grid: { paneWidth: 12, tabWidth: 4 },
menu: { attached: true, tabular: true },
renderActiveOnly: true,
}
}

Tab.Pane = TabPane

export default Tab
17 changes: 4 additions & 13 deletions src/modules/Tab/TabPane.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash'
import cx from 'clsx'
import PropTypes from 'prop-types'
import React from 'react'
Expand All @@ -7,7 +6,7 @@ import {
childrenUtils,
createShorthandFactory,
customPropTypes,
getElementType,
getComponentType,
getUnhandledProps,
useKeyOnly,
} from '../../lib'
Expand All @@ -16,13 +15,12 @@ import Segment from '../../elements/Segment/Segment'
/**
* A tab pane holds the content of a tab.
*/
const TabPane = React.forwardRef(function (partialProps, ref) {
const props = _.defaults(partialProps, getDefaultProps())
const { active, children, className, content, loading } = props
const TabPane = React.forwardRef(function (props, ref) {
const { active = true, children, className, content, loading } = props

const classes = cx(useKeyOnly(active, 'active'), useKeyOnly(loading, 'loading'), 'tab', className)
const rest = getUnhandledProps(TabPane, props)
const ElementType = getElementType(TabPane, props)
const ElementType = getComponentType(props, { defaultAs: Segment })

const calculatedDefaultProps = {}

Expand All @@ -37,13 +35,6 @@ const TabPane = React.forwardRef(function (partialProps, ref) {
)
})

function getDefaultProps() {
return {
as: Segment,
active: true,
}
}

TabPane.displayName = 'TabPane'
TabPane.propTypes = {
/** An element type to render as (string or function). */
Expand Down
21 changes: 6 additions & 15 deletions src/modules/Transition/TransitionGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import React from 'react'

import {
getElementType,
getComponentType,
getUnhandledProps,
makeDebugger,
SUI,
Expand All @@ -19,7 +19,7 @@ const debug = makeDebugger('transition_group')
* Wraps all children elements with proper callbacks and props.
*
* @param {React.ReactNode} children
* @param {Stream} animation
* @param {String} animation
* @param {Number|String|Object} duration
* @param {Boolean} directional
*
Expand Down Expand Up @@ -107,19 +107,18 @@ function useWrappedChildren(children, animation, duration, directional) {
/**
* A Transition.Group animates children as they mount and unmount.
*/
const TransitionGroup = React.forwardRef(function (partialProps, ref) {
const props = _.defaults(partialProps, getDefaultProps())
const TransitionGroup = React.forwardRef(function (props, ref) {
debug('render')
debug('props', props)

const children = useWrappedChildren(
props.children,
props.animation,
props.duration,
props.animation ?? 'fade',
props.duration ?? 500,
props.directional,
)

const ElementType = getElementType(TransitionGroup, props)
const ElementType = getComponentType(props, { defaultAs: React.Fragment })
const rest = getUnhandledProps(TransitionGroup, props)

return (
Expand Down Expand Up @@ -154,12 +153,4 @@ TransitionGroup.propTypes = {
]),
}

function getDefaultProps() {
return {
as: React.Fragment,
animation: 'fade',
duration: 500,
}
}

export default TransitionGroup
14 changes: 3 additions & 11 deletions src/views/Comment/CommentAction.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import _ from 'lodash'
import cx from 'clsx'
import PropTypes from 'prop-types'
import React from 'react'

import {
childrenUtils,
customPropTypes,
getElementType,
getComponentType,
getUnhandledProps,
useKeyOnly,
} from '../../lib'

/**
* A comment can contain an action.
*/
const CommentAction = React.forwardRef(function (partialProps, ref) {
const props = _.defaults(partialProps, getDefaultProps())
const CommentAction = React.forwardRef(function (props, ref) {
const { active, className, children, content } = props

const classes = cx(useKeyOnly(active, 'active'), className)
const rest = getUnhandledProps(CommentAction, props)
const ElementType = getElementType(CommentAction, props)
const ElementType = getComponentType(props, { defaultAs: 'a' })

return (
<ElementType {...rest} className={classes} ref={ref}>
Expand All @@ -29,12 +27,6 @@ const CommentAction = React.forwardRef(function (partialProps, ref) {
)
})

function getDefaultProps() {
return {
as: 'a',
}
}

CommentAction.displayName = 'CommentAction'
CommentAction.propTypes = {
/** An element type to render as (string or function). */
Expand Down

0 comments on commit baed0af

Please sign in to comment.