UNPKG

@talend/react-containers

Version:

Provide connected components aka containers for @talend/react-cmf based on @talend/react-components.

61 lines 1.36 kB
import { cmfConnect } from '@talend/react-cmf'; import Action from '../Action'; import Actions from '../Actions'; import ActionDropdown from '../ActionDropdown'; import ActionSplitDropdown from '../ActionSplitDropdown'; import getRenderers from '../renderers'; import { ActionBar } from "@talend/react-components"; const renderers = { Action, Actions, ActionDropdown, ActionSplitDropdown }; function getAction(actionId) { if (typeof actionId === 'string') { return { actionId }; } return actionId; } export function mapStateToProps(state, { actionIds }) { const props = { renderers: getRenderers(renderers) }; if (actionIds) { props.actions = {}; const { left, right } = actionIds; if (left) { props.actions.left = left.map(getAction); } if (right) { props.actions.right = right.map(getAction); } } return props; } export function mergeProps(stateProps, dispatchProps, ownProps) { const props = { ...ownProps, ...stateProps, ...dispatchProps }; delete props.actionIds; return props; } export default cmfConnect({ mapStateToProps, mergeProps, omitCMFProps: true, withComponentRegistry: true, withDispatch: true, withDispatchActionCreator: true, withComponentId: true })(ActionBar); //# sourceMappingURL=ActionBar.connect.js.map