Sha256: 51e293a80fb5975cd76622c1187bc8dbff9f33a9d24ec3541331b9d69e2a8157

Contents?: true

Size: 1.99 KB

Versions: 561

Compression:

Stored size: 1.99 KB

Contents

import React, { useContext } from "react"
import { Row, Table } from "@tanstack/react-table"

import { GenericObject } from "../../types"

import { GlobalProps } from "../../utilities/globalProps"

import Flex from "../../pb_flex/_flex"
import Caption from "../../pb_caption/_caption"

import { ToggleIconButton } from "./ToggleIconButton"
import { renderCollapsibleTrail } from "./CollapsibleTrail"

import { isChrome } from "../Utilities/BrowserCheck"

import AdvancedTableContext from "../Context/AdvancedTableContext"

interface SubRowHeaderRowProps {
  collapsibleTrail?: boolean
  enableToggleExpansion?: "all" | "header" | "none"
  onClick: (row: Row<GenericObject>) => void
  row: Row<GenericObject>
  subRowHeaders?: string[]
  table: Table<GenericObject>
}

export const SubRowHeaderRow = ({
  collapsibleTrail,
  enableToggleExpansion,
  onClick,
  row,
  subRowHeaders,
  table,
}: SubRowHeaderRowProps & GlobalProps) => {
  const { inlineRowLoading } = useContext(AdvancedTableContext)

  const numberOfColumns = table.getAllFlatColumns().length
  const rowHasChildren = row.original.children ? true : false
  const canExpand = inlineRowLoading ? rowHasChildren : row.getCanExpand()

  return (
    <tr className="custom-row bg-silver">
      <td
          className={`custom-row-first-column ${
          isChrome() ? "chrome-styles" : ""
          }`}
          colSpan={1}
      >
        {collapsibleTrail && row.depth > 0 && renderCollapsibleTrail(row.depth)}
        <div style={{ paddingLeft: `${row.depth * 1.25}em` }}>
          <Flex align="center" 
              columnGap="xs"
          >
            {enableToggleExpansion === "all" && canExpand ? (
              <ToggleIconButton onClick={onClick} 
                  row={row}
              />
            ) : null}
            <Caption
                marginLeft={canExpand ? "none" : "xs"}
                text={subRowHeaders[row.depth - 1]}
            />
          </Flex>
        </div>
      </td>

      <td colSpan={numberOfColumns - 1} />
    </tr>
  )
}

Version data entries

561 entries across 561 versions & 1 rubygems

Version Path
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5201 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.11.0.pre.rc.9 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5200 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.11.0.pre.rc.8 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.11.0.pre.rc.7 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.11.0.pre.rc.6 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.11.0.pre.rc.5 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5193 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.11.0.pre.rc.4 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.11.0.pre.rc.3 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.10.0.pre.alpha.PBNTR662stickyrightcolumnreact5160 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.11.0.pre.rc.2 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.11.0.pre.rc.1 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.10.0.pre.alpha.PBNTR775formmatingmaskdefaultvalue5137 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.11.0.pre.rc.0 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.9.0.pre.alpha.PBNTR767advancedtablemultiheadercolumns5136 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.9.0.pre.alpha.PBNTR775formmatingmaskdefaultvalue5121 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.9.0.pre.alpha.PBNTR775formmatingmaskdefaultvalue5120 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.10.0 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx
playbook_ui-14.10.0.pre.rc.24 app/pb_kits/playbook/pb_advanced_table/Components/SubRowHeaderRow.tsx