UNPKG

@kiwicom/orbit-components

Version:

Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.

58 lines (57 loc) 2.25 kB
"use client"; import _extends from "@babel/runtime/helpers/esm/extends"; import * as React from "react"; import cx from "clsx"; import Heading from "../Heading"; import Checkbox from "../Checkbox"; import Text from "../Text"; import handleKeyDown from "../utils/handleKeyDown"; const ListChoice = /*#__PURE__*/React.forwardRef(({ dataTest, id, icon, action, title, description, selectable, role, onClick, tabIndex = 0, selected, disabled }, ref) => { const conditionalProps = { ...(selectable ? { "aria-checked": selected } : null) }; return /*#__PURE__*/React.createElement("div", _extends({ className: cx("orbit-list-choice", "py-sm px-md box-border flex w-full items-center", "border-b-cloud-normal bg-white-normal border-b-solid border-b", "duration-fast transition-[background-color] ease-in-out", disabled ? "cursor-not-allowed" : "hover:bg-cloud-light cursor-pointer", "hover:outline-none [&_button]:hover:bg-transparent", "[&_.orbit-checkbox-label]:w-auto"), onClick: !disabled ? onClick : undefined, "data-test": dataTest, id: id, ref: ref, onKeyDown: !disabled ? handleKeyDown(onClick) : undefined, tabIndex: tabIndex || disabled ? -1 : 0, "data-title": title, "aria-disabled": disabled, "aria-selected": selected, role: role || (selectable ? "checkbox" : "button") }, conditionalProps), icon && /*#__PURE__*/React.createElement("div", { className: cx("me-xs h-icon-medium flex flex-none items-center self-start", "[&_svg]:w-icon-medium [&_svg]:h-icon-medium [&_svg]:text-icon-primary-foreground [&_svg]:self-center", "[&_svg]:duration-fast [&_svg]:transition-[color] [&_svg]:ease-in-out") }, icon), /*#__PURE__*/React.createElement("div", { className: "pe-sm flex w-full flex-col justify-center" }, /*#__PURE__*/React.createElement(Heading, { type: "title4" }, title), description && /*#__PURE__*/React.createElement(Text, { type: "secondary", size: "small" }, description)), selectable && /*#__PURE__*/React.createElement(Checkbox, { checked: selected, readOnly: true, disabled: disabled, tabIndex: -1 }), !selectable && action); }); ListChoice.displayName = "ListChoice"; export default ListChoice;