applySpanStyles = (spanNode, { classNames, index, label }) => {
  if (classNames) {
    spanNode.className = "";
    spanNode.classList.add(...classNames);
  }

  // label is array, string or null, so check for length
  if (!label?.length) spanNode.removeAttribute("data-label");
  else spanNode.setAttribute("data-label", label);
  spanNode.setAttribute("data-index", index ? String(index) : "");
}
Apply classes and styles to a span. Optionally add or remove label
@param {HTMLSpanElement} spanNode
@param {{classNames?: string[], index?: number, label?: string}} param1