import * as React from 'react';
import OPLabel from 'src/view/op-label';
import { RenderProps, CodeProps } from 'src/types/op-table';

export default function Code(props: RenderProps) {
  const { value = '', options = {} } = props;
  const {
    lenLimit,
    maxLength,
    hightlightNum = 4,
    highlightLength,
    copyable = true,
  } = options as CodeProps;
  const maxLen = lenLimit || maxLength;
  const highlightLen = hightlightNum * -1 || highlightLength;

  return (
    <OPLabel
      label={value}
      maxLength={maxLen}
      highlightLength={highlightLen}
      copyable={copyable}
    />
  );
}
