UNPKG

@onesy/ui-react

Version:
94 lines 4.21 kB
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; const _excluded = ["tonal", "color", "size", "hover", "selected", "position", "Component", "className", "children"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } import { c as _c } from "react/compiler-runtime"; import React from 'react'; import { is } from '@onesy/utils'; import { classNames, style as styleMethod, useOnesyTheme } from '@onesy/style-react'; import SurfaceElement from '../Surface'; import { staticClassName } from '../utils'; import { jsx as _jsx } from "react/jsx-runtime"; const useStyle = styleMethod(theme => ({ root: { display: 'table-row', position: 'relative' }, hover: { '&:hover': { '& .onesy-TableCell-root::before': { opacity: theme.palette.visual_contrast.default.opacity.hover } } }, selected: { '& .onesy-TableCell-root::before': { opacity: [theme.palette.visual_contrast.default.opacity.selected, '!important'] } } }), { name: 'onesy-TableRow' }); const TableRow = props_ => { const $ = _c(8); const theme = useOnesyTheme(); const props = _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.onesyTableRow?.props?.default), props_); const Surface = theme?.elements?.Surface || SurfaceElement; const { tonal: t0, color: t1, size: t2, hover: t3, selected, position: t4, Component: t5, className, children } = props, other = _objectWithoutProperties(props, _excluded); const tonal = t0 === undefined ? true : t0; const color = t1 === undefined ? "themed" : t1; const size = t2 === undefined ? "regular" : t2; const hover = t3 === undefined ? true : t3; const position = t4 === undefined ? "body" : t4; const Component = t5 === undefined ? "tr" : t5; const { classes } = useStyle(); const t6 = "row"; const t7 = classNames([staticClassName("TableRow", theme) && ["onesy-TableRow-root", `onesy-TableRow-size-${size}`, hover && position === "body" && "onesy-TableRow-hover", selected && "onesy-TableRow-selected"], className, classes.root, hover && position === "body" && classes.hover, selected && classes.selected]); const t8 = React.Children.toArray(children).map((item, index) => is("object", item) ? /*#__PURE__*/React.cloneElement(item, { tonal: item.props.tonal !== undefined ? item.props.tonal : tonal, color: item.props.color !== undefined ? item.props.color : color, size: item.props.size !== undefined ? item.props.size : size, justify: item.props.justify !== undefined ? item.props.justify : index === 0 ? "flex-start" : "flex-end", position: props.position !== undefined ? props.position : index === 0 && position === "body" ? "head" : position, noWeight: index === 0 && position === "body" }) : item); let t9; if ($[0] !== Component || $[1] !== Surface || $[2] !== color || $[3] !== other || $[4] !== t7 || $[5] !== t8 || $[6] !== tonal) { t9 = /*#__PURE__*/_jsx(Surface, _objectSpread(_objectSpread({ tonal: tonal, color: color, role: t6, Component: Component, className: t7 }, other), {}, { children: t8 })); $[0] = Component; $[1] = Surface; $[2] = color; $[3] = other; $[4] = t7; $[5] = t8; $[6] = tonal; $[7] = t9; } else { t9 = $[7]; } return t9; }; TableRow.displayName = 'onesy-TableRow'; export default TableRow;