UNPKG

@atlaskit/dynamic-table

Version:

A dynamic table displays rows of data with built-in pagination, sorting, and re-ordering functionality.

60 lines (58 loc) 3.31 kB
/* head-cell.tsx generated by @compiled/babel-plugin v3.0.2 */ import _extends from "@babel/runtime/helpers/extends"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["width", "children", "isSortable", "sortOrder", "isFixedSize", "shouldTruncate", "onClick", "style", "testId"]; import "./head-cell.compiled.css"; import * as React from 'react'; import { ax, ix } from "@compiled/react/runtime"; 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; } /* eslint-disable @repo/internal/react/require-jsdoc */ import { forwardRef } from 'react'; import { getTruncationStyleVars } from './constants'; var CSS_VAR_TEXT_COLOR = '--local-dynamic-table-text-color'; var overflowTruncateStyles = null; var truncationWidthStyles = null; var fixedSizeTruncateStyles = null; var cellStyles = null; var headCellBaseStyles = null; export var HeadCell = /*#__PURE__*/forwardRef(function (_ref, ref) { var width = _ref.width, children = _ref.children, isSortable = _ref.isSortable, sortOrder = _ref.sortOrder, isFixedSize = _ref.isFixedSize, shouldTruncate = _ref.shouldTruncate, onClick = _ref.onClick, style = _ref.style, testId = _ref.testId, rest = _objectWithoutProperties(_ref, _excluded); var mergedStyles = _objectSpread(_objectSpread(_objectSpread({}, style), width && getTruncationStyleVars({ width: width })), {}, _defineProperty({}, CSS_VAR_TEXT_COLOR, "var(--ds-text-subtlest, #6B6E76)")); var isASC = sortOrder === 'ASC'; var isDESC = sortOrder === 'DESC'; var getFormattedSortOrder = function getFormattedSortOrder() { if (isASC) { return 'ascending'; } else if (isDESC) { return 'descending'; } return; }; // If there is no content in the cell, it should be rendered as an empty `td`, not a `th`. // https://dequeuniversity.com/rules/axe/4.7/empty-table-header var Component = children ? 'th' : 'td'; return /*#__PURE__*/React.createElement(Component, _extends({ "aria-sort": getFormattedSortOrder() // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766 , style: mergedStyles, onClick: undefined, ref: ref, "data-testid": testId }, rest, { className: ax(["_izbqglyw _h7alglyw _85i51b66 _1q511b66 _y4tiu2gc _bozgu2gc _y3gn1e5h _1s37ze3t _uupyze3t", "_11c8wadc _179r1uh4 _mqm2glyw _kqswh2mm _syazazsu _k48pwu06 _y3gn1e5h _s7n4nkob _1ygbd0i9", "_1bsb8a2a", isFixedSize && shouldTruncate && "_1bto1l2s _o5721q9c", isFixedSize && "_1reo15vq _18m915vq"]) }), children); });