UNPKG

@onesy/ui-react

Version:
83 lines (82 loc) 4.56 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _compilerRuntime = require("react/compiler-runtime"); var _react = _interopRequireDefault(require("react")); var _styleReact = require("@onesy/style-react"); var _Line = _interopRequireDefault(require("../Line")); var _Surface = _interopRequireDefault(require("../Surface")); var _utils = require("../utils"); var _jsxRuntime = require("react/jsx-runtime"); const _excluded = ["tonal", "color", "size", "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) { (0, _defineProperty2.default)(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; } const useStyle = (0, _styleReact.style)(theme => ({ root: {}, size_small: { padding: theme.methods.space.value(2, 'px') }, size_regular: { padding: `${theme.methods.space.value(3, 'px')} ${theme.methods.space.value(2, 'px')}` }, size_large: { padding: `${theme.methods.space.value(4, 'px')} ${theme.methods.space.value(3, 'px')}` } }), { name: 'onesy-TableHeader' }); const TableHeader = props_ => { var _theme$ui, _theme$ui2, _theme$elements, _theme$elements2; const $ = (0, _compilerRuntime.c)(8); const theme = (0, _styleReact.useOnesyTheme)(); const props = _objectSpread(_objectSpread(_objectSpread({}, theme === null || theme === void 0 || (_theme$ui = theme.ui) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.elements) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.all) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.props) === null || _theme$ui === void 0 ? void 0 : _theme$ui.default), theme === null || theme === void 0 || (_theme$ui2 = theme.ui) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.elements) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.onesyTableHeader) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.props) === null || _theme$ui2 === void 0 ? void 0 : _theme$ui2.default), props_); const Line = (theme === null || theme === void 0 || (_theme$elements = theme.elements) === null || _theme$elements === void 0 ? void 0 : _theme$elements.Line) || _Line.default; const Surface = (theme === null || theme === void 0 || (_theme$elements2 = theme.elements) === null || _theme$elements2 === void 0 ? void 0 : _theme$elements2.Surface) || _Surface.default; const { tonal: t0, color: t1, size: t2, Component: t3, className, children } = props, other = (0, _objectWithoutProperties2.default)(props, _excluded); const tonal = t0 === undefined ? true : t0; const color = t1 === undefined ? "themed" : t1; const size = t2 === undefined ? "regular" : t2; const Component = t3 === undefined ? Line : t3; const { classes } = useStyle(); const t4 = Surface; const t5 = (0, _styleReact.classNames)([(0, _utils.staticClassName)("TableHeader", theme) && ["onesy-TableHeader-root", `onesy-TableHeader-size-${size}`], className, classes.root, classes[`size_${size}`]]); let t6; if ($[0] !== Component || $[1] !== children || $[2] !== color || $[3] !== other || $[4] !== t4 || $[5] !== t5 || $[6] !== tonal) { t6 = /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, _objectSpread(_objectSpread({ tonal: tonal, color: color, Component: t4, className: t5 }, other), {}, { children: children })); $[0] = Component; $[1] = children; $[2] = color; $[3] = other; $[4] = t4; $[5] = t5; $[6] = tonal; $[7] = t6; } else { t6 = $[7]; } return t6; }; TableHeader.displayName = 'onesy-TableHeader'; var _default = exports.default = TableHeader;