Sha256: 721c51ae90c9dee50e3c74a7572659b2a1fa97e69e7cd326be326f4465d9196c

Contents?: true

Size: 1.8 KB

Versions: 16

Compression:

Stored size: 1.8 KB

Contents

import React, { useContext } from "react"
import classnames from "classnames";
import { buildCss } from "../../utilities/props";
import { globalProps } from "../../utilities/globalProps";
import { HeaderGroup } from "@tanstack/react-table"
import AdvancedTableContext from "../Context/AdvancedTableContext"
import { TableHeaderCell } from "../Components/TableHeaderCell"
import { DataType } from "../Utilities/types"

type TableHeaderProps = {
  children?: React.ReactNode | React.ReactNode[]
  className?: string
  enableSorting?: boolean
  id?: string;
  sortIcon?: string | string[]
}

export const TableHeader = ({
  children,
  className,
  enableSorting = false,
  id,
  sortIcon = ["arrow-up-short-wide", "arrow-down-short-wide"],
  ...props
}: TableHeaderProps) => {
  const {
    enableToggleExpansion,
    handleExpandOrCollapse,
    loading,
    table,
  } = useContext(AdvancedTableContext)

  const classes = classnames(
    buildCss("pb_advanced_table_header"),
    globalProps(props),
    className
  );


  return (
    <>
      <thead className={classes}
          id={id}
      >
        {/* Get the header groups (only one in this example) */}
        {table.getHeaderGroups().map((headerGroup: HeaderGroup<DataType>) => (
          <tr key={`${headerGroup.id}-headerGroup`}>
            {headerGroup.headers.map(header => (
              <TableHeaderCell
                  enableSorting={enableSorting}
                  enableToggleExpansion={enableToggleExpansion}
                  handleExpandOrCollapse={handleExpandOrCollapse}
                  header={header}
                  headerChildren={children}
                  key={`${header.id}-header`}
                  loading={loading}
                  sortIcon={sortIcon}
              />
            ))}
          </tr>
        ))}
      </thead>
    </>
  )
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
playbook_ui-13.19.0.pre.alpha.play1174fixconfimationtoastmobilebug2345 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.19.0.pre.alpha.play1174fixconfimationtoastmobilebug2342 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.19.0.pre.alpha.play1186collapsiblenaviconcolorbug2321 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.19.0.pre.alpha.PBNTR211tablekitsubcomponentsreact2318 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.19.0.pre.alpha.play1174fixconfimationtoastmobilebug2306 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.19.0.pre.alpha.play1174fixconfimationtoastmobilebug2305 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.20.0 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.19.0.pre.alpha.play1141iconkitusinglibrary2264 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.19.0.pre.alpha.PBNTR207tabledivsupport2261 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.19.0.pre.alpha.PBNTR207tabledivsupport2245 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.19.0 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2197 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2178 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2176 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2173 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx
playbook_ui-13.18.0.pre.alpha.PBNTR191AdvancedTableFinalFixes2159 app/pb_kits/playbook/pb_advanced_table/SubKits/TableHeader.tsx