{"version":3,"file":"TableHead.mjs","sources":["../../../src/lib/elements/TableHead/TableHead.jsx"],"sourcesContent":["/*\nCopyright 2019 Iguazio Systems Ltd.\n\nLicensed under the Apache License, Version 2.0 (the \"License\") with\nan addition restriction as set forth herein. You may not use this\nfile except in compliance with the License. You may obtain a copy of\nthe License at http://www.apache.org/licenses/LICENSE-2.0.\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\nimplied. See the License for the specific language governing\npermissions and limitations under the License.\n\nIn addition, you may not use the software for any purposes that are\nillegal under applicable law, and the grant of the foregoing license\nunder the Apache 2.0 license is conditioned upon your compliance with\nsuch restriction.\n*/\nimport React, { forwardRef } from 'react'\nimport PropTypes from 'prop-types'\nimport classNames from 'classnames'\nimport { isEmpty } from 'lodash'\n\nimport Tip from '../../components/Tip/Tip'\nimport Tooltip from '../../components/Tooltip/Tooltip'\nimport TextTooltipTemplate from '../../components/TooltipTemplate/TextTooltipTemplate'\n\nimport { SORT_PROPS } from '../../types'\n\nlet TableHead = (\n  { content, hideActionsMenu = false, mainRowItemsCount, selectedItem, sortProps = null },\n  ref\n) => {\n  const getHeaderCellClasses = (\n    headerId,\n    isSortable,\n    tableItemClassName,\n    headerCellClassName,\n    index\n  ) =>\n    classNames(\n      'table-header__cell',\n      tableItemClassName,\n      headerCellClassName,\n      isSortable && 'sortable-header-cell',\n      isSortable && sortProps?.selectedColumnName === headerId && 'sortable-header-cell_active',\n      !isEmpty(selectedItem) && index >= mainRowItemsCount && 'table-body__cell_hidden'\n    )\n\n  return (\n    <thead className=\"table-header\">\n      <tr className=\"table-row table-header-row\" ref={ref}>\n        {content.map(({ headerLabel, headerId, isSortable, ...tableItem }, index) => {\n          return tableItem.type !== 'hidden' && !tableItem.hidden && !tableItem.headerIsHidden ? (\n            <th\n              data-testid={headerId}\n              className={getHeaderCellClasses(\n                headerId,\n                isSortable,\n                tableItem.className,\n                tableItem.headerCellClassName,\n                index\n              )}\n              key={headerId}\n              onClick={isSortable ? () => sortProps?.sortTable(headerId) : null}\n            >\n              <Tooltip template={<TextTooltipTemplate text={headerLabel} />}>\n                <label className={isSortable ? 'sortable-header-label' : ''}>\n                  <span className=\"data-ellipsis\">{headerLabel}</span>\n                  {isSortable && sortProps?.getSortingIcon(headerId)}\n                </label>\n              </Tooltip>\n\n              {tableItem.tip && <Tip text={tableItem.tip} />}\n            </th>\n          ) : null\n        })}\n        {!hideActionsMenu && <th className=\"table-header__cell table-cell-icon\" />}\n      </tr>\n    </thead>\n  )\n}\n\nTableHead = forwardRef(TableHead)\n\nTableHead.displayName = 'TableHead'\n\nTableHead.propTypes = {\n  content: PropTypes.array.isRequired,\n  hideActionsMenu: PropTypes.bool,\n  mainRowItemsCount: PropTypes.number.isRequired,\n  selectedItem: PropTypes.object.isRequired,\n  sortProps: SORT_PROPS\n}\n\nexport default TableHead\n"],"names":["TableHead","content","hideActionsMenu","mainRowItemsCount","selectedItem","sortProps","ref","getHeaderCellClasses","headerId","isSortable","tableItemClassName","headerCellClassName","index","classNames","isEmpty","jsx","headerLabel","tableItem","jsxs","Tooltip","TextTooltipTemplate","Tip","forwardRef","PropTypes","SORT_PROPS","TableHead$1"],"mappings":";;;;;;;;;AA8BA,IAAIA,IAAY,CACd,EAAE,SAAAC,GAAS,iBAAAC,IAAkB,IAAO,mBAAAC,GAAmB,cAAAC,GAAc,WAAAC,IAAY,KAAA,GACjFC,MACG;AACH,QAAMC,IAAuB,CAC3BC,GACAC,GACAC,GACAC,GACAC,MAEAC;AAAAA,IACE;AAAA,IACAH;AAAA,IACAC;AAAA,IACAF,KAAc;AAAA,IACdA,MAAcJ,KAAA,gBAAAA,EAAW,wBAAuBG,KAAY;AAAA,IAC5D,CAACM,EAAQV,CAAY,KAAKQ,KAAST,KAAqB;AAAA,EAAA;AAG5D,SACE,gBAAAY,EAAC,WAAM,WAAU,gBACf,4BAAC,MAAA,EAAG,WAAU,8BA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