UNPKG

@heycar-uikit/core

Version:
21 lines (17 loc) 1.14 kB
import React from 'react'; var styles = {"wrapper":"segmented-buttons__wrapper_9p12n","btn":"segmented-buttons__btn_9p12n","isWideView":"segmented-buttons__isWideView_9p12n"}; require('./styles/default.css'); /* eslint-disable react-hooks/exhaustive-deps */ const SegmentedButtons = React.forwardRef(({ className, currentValue, buttons, dataTestId, onChange, wideView, ...restProps }, ref) => { return (React.createElement("div", { className: `${styles.wrapper} ${wideView ? styles.isWideView : ''} ${className}`, "data-test-id": dataTestId, ref: ref, role: "radiogroup", ...restProps }, buttons.map(btn => { const isActive = currentValue === btn.value; return (React.createElement("button", { "aria-checked": isActive, "aria-label": btn.label, className: styles.btn, "data-test-id": btn.dataTestId, disabled: btn.isDisabled, key: btn.label, onClick: () => { if (!isActive) onChange(btn.value); }, role: "radio" }, btn.icon, btn.label)); }))); }); SegmentedButtons.displayName = 'SegmentedButtons'; export { SegmentedButtons as default };