zmp-react
Version:
Build full featured iOS & Android apps using ZMP & React
58 lines (57 loc) • 2.01 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
import { classNames, getExtraAttrs } from '../shared/utils';
import { colorClasses } from '../shared/mixins';
var Segmented = /*#__PURE__*/forwardRef(function (props, ref) {
var className = props.className,
id = props.id,
style = props.style,
children = props.children,
raised = props.raised,
raisedIos = props.raisedIos,
raisedMd = props.raisedMd,
raisedAurora = props.raisedAurora,
round = props.round,
roundIos = props.roundIos,
roundMd = props.roundMd,
roundAurora = props.roundAurora,
strong = props.strong,
strongIos = props.strongIos,
strongMd = props.strongMd,
strongAurora = props.strongAurora,
_props$tag = props.tag,
tag = _props$tag === void 0 ? 'div' : _props$tag;
var extraAttrs = getExtraAttrs(props);
var elRef = useRef(null);
useImperativeHandle(ref, function () {
return {
el: elRef.current
};
});
var classes = classNames(className, {
segmented: true,
'segmented-raised': raised,
'segmented-raised-ios': raisedIos,
'segmented-raised-aurora': raisedAurora,
'segmented-raised-md': raisedMd,
'segmented-round': round,
'segmented-round-ios': roundIos,
'segmented-round-aurora': roundAurora,
'segmented-round-md': roundMd,
'segmented-strong': strong,
'segmented-strong-ios': strongIos,
'segmented-strong-md': strongMd,
'segmented-strong-aurora': strongAurora
}, colorClasses(props));
var SegmentedTag = tag;
return /*#__PURE__*/React.createElement(SegmentedTag, _extends({
id: id,
style: style,
className: classes,
ref: elRef
}, extraAttrs), children, (strong || strongIos || strongMd || strongAurora) && /*#__PURE__*/React.createElement("span", {
className: "segmented-highlight"
}));
});
Segmented.displayName = 'zmp-segmented';
export default Segmented;