Sha256: 907d0b5788344c28327930947f6fb9e5c89f280aebf031cf1c5496fe65398e5c

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

/* eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */
import Highlighter from 'react-highlight-words'
import React from 'react'
import classnames from 'classnames'
import { globalProps, GlobalProps } from '../utilities/globalProps'
import { buildHtmlProps } from '../utilities/props'

type HighlightProps = {
  className?: string,
  data?: {[key: string]: string},
  htmlOptions?: {[key: string]: string | number | boolean | Function},
  id?: string,
  children?: React.ReactChild[] | React.ReactChild | string,
  text?: string,
  highlightedText?: string[],
} & GlobalProps

const Highlight = (props: HighlightProps): React.ReactElement => {
  const {
    children,
    className = 'pb_highlight_kit',
    data = {},
    highlightedText = ['highlight'],
    htmlOptions = {},
    id = '',
    text = '',
  } = props

  const htmlProps = buildHtmlProps(htmlOptions)
  const highlightContent: any = text || children;

  return (
    <Highlighter
        autoEscape
        data={data}
        highlightClassName={classnames(globalProps(props), className)}
        highlightTag="mark"
        id={id}
        searchWords={highlightedText}
        textToHighlight={highlightContent}
        {...htmlProps}
    />
  )
}

export default Highlight

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
playbook_ui-13.14.0.pre.alpha.PLAY1109bugdisplaypropblocksfontcolor1784 app/pb_kits/playbook/pb_highlight/_highlight.tsx
playbook_ui-13.14.0.pre.alpha.play1106filter1751 app/pb_kits/playbook/pb_highlight/_highlight.tsx
playbook_ui-13.14.0.pre.alpha.play1106filter1748 app/pb_kits/playbook/pb_highlight/_highlight.tsx
playbook_ui-13.14.0 app/pb_kits/playbook/pb_highlight/_highlight.tsx
playbook_ui-13.13.0.pre.alpha.PLAY1097linterenhancedelement1728 app/pb_kits/playbook/pb_highlight/_highlight.tsx
playbook_ui-13.13.0.pre.alpha.play10221678 app/pb_kits/playbook/pb_highlight/_highlight.tsx
playbook_ui-13.13.0.pre.alpha.PLAY1090csstokens1675 app/pb_kits/playbook/pb_highlight/_highlight.tsx
playbook_ui-13.13.0.pre.alpha.play900startratingasinput1657 app/pb_kits/playbook/pb_highlight/_highlight.tsx
playbook_ui-13.13.0 app/pb_kits/playbook/pb_highlight/_highlight.tsx
playbook_ui-13.12.0.pre.alpha.play10281596 app/pb_kits/playbook/pb_highlight/_highlight.tsx