react-toolbox/components/list/ListItemActions.js

35 lines
1003 B
JavaScript
Raw Normal View History

import React from 'react';
2016-05-22 20:08:47 +03:00
import { themr } from 'react-css-themr';
2016-05-29 21:59:54 +03:00
import { LIST } from '../identifiers.js';
import InjectListItemAction from './ListItemAction.js';
2016-05-29 21:59:54 +03:00
const factory = (ListItemAction) => {
const ListItemActions = ({type, children, theme}) => {
const validChildren = React.Children.toArray(children).filter(c => (
React.isValidElement(c)
));
2016-05-29 21:59:54 +03:00
return (
<span className={theme[type]}>
{validChildren.map((action, i) => <ListItemAction key={i} action={action} />)}
</span>
);
};
ListItemActions.propTypes = {
children: React.PropTypes.any,
theme: React.PropTypes.shape({
left: React.PropTypes.string.isRequired,
right: React.PropTypes.string.isRequired
}),
type: React.PropTypes.oneOf(['left', 'right'])
};
2016-05-29 21:59:54 +03:00
return ListItemActions;
};
2016-05-29 21:59:54 +03:00
const ListItemActions = factory(InjectListItemAction);
export default themr(LIST)(ListItemActions);
export { factory as listItemActionsFactory };
export { ListItemActions };