<commit_before>import { appendIfMissing, selectionChanged }  from '@zambezi/d3-utils'
import { findIndex } from 'underscore'
import { select } from 'd3-selection'

const highlightContainer = appendIfMissing('div.selected-cells-highlight.zambezi-grid-overlay')

export function createHighlightSelectedCells() {

  let selectedCells = []
    , borderCache

  function highlightSelectedCells(s) {
    s.each(highlightSelectedCellsEach)
  }

  highlightSelectedCells.selectedCells = function(value) {
    if (!arguments.length) return selectedCells
    selectedCells = value
    borderCache = null
    return highlightSelectedCells
  }

  return highlightSelectedCells

  function highlightSelectedCellsEach(bundle) {
    const { columns, rows, scroll } = bundle
        , target = select(this)
              .on(
                'data-dirty.highlight-selected-cells',
                () => borderCache = null
              )
            .select(highlightContainer)
              .text('HIGHLIGHTCONTAINER')
              .style('transform', `translate(${-scroll.left}px, ${-scroll.top}px)`)


    if (!borderCache)  {
      console.log('compile border cache')
      borderCache = compileBorderLayout()
    }

    console.log('render border cache!', borderCache)

    function compileBorderLayout() {

      const rowToIndex = new Map()
          , columnToIndex = new Map()
          , selectedCellGrid = []
<commit_msg>Add cells highlight at the grid body level.<commit_after>import { appendIfMissing, selectionChanged }  from '@zambezi/d3-utils'
import { findIndex } from 'underscore'
import { select } from 'd3-selection'

const highlightContainer = appendIfMissing('div.selected-cells-highlight.zambezi-grid-overlay')

export function createHighlightSelectedCells() {

  let selectedCells = []
    , borderCache

  function highlightSelectedCells(s) {
    s.each(highlightSelectedCellsEach)
  }

  highlightSelectedCells.selectedCells = function(value) {
    if (!arguments.length) return selectedCells
    selectedCells = value
    borderCache = null
    return highlightSelectedCells
  }

  return highlightSelectedCells

  function highlightSelectedCellsEach(bundle) {
    const { columns, rows, scroll } = bundle
        , target = select(this)
              .on(
                'data-dirty.highlight-selected-cells',
                () => borderCache = null
              )
            .select('.zambezi-grid-body')
            .select(highlightContainer)
              .text('HIGHLIGHTCONTAINER')
              .style('transform', `translate(${-scroll.left}px, ${-scroll.top}px)`)

    if (!borderCache)  {
      console.log('compile border cache')
      borderCache = compileBorderLayout()
    }

    console.log('render border cache!', borderCache)

    function compileBorderLayout() {

      const rowToIndex = new Map()
          , columnToIndex = new Map()
          , selectedCellGrid = []

{'fraction_non_alphanumeric': 0.10430292598967297, 'fraction_numerical': 0.001376936316695353, 'mean_word_length': 2.9006711409395973, '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': '2207767', 'n_tokens_mistral': 821, 'n_tokens_neox': 757, 'n_words': 164}