{"version":3,"file":"sortable-table.mjs","sources":["../../../../src/moj/components/sortable-table/sortable-table.mjs"],"sourcesContent":["import { ConfigurableComponent } from 'govuk-frontend'\n\n/**\n * @augments {ConfigurableComponent<SortableTableConfig>}\n */\nexport class SortableTable extends ConfigurableComponent {\n  /**\n   * @param {Element | null} $root - HTML element to use for sortable table\n   * @param {SortableTableConfig} [config] - Sortable table config\n   */\n  constructor($root, config = {}) {\n    super($root, config)\n\n    const $head = $root?.querySelector('thead')\n    const $body = $root?.querySelector('tbody')\n\n    if (!$head || !$body) {\n      return this\n    }\n\n    this.$head = $head\n    this.$body = $body\n    this.$caption = this.$root.querySelector('caption')\n\n    this.$upArrow = `<svg width=\"22\" height=\"22\" focusable=\"false\" aria-hidden=\"true\" role=\"img\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M6.5625 15.5L11 6.63125L15.4375 15.5H6.5625Z\" fill=\"currentColor\"/>\n</svg>`\n    this.$downArrow = `<svg width=\"22\" height=\"22\" focusable=\"false\" aria-hidden=\"true\" role=\"img\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M15.4375 7L11 15.8687L6.5625 7L15.4375 7Z\" fill=\"currentColor\"/>\n</svg>`\n    this.$upDownArrow = `<svg width=\"22\" height=\"22\" focusable=\"false\" aria-hidden=\"true\" role=\"img\" viewBox=\"0 0 22 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M8.1875 9.5L10.9609 3.95703L13.7344 9.5H8.1875Z\" fill=\"currentColor\"/>\n<path d=\"M13.7344 12.0781L10.9609 17.6211L8.1875 12.0781H13.7344Z\" fill=\"currentColor\"/>\n</svg>`\n\n    this.$headings = this.$head\n      ? Array.from(this.$head.querySelectorAll('th'))\n      : []\n\n    this.createHeadingButtons()\n    this.updateCaption()\n    this.updateDirectionIndicators()\n    this.createStatusBox()\n    this.initialiseSortedColumn()\n\n    this.$head.addEventListener('click', this.onSortButtonClick.bind(this))\n  }\n\n  createHeadingButtons() {\n    for (const $heading of this.$headings) {\n      if ($heading.hasAttribute('aria-sort')) {\n        this.createHeadingButton($heading)\n      }\n    }\n  }\n\n  /**\n   * @param {HTMLTableCellElement} $heading\n   */\n  createHeadingButton($heading) {\n    const index = this.$headings.indexOf($heading)\n    const $button = document.createElement('button')\n\n    $button.setAttribute('type', 'button')\n    $button.setAttribute('data-index', `${index}`)\n    $button.textContent = $heading.textContent\n\n    $heading.textContent = ''\n    $heading.appendChild($button)\n  }\n\n  createStatusBox() {\n    this.$status = document.createElement('div')\n\n    this.$status.setAttribute('aria-atomic', 'true')\n    this.$status.setAttribute('aria-live', 'polite')\n    this.$status.setAttribute('class', 'govuk-visually-hidden')\n    this.$status.setAttribute('role', 'status')\n\n    this.$root.insertAdjacentElement('afterend', this.$status)\n  }\n\n  initialiseSortedColumn() {\n    const $rows = this.getTableRowsArray()\n\n    const $heading = this.$root.querySelector(\n      'th[aria-sort=\"ascending\"], th[aria-sort=\"descending\"]'\n    )\n    const $sortButton = $heading?.querySelector('button')\n    const sortDirection = $heading?.getAttribute('aria-sort')\n\n    const columnNumber = Number.parseInt(\n      $sortButton?.getAttribute('data-index') ?? '0',\n      10\n    )\n\n    if (\n      !$heading ||\n      !$sortButton ||\n      !(sortDirection === 'ascending' || sortDirection === 'descending')\n    ) {\n      return\n    }\n\n    const $sortedRows = this.sort($rows, columnNumber, sortDirection)\n    this.addRows($sortedRows)\n  }\n\n  /**\n   * @param {MouseEvent} event - Click event\n   */\n  onSortButtonClick(event) {\n    const $target = /** @type {HTMLElement} */ (event.target)\n    const $button = $target.closest('button')\n\n    if (\n      !$button ||\n      !($button instanceof HTMLButtonElement) ||\n      !$button.parentElement\n    ) {\n      return\n    }\n\n    const $heading = $button.parentElement\n    const sortDirection = $heading.getAttribute('aria-sort')\n\n    const columnNumber = Number.parseInt(\n      $button?.getAttribute('data-index') ?? '0',\n      10\n    )\n\n    const newSortDirection =\n      sortDirection === 'none' || sortDirection === 'descending'\n        ? 'ascending'\n        : 'descending'\n\n    const $rows = this.getTableRowsArray()\n    const $sortedRows = this.sort($rows, columnNumber, newSortDirection)\n\n    this.addRows($sortedRows)\n    this.removeButtonStates()\n    this.updateButtonState($button, newSortDirection)\n    this.updateDirectionIndicators()\n  }\n\n  updateCaption() {\n    if (!this.$caption) {\n      return\n    }\n\n    let assistiveText = this.$caption.querySelector('.govuk-visually-hidden')\n    if (assistiveText) {\n      return\n    }\n\n    assistiveText = document.createElement('span')\n    assistiveText.classList.add('govuk-visually-hidden')\n    assistiveText.textContent = ' (column headers with buttons are sortable).'\n\n    this.$caption.appendChild(assistiveText)\n  }\n\n  /**\n   * @param {HTMLButtonElement} $button\n   * @param {string} direction\n   */\n  updateButtonState($button, direction) {\n    if (!(direction === 'ascending' || direction === 'descending')) {\n      return\n    }\n\n    $button.parentElement.setAttribute('aria-sort', direction)\n    let message = this.config.statusMessage\n    message = message.replace(/%heading%/, $button.textContent)\n    message = message.replace(/%direction%/, this.config[`${direction}Text`])\n    this.$status.textContent = message\n  }\n\n  updateDirectionIndicators() {\n    for (const $heading of this.$headings) {\n      const $button = /** @type {HTMLButtonElement} */ (\n        $heading.querySelector('button')\n      )\n      if ($heading.hasAttribute('aria-sort') && $button) {\n        const direction = $heading.getAttribute('aria-sort')\n        $button.querySelector('svg')?.remove()\n\n        switch (direction) {\n          case 'ascending':\n            $button.insertAdjacentHTML('beforeend', this.$upArrow)\n            break\n          case 'descending':\n            $button.insertAdjacentHTML('beforeend', this.$downArrow)\n            break\n          default:\n            $button.insertAdjacentHTML('beforeend', this.$upDownArrow)\n        }\n      }\n    }\n  }\n\n  removeButtonStates() {\n    for (const $heading of this.$headings) {\n      $heading.setAttribute('aria-sort', 'none')\n    }\n  }\n\n  /**\n   * @param {HTMLTableRowElement[]} $rows\n   */\n  addRows($rows) {\n    for (const $row of $rows) {\n      this.$body.append($row)\n    }\n  }\n\n  getTableRowsArray() {\n    return Array.from(this.$body.querySelectorAll('tr'))\n  }\n\n  /**\n   * @param {HTMLTableRowElement[]} $rows\n   * @param {number} columnNumber\n   * @param {string} sortDirection\n   */\n  sort($rows, columnNumber, sortDirection) {\n    return $rows.sort(($rowA, $rowB) => {\n      const $tdA = $rowA.querySelectorAll('td, th')[columnNumber]\n      const $tdB = $rowB.querySelectorAll('td, th')[columnNumber]\n\n      if (\n        !$tdA ||\n        !$tdB ||\n        !($tdA instanceof HTMLElement) ||\n        !($tdB instanceof HTMLElement)\n      ) {\n        return 0\n      }\n\n      const valueA =\n        sortDirection === 'ascending'\n          ? this.getCellValue($tdA)\n          : this.getCellValue($tdB)\n\n      const valueB =\n        sortDirection === 'ascending'\n          ? this.getCellValue($tdB)\n          : this.getCellValue($tdA)\n\n      return !(typeof valueA === 'number' && typeof valueB === 'number')\n        ? valueA.toString().localeCompare(valueB.toString())\n        : valueA - valueB\n    })\n  }\n\n  /**\n   * @param {HTMLElement} $cell\n   */\n  getCellValue($cell) {\n    const val = $cell.getAttribute('data-sort-value') || $cell.innerHTML\n    const valAsNumber = Number(val)\n\n    return Number.isFinite(valAsNumber)\n      ? valAsNumber // Exclude invalid numbers, infinity etc\n      : val\n  }\n\n  /**\n   * Name for the component used when initialising using data-module attributes.\n   */\n  static moduleName = 'moj-sortable-table'\n\n  /**\n   * Sortable table config\n   *\n   * @type {SortableTableConfig}\n   */\n  static defaults = Object.freeze({\n    statusMessage: 'Sort by %heading% (%direction%)',\n    ascendingText: 'ascending',\n    descendingText: 'descending'\n  })\n\n  /**\n   * Sortable table config schema\n   *\n   * @satisfies {Schema<SortableTableConfig>}\n   */\n  static schema = Object.freeze(\n    /** @type {const} */ ({\n      properties: {\n        statusMessage: { type: 'string' },\n        ascendingText: { type: 'string' },\n        descendingText: { type: 'string' }\n      }\n    })\n  )\n}\n\n/**\n * Sortable table config\n *\n * @typedef {object} SortableTableConfig\n * @property {string} [statusMessage] - Status message\n * @property {string} [ascendingText] - Ascending text\n * @property {string} [descendingText] - Descending text\n */\n\n/**\n * @import { Schema } from 'govuk-frontend/dist/govuk/common/configuration.mjs'\n */\n"],"names":["SortableTable","ConfigurableComponent","constructor","$root","config","$head","querySelector","$body","$caption","$upArrow","$downArrow","$upDownArrow","$headings","Array","from","querySelectorAll","createHeadingButtons","updateCaption","updateDirectionIndicators","createStatusBox","initialiseSortedColumn","addEventListener","onSortButtonClick","bind","$heading","hasAttribute","createHeadingButton","index","indexOf","$button","document","createElement","setAttribute","textContent","appendChild","$status","insertAdjacentElement","_$sortButton$getAttri","$rows","getTableRowsArray","$sortButton","sortDirection","getAttribute","columnNumber","Number","parseInt","$sortedRows","sort","addRows","event","_$button$getAttribute","$target","target","closest","HTMLButtonElement","parentElement","newSortDirection","removeButtonStates","updateButtonState","assistiveText","classList","add","direction","message","statusMessage","replace","_$button$querySelecto","remove","insertAdjacentHTML","$row","append","$rowA","$rowB","$tdA","$tdB","HTMLElement","valueA","getCellValue","valueB","toString","localeCompare","$cell","val","innerHTML","valAsNumber","isFinite","moduleName","defaults","Object","freeze","ascendingText","descendingText","schema","properties","type"],"mappings":";;AAEA;AACA;AACA;AACO,MAAMA,aAAa,SAASC,qBAAqB,CAAC;AACvD;AACF;AACA;AACA;AACEC,EAAAA,WAAWA,CAACC,KAAK,EAAEC,MAAM,GAAG,EAAE,EAAE;AAC9B,IAAA,KAAK,CAACD,KAAK,EAAEC,MAAM,CAAC;IAEpB,MAAMC,KAAK,GAAGF,KAAK,IAAA,IAAA,GAAA,MAAA,GAALA,KAAK,CAAEG,aAAa,CAAC,OAAO,CAAC;IAC3C,MAAMC,KAAK,GAAGJ,KAAK,IAAA,IAAA,GAAA,MAAA,GAALA,KAAK,CAAEG,aAAa,CAAC,OAAO,CAAC;AAE3C,IAAA,IAAI,CAACD,KAAK,IAAI,CAACE,KAAK,EAAE;AACpB,MAAA,OAAO,IAAI;AACb,IAAA;IAEA,IAAI,CAACF,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACE,KAAK,GAAG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