Skip to content

Commit

Permalink
docs(types): fix type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter committed May 14, 2017
1 parent a14cb23 commit 40225a8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
37 changes: 30 additions & 7 deletions gulp/plugins/util/parseType.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
require('babel-register')
const _ = require('lodash')
const SUI = require('../../../src/lib/SUI')
const SUI = require('../../../src/lib/SUI') // eslint-disable-line no-unused-vars

module.exports = (propDef) => {
const { type } = propDef
const { name, value } = type
const evalValue = (values) => _.uniq(eval(values)).map(value => ({ // eslint-disable-line no-eval
computed: true,
value: `'${value}'`,
}))

if (name !== 'enum') return type
if (!_.startsWith(value, 'SUI') && !_.startsWith(value, '_.without(SUI')) return type
return _.assign(type, { value: eval(value) })
const transformValues = (items) => _.flatMap(items, item => {
const { value } = item

if (_.startsWith(value, '...SUI')) return evalValue(value.substring(3))
return item
})

const parseEnum = type => {
const { value } = type

if (typeof value === 'string' && value.includes('SUI')) {
return Object.assign(type, { value: evalValue(value) })
}

return Object.assign(type, { value: transformValues(value) })
}

const parsers = {
enum: parseEnum,
}

module.exports = ({ type }) => {
const parser = parsers[type.name]

return parser ? parser(type) : type
}
11 changes: 9 additions & 2 deletions src/collections/Table/TableFooter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import React from 'react'

import { customPropTypes, META } from '../../lib'
import {
customPropTypes,
getUnhandledProps,
META
} from '../../lib'
import TableHeader from './TableHeader'

/**
* A table can have a footer.
*/
function TableFooter(props) {
return <TableHeader {...props} />
const { as } = props
const rest = getUnhandledProps(TableFooter, props)

return <TableHeader {...rest} as={as} />
}

TableFooter._meta = {
Expand Down

0 comments on commit 40225a8

Please sign in to comment.