<commit_before>import React, { ReactNode, useEffect, useRef } from 'react';

import { useTypeaheadContext } from '../../core/Context';

// IE doesn't seem to get the composite computed value (eg: 'padding',
// 'borderStyle', etc.), so generate these from the individual values.
function interpolateStyle(
  styles: CSSStyleDeclaration,
  attr: string,
  subattr = ''
): string {
  // Title-case the sub-attribute.
  if (subattr) {
    /* eslint-disable-next-line no-param-reassign */
    subattr = subattr.replace(subattr[0], subattr[0].toUpperCase());
  }

  return ['Top', 'Right', 'Bottom', 'Left']
    .map(
      (dir) => styles[`${attr}${dir}${subattr}` as keyof CSSStyleDeclaration]
    )
    .join(' ');
}

function copyStyles(inputNode: HTMLInputElement, hintNode: HTMLInputElement) {
  const inputStyle = window.getComputedStyle(inputNode);

  /* eslint-disable no-param-reassign */
  hintNode.style.borderStyle = interpolateStyle(inputStyle, 'border', 'style');
  hintNode.style.borderWidth = interpolateStyle(inputStyle, 'border', 'width');
  hintNode.style.fontSize = inputStyle.fontSize;
  hintNode.style.height = inputStyle.height;<commit_msg>Copy font-weight to hintNode (#719)<commit_after>import React, { ReactNode, useEffect, useRef } from 'react';

import { useTypeaheadContext } from '../../core/Context';

// IE doesn't seem to get the composite computed value (eg: 'padding',
// 'borderStyle', etc.), so generate these from the individual values.
function interpolateStyle(
  styles: CSSStyleDeclaration,
  attr: string,
  subattr = ''
): string {
  // Title-case the sub-attribute.
  if (subattr) {
    /* eslint-disable-next-line no-param-reassign */
    subattr = subattr.replace(subattr[0], subattr[0].toUpperCase());
  }

  return ['Top', 'Right', 'Bottom', 'Left']
    .map(
      (dir) => styles[`${attr}${dir}${subattr}` as keyof CSSStyleDeclaration]
    )
    .join(' ');
}

function copyStyles(inputNode: HTMLInputElement, hintNode: HTMLInputElement) {
  const inputStyle = window.getComputedStyle(inputNode);

  /* eslint-disable no-param-reassign */
  hintNode.style.borderStyle = interpolateStyle(inputStyle, 'border', 'style');
  hintNode.style.borderWidth = interpolateStyle(inputStyle, 'border', 'width');
  hintNode.style.fontSize = inputStyle.fontSize;
  hintNode.style.fontWeight = inputStyle.fontWeight;
  hintNode.style.height = inputStyle.height;
{'fraction_non_alphanumeric': 0.1493099121706399, 'fraction_numerical': 0.0029276453366792136, 'mean_word_length': 4.461187214611872, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5804387', 'n_tokens_mistral': 751, 'n_tokens_neox': 738, 'n_words': 171}