Sha256: e64122527b7cd099d6db6b436e5e30668718b8674214ab1613bc40bc22361bee

Contents?: true

Size: 1.99 KB

Versions: 290

Compression:

Stored size: 1.99 KB

Contents

import React from "react";
import classnames from "classnames";
import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
import { globalProps } from "../utilities/globalProps";

type ListProps = {
  aria?: { [key: string]: string };
  borderless?: boolean;
  className?: string;
  children: React.ReactNode[] | React.ReactNode;
  dark?: boolean;
  data?: object;
  id?: string;
  layout?: "" | "left" | "right";
  ordered?: boolean;
  role?: string;
  tabIndex?: number;
  text?: string;
  size?: string;
  variant?: string;
  xpadding?: boolean;
};

const List = (props: ListProps) => {
  const {
    aria = {},
    borderless = false,
    children,
    className,
    dark = false,
    data = {},
    id,
    layout = "",
    ordered = false,
    role,
    size = "",
    tabIndex,
    xpadding = false,
    variant,
    text,
  } = props;

  const layoutClass: { [key: string]: string } = {
    left: "layout_left",
    right: "layout_right",
    default: "",
  };

  const childrenWithProps = React.Children.map(
    children,
    (child: React.ReactElement) => {
      return React.cloneElement(child, { text, variant });
    }
  );
  const ariaProps = buildAriaProps(aria);
  const dataProps = buildDataProps(data);
  const classes = classnames(
    buildCss("pb_list_kit", layoutClass[layout], size, {
      dark: dark,
      borderless: borderless,
      ordered: ordered,
      xpadding: xpadding,
    }),
    globalProps(props),
    className
  );

  return (
    <div className={classes}>
      {ordered ? (
        <ol
          {...ariaProps}
          {...dataProps}
          className={className}
          id={id}
          role={role}
          tabIndex={tabIndex}
        >
          {childrenWithProps}
        </ol>
      ) : (
        <ul
          {...ariaProps}
          {...dataProps}
          className={className}
          id={id}
          role={role}
          tabIndex={tabIndex}
        >
          {childrenWithProps}
        </ul>
      )}
    </div>
  );
};

export default List;

Version data entries

290 entries across 290 versions & 1 rubygems

Version Path
playbook_ui-13.12.0.pre.alpha.PLAY880cardkithighlightzindex1655 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exportingtypes1627 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exportingtypes1626 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1624 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1623 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1612 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1611 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1609 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1081exporttypes1608 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1581 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1580 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1579 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1093typeaheadkitdocbug1577 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.play1051testhighcharts1574 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1567 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1558 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.play1051highchartstest1556 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.PLAY1051removinghighchartsdependency1551 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1550 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-13.12.0.pre.alpha.play900startratingasinput1543 app/pb_kits/playbook/pb_list/_list.tsx