/*
Copyright (c) 2018-2020 Uber Technologies, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
// @flow
import * as React from 'react';
import * as ReactIs from 'react-is';
import {
StartEnhancer as StyledStartEnhancer,
EndEnhancer as StyledEndEnhancer,
} from './styled-components.js';
import {getSharedProps} from './utils.js';
import {getOverrides} from '../helpers/overrides.js';
import type {ButtonPropsT} from './types.js';
function RenderEnhancer(props) {
const {Enhancer, ...restProps} = props;
if (typeof Enhancer === 'string') {
return Enhancer;
}
if (ReactIs.isValidElementType(Enhancer)) {
// $FlowFixMe
return ;
}
// $FlowFixMe
return Enhancer;
}
export default function ButtonInternals(props: ButtonPropsT) {
const {children, overrides = {}, startEnhancer, endEnhancer} = props;
const [StartEnhancer, startEnhancerProps] = getOverrides(
overrides.StartEnhancer,
StyledStartEnhancer,
);
const [EndEnhancer, endEnhancerProps] = getOverrides(
overrides.EndEnhancer,
StyledEndEnhancer,
);
const sharedProps = getSharedProps(props);
return (
{startEnhancer !== null && startEnhancer !== undefined && (
)}
{children}
{endEnhancer !== null && endEnhancer !== undefined && (
)}
);
}
declare var __DEV__: boolean;
declare var __NODE__: boolean;
declare var __BROWSER__: boolean;