vectis-ui 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/components/VAccordion/VAccordion.css +1 -1
  2. package/dist/components/VAccordion/VAccordion.d.ts +0 -6
  3. package/dist/components/VAccordion/VAccordion.js.map +1 -1
  4. package/dist/components/VAccordion/VAccordion.vue_vue_type_script_setup_true_lang.js +3 -8
  5. package/dist/components/VAccordion/VAccordion.vue_vue_type_script_setup_true_lang.js.map +1 -1
  6. package/dist/components/VAccordion/context.js.map +1 -1
  7. package/dist/components/VAvatar/VAvatar.d.ts +0 -3
  8. package/dist/components/VAvatar/VAvatar.js.map +1 -1
  9. package/dist/components/VAvatar/VAvatar.vue_vue_type_script_setup_true_lang.js +21 -27
  10. package/dist/components/VAvatar/VAvatar.vue_vue_type_script_setup_true_lang.js.map +1 -1
  11. package/dist/components/VAvatar/VAvatarGroup.d.ts +0 -6
  12. package/dist/components/VAvatar/VAvatarGroup.js.map +1 -1
  13. package/dist/components/VAvatar/VAvatarGroup.vue_vue_type_script_setup_true_lang.js +5 -19
  14. package/dist/components/VAvatar/VAvatarGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
  15. package/dist/components/VAvatar/context.d.ts +0 -1
  16. package/dist/components/VAvatar/context.js.map +1 -1
  17. package/dist/components/VButton/VButton.d.ts +0 -6
  18. package/dist/components/VButton/VButton.js.map +1 -1
  19. package/dist/components/VButton/VButton.vue_vue_type_script_setup_true_lang.js +11 -17
  20. package/dist/components/VButton/VButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  21. package/dist/components/VButton/VButtonGroup.d.ts +0 -6
  22. package/dist/components/VButton/VButtonGroup.js.map +1 -1
  23. package/dist/components/VButton/VButtonGroup.vue_vue_type_script_setup_true_lang.js +0 -7
  24. package/dist/components/VButton/VButtonGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
  25. package/dist/components/VButton/context.d.ts +0 -2
  26. package/dist/components/VButton/context.js.map +1 -1
  27. package/dist/components/VChip/VChip.d.ts +0 -3
  28. package/dist/components/VChip/VChip.js.map +1 -1
  29. package/dist/components/VChip/VChip.vue_vue_type_script_setup_true_lang.js +0 -6
  30. package/dist/components/VChip/VChip.vue_vue_type_script_setup_true_lang.js.map +1 -1
  31. package/dist/components/VColorInput/VColorInput.d.ts +0 -3
  32. package/dist/components/VColorInput/VColorInput.js.map +1 -1
  33. package/dist/components/VColorInput/VColorInput.vue_vue_type_script_setup_true_lang.js +60 -66
  34. package/dist/components/VColorInput/VColorInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
  35. package/dist/components/VCombobox/VCombobox.d.ts +0 -3
  36. package/dist/components/VCombobox/VCombobox.js.map +1 -1
  37. package/dist/components/VCombobox/VCombobox.vue_vue_type_script_setup_true_lang.js +127 -138
  38. package/dist/components/VCombobox/VCombobox.vue_vue_type_script_setup_true_lang.js.map +1 -1
  39. package/dist/components/VContextMenu/VContextMenu.d.ts +0 -3
  40. package/dist/components/VContextMenu/VContextMenu.js.map +1 -1
  41. package/dist/components/VContextMenu/VContextMenu.vue_vue_type_script_setup_true_lang.js +0 -6
  42. package/dist/components/VContextMenu/VContextMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  43. package/dist/components/VDataTable/VDataTable.css +1 -1
  44. package/dist/components/VDataTable/VDataTable.d.ts +0 -2
  45. package/dist/components/VDataTable/VDataTable.js.map +1 -1
  46. package/dist/components/VDataTable/VDataTable.vue_vue_type_script_setup_true_lang.js +69 -84
  47. package/dist/components/VDataTable/VDataTable.vue_vue_type_script_setup_true_lang.js.map +1 -1
  48. package/dist/components/VDateInput/VDateInput.d.ts +0 -3
  49. package/dist/components/VDateInput/VDateInput.js.map +1 -1
  50. package/dist/components/VDateInput/VDateInput.vue_vue_type_script_setup_true_lang.js +32 -37
  51. package/dist/components/VDateInput/VDateInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
  52. package/dist/components/VFileInput/VFileInput.d.ts +0 -5
  53. package/dist/components/VFileInput/VFileInput.js.map +1 -1
  54. package/dist/components/VFileInput/VFileInput.vue_vue_type_script_setup_true_lang.js +75 -86
  55. package/dist/components/VFileInput/VFileInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
  56. package/dist/components/VHotkeys/VHotkeys.d.ts +0 -3
  57. package/dist/components/VHotkeys/VHotkeys.js.map +1 -1
  58. package/dist/components/VHotkeys/VHotkeys.vue_vue_type_script_setup_true_lang.js +0 -6
  59. package/dist/components/VHotkeys/VHotkeys.vue_vue_type_script_setup_true_lang.js.map +1 -1
  60. package/dist/components/VIconButton/VIconButton.d.ts +0 -3
  61. package/dist/components/VIconButton/VIconButton.js.map +1 -1
  62. package/dist/components/VIconButton/VIconButton.vue_vue_type_script_setup_true_lang.js +0 -6
  63. package/dist/components/VIconButton/VIconButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  64. package/dist/components/VInput/VInput.css +1 -1
  65. package/dist/components/VInput/VInput.d.ts +0 -3
  66. package/dist/components/VInput/VInput.js.map +1 -1
  67. package/dist/components/VInput/VInput.vue_vue_type_script_setup_true_lang.js +18 -24
  68. package/dist/components/VInput/VInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
  69. package/dist/components/VInput/VInputGroup.d.ts +0 -3
  70. package/dist/components/VInput/VInputGroup.js.map +1 -1
  71. package/dist/components/VInput/VInputGroup.vue_vue_type_script_setup_true_lang.js +0 -7
  72. package/dist/components/VInput/VInputGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
  73. package/dist/components/VInput/context.d.ts +0 -2
  74. package/dist/components/VInput/context.js.map +1 -1
  75. package/dist/components/VInputOTP/VInputOTP.d.ts +0 -3
  76. package/dist/components/VInputOTP/VInputOTP.js.map +1 -1
  77. package/dist/components/VInputOTP/VInputOTP.vue_vue_type_script_setup_true_lang.js +0 -6
  78. package/dist/components/VInputOTP/VInputOTP.vue_vue_type_script_setup_true_lang.js.map +1 -1
  79. package/dist/components/VListbox/VListboxPanel.d.ts +0 -3
  80. package/dist/components/VListbox/VListboxPanel.js.map +1 -1
  81. package/dist/components/VListbox/VListboxPanel.vue_vue_type_script_setup_true_lang.js +0 -6
  82. package/dist/components/VListbox/VListboxPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
  83. package/dist/components/VListbox/VListboxValues.js.map +1 -1
  84. package/dist/components/VListbox/VListboxValues.vue_vue_type_script_setup_true_lang.js +4 -14
  85. package/dist/components/VListbox/VListboxValues.vue_vue_type_script_setup_true_lang.js.map +1 -1
  86. package/dist/components/VMenu/VMenu.d.ts +0 -3
  87. package/dist/components/VMenu/VMenu.js.map +1 -1
  88. package/dist/components/VMenu/VMenu.vue_vue_type_script_setup_true_lang.js +0 -6
  89. package/dist/components/VMenu/VMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  90. package/dist/components/VMenu/VMenuPanel.d.ts +0 -3
  91. package/dist/components/VMenu/VMenuPanel.js.map +1 -1
  92. package/dist/components/VMenu/VMenuPanel.vue_vue_type_script_setup_true_lang.js +0 -6
  93. package/dist/components/VMenu/VMenuPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
  94. package/dist/components/VNumberInput/VNumberInput.d.ts +0 -3
  95. package/dist/components/VNumberInput/VNumberInput.js.map +1 -1
  96. package/dist/components/VNumberInput/VNumberInput.vue_vue_type_script_setup_true_lang.js +0 -6
  97. package/dist/components/VNumberInput/VNumberInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
  98. package/dist/components/VPagination/VPagination.d.ts +0 -3
  99. package/dist/components/VPagination/VPagination.js.map +1 -1
  100. package/dist/components/VPagination/VPagination.vue_vue_type_script_setup_true_lang.js +0 -6
  101. package/dist/components/VPagination/VPagination.vue_vue_type_script_setup_true_lang.js.map +1 -1
  102. package/dist/components/VSelect/VSelect.d.ts +0 -3
  103. package/dist/components/VSelect/VSelect.js.map +1 -1
  104. package/dist/components/VSelect/VSelect.vue_vue_type_script_setup_true_lang.js +114 -123
  105. package/dist/components/VSelect/VSelect.vue_vue_type_script_setup_true_lang.js.map +1 -1
  106. package/dist/components/VSideNavigation/VSideNavigation.d.ts +0 -6
  107. package/dist/components/VSideNavigation/VSideNavigation.js.map +1 -1
  108. package/dist/components/VSideNavigation/VSideNavigation.vue_vue_type_script_setup_true_lang.js +1 -10
  109. package/dist/components/VSideNavigation/VSideNavigation.vue_vue_type_script_setup_true_lang.js.map +1 -1
  110. package/dist/components/VSideNavigation/context.js.map +1 -1
  111. package/dist/components/VSkeletonLoader/VSkeletonLoader.d.ts +0 -3
  112. package/dist/components/VSkeletonLoader/VSkeletonLoader.js.map +1 -1
  113. package/dist/components/VSkeletonLoader/VSkeletonLoader.vue_vue_type_script_setup_true_lang.js +0 -6
  114. package/dist/components/VSkeletonLoader/VSkeletonLoader.vue_vue_type_script_setup_true_lang.js.map +1 -1
  115. package/dist/components/VSlider/VSlider.js.map +1 -1
  116. package/dist/components/VSlider/VSlider.vue_vue_type_script_setup_true_lang.js +115 -120
  117. package/dist/components/VSlider/VSlider.vue_vue_type_script_setup_true_lang.js.map +1 -1
  118. package/dist/components/VSplitButton/VSplitButton.d.ts +0 -3
  119. package/dist/components/VSplitButton/VSplitButton.js.map +1 -1
  120. package/dist/components/VSplitButton/VSplitButton.vue_vue_type_script_setup_true_lang.js +0 -6
  121. package/dist/components/VSplitButton/VSplitButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  122. package/dist/components/VTabs/VTab.js.map +1 -1
  123. package/dist/components/VTabs/VTab.vue_vue_type_script_setup_true_lang.js +0 -2
  124. package/dist/components/VTabs/VTab.vue_vue_type_script_setup_true_lang.js.map +1 -1
  125. package/dist/components/VTabs/VTabs.css +1 -1
  126. package/dist/components/VTabs/VTabs.d.ts +0 -3
  127. package/dist/components/VTabs/VTabs.js.map +1 -1
  128. package/dist/components/VTabs/VTabs.vue_vue_type_script_setup_true_lang.js +2 -15
  129. package/dist/components/VTabs/VTabs.vue_vue_type_script_setup_true_lang.js.map +1 -1
  130. package/dist/components/VTabs/context.d.ts +0 -2
  131. package/dist/components/VTabs/context.js.map +1 -1
  132. package/dist/components/VTextarea/VTextarea.d.ts +0 -6
  133. package/dist/components/VTextarea/VTextarea.js.map +1 -1
  134. package/dist/components/VTextarea/VTextarea.vue_vue_type_script_setup_true_lang.js +0 -6
  135. package/dist/components/VTextarea/VTextarea.vue_vue_type_script_setup_true_lang.js.map +1 -1
  136. package/dist/components/VTimeInput/VTimeInput.d.ts +0 -3
  137. package/dist/components/VTimeInput/VTimeInput.js.map +1 -1
  138. package/dist/components/VTimeInput/VTimeInput.vue_vue_type_script_setup_true_lang.js +211 -218
  139. package/dist/components/VTimeInput/VTimeInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
  140. package/dist/components/VToggle/VToggle.d.ts +0 -3
  141. package/dist/components/VToggle/VToggle.js.map +1 -1
  142. package/dist/components/VToggle/VToggle.vue_vue_type_script_setup_true_lang.js +0 -6
  143. package/dist/components/VToggle/VToggle.vue_vue_type_script_setup_true_lang.js.map +1 -1
  144. package/dist/components/VToggle/VToggleItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
  145. package/dist/composables/useControlShape.d.ts +1 -5
  146. package/dist/composables/useControlShape.js +0 -1
  147. package/dist/composables/useControlShape.js.map +1 -1
  148. package/dist/composables/useListbox.d.ts +0 -1
  149. package/dist/composables/useListbox.js +1 -1
  150. package/dist/composables/useListbox.js.map +1 -1
  151. package/dist/styles.css +1 -1
  152. package/dist/tokens/index.d.ts +3 -0
  153. package/dist/tokens/semantic.d.ts +3 -0
  154. package/dist/tokens/semantic.js +6 -5
  155. package/dist/tokens/semantic.js.map +1 -1
  156. package/dist/tokens.json +12 -5
  157. package/dist/types.d.ts +0 -2
  158. package/dist/utils/chip.d.ts +4 -6
  159. package/dist/utils/chip.js +8 -5
  160. package/dist/utils/chip.js.map +1 -1
  161. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"VDataTable.js","names":["_sfc_main","VDataTable_vue_vue_type_script_setup_true_lang_default","VDataTable_default"],"sources":["../../../src/components/VDataTable/VDataTable.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"Row extends Record<string, unknown>\">\n// @core\n/**\n * Native table semantics remain intact. JavaScript adds sorting, paging, selection and\n * debounced search; browser measurements stay in browser tests.\n */\n\nimport { computed, ref, useId, useSlots, watch, watchEffect } from 'vue'\nimport type { StyleValue } from 'vue'\n\nimport VButton from '../VButton/VButton.vue'\nimport VCheckbox from '../VCheckbox/VCheckbox.vue'\nimport VEmptyState from '../VEmptyState/VEmptyState.vue'\nimport VIcon from '../VIcon/VIcon.vue'\nimport { iconProps } from '../VIcon/iconProps'\nimport { arrow_downward as arrowDownwardIcon } from '../VIcon/icons/arrow_downward'\nimport { arrow_drop_down as arrowDropDownIcon } from '../VIcon/icons/arrow_drop_down'\nimport { arrow_upward as arrowUpwardIcon } from '../VIcon/icons/arrow_upward'\nimport { inbox as inboxIcon } from '../VIcon/icons/inbox'\nimport { search as searchIcon } from '../VIcon/icons/search'\nimport { search_off as searchOffIcon } from '../VIcon/icons/search_off'\nimport { swap_vert as swapVertIcon } from '../VIcon/icons/swap_vert'\nimport type { IconSource } from '../VIcon/types'\nimport VInput from '../VInput/VInput.vue'\nimport VMenu from '../VMenu/VMenu.vue'\nimport VMenuItem from '../VMenu/VMenuItem.vue'\nimport VPagination from '../VPagination/VPagination.vue'\nimport VSpinner from '../VSpinner/VSpinner.vue'\nimport VTypography from '../VTypography/VTypography.vue'\n\nimport { toggleValue } from '../../utils/array'\nimport { cssSize } from '../../utils/css'\nimport { isDev } from '../../utils/env'\nimport { clamp } from '../../utils/number'\nimport { createNormalizedCache, normalizeText } from '../../utils/text'\n\nimport { useInfiniteScroll } from '../../composables/useInfiniteScroll'\nimport { useRootAttrs } from '../../composables/useRootAttrs'\nimport { useVirtualList, type VirtualSegment } from '../../composables/useVirtualList'\n\nimport { useTimer } from '../../composables/useTimer'\nimport { useLocale, useMessages } from '../../i18n/state'\n\n/** How a column's content is aligned. */\nexport type DataTableColumnAlign = 'start' | 'center' | 'end'\n\n/** One column of the table. */\nexport interface DataTableColumn {\n /** Which field of a row it shows, and the name its slots are addressed by. */\n key: string\n /** Its heading. */\n label: string\n /** Lets the reader sort by this column. */\n sortable?: boolean\n /** How its content is aligned. Numbers usually belong at the end. */\n align?: DataTableColumnAlign\n}\n\n/** Which way a column is sorted: A to Z, or Z to A. */\nexport type DataTableSortDirection = 'asc' | 'desc'\n\n/** Which column the table is sorted by, and in which direction. */\nexport interface DataTableSort {\n /** The `key` of the column the rows are ordered by. */\n key: string\n /** Which way they are ordered. */\n direction: DataTableSortDirection\n}\n\n/** How a row is identified: by the field named in `rowKey`, or failing that by its position. */\nexport type DataTableRowId = string | number\n\n/**\n * Everything the table is currently being asked for, reported whenever it changes so a\n * server can answer it. What is not set is `null` rather than left out, so the object keeps\n * the same keys once serialized into a request.\n */\nexport interface DataTableParams {\n /** The page asked for, from 1. */\n page: number\n /** How many rows a page holds, `null` when the table is not paginated. */\n perPage: number | null\n /** The `key` of the sorted column, `null` when the rows are not sorted. */\n sortKey: string | null\n /** Which way they are sorted, `null` when they are not. */\n sortDirection: DataTableSortDirection | null\n /** The committed search, empty when nothing is searched for. */\n search: string\n}\n\n/** What the `cell-<key>` slots receive. */\nexport interface DataTableCellSlotProps<Row extends Record<string, unknown>> {\n /** The row the cell belongs to. */\n row: Row\n /** The value of the column's field in that row. */\n value: unknown\n /** The column the cell belongs to. */\n column: DataTableColumn\n}\n\n/** What the `head-<key>` slots receive. */\nexport interface DataTableHeadSlotProps {\n /** The column the heading belongs to. */\n column: DataTableColumn\n}\n\n/** What the `#empty` slot receives. */\nexport interface DataTableEmptySlotProps {\n /** The search that produced the empty result, empty when nothing was searched for. */\n search: string\n}\n\n/** The rows on show, as `rangeText` receives them, counted from 1. */\nexport interface DataTableRange {\n /** The position of the first row on show. */\n start: number\n /** The position of the last row on show. */\n end: number\n /** How many rows there are in all. */\n total: number\n}\n\n/** How the rows are set off from the page: nothing, a border, a shadow, or a muted fill. */\nexport type DataTableVariant = 'flat' | 'outline' | 'elevated' | 'filled'\n\n// This interface is exported rather than kept local, and it is generic rather than referring to\n// the component's own type parameter. A component typed over its rows inlines the whole\n// signature of its props into the declarations it emits, so a name that is not exported cannot\n// be written there and the build of the type declarations fails.\nexport interface DataTableProps<Row extends Record<string, unknown>> {\n /** The columns to show, in order. */\n columns: DataTableColumn[]\n /** The rows to show. */\n rows: Row[]\n /** Which field identifies a row. */\n rowKey?: string\n /**\n * How the rows and the footer are framed: nothing at all (`flat`, the default), or a card\n * with rounded corners set off by a border on the page surface (`outline`), a shadow over a\n * raised surface (`elevated`), or a muted fill (`filled`). The header and the toolbar stay\n * outside the frame.\n */\n variant?: DataTableVariant\n /** Shows that the rows are being loaded. */\n loading?: boolean\n /**\n * What is written beside the spinner while the rows are loading. It falls back to the design\n * system dictionary.\n */\n loadingText?: string\n /**\n * The title of the empty state shown when there is no row to show. It falls back to the design\n * system dictionary, which words a table with no data and a search with no match differently.\n */\n emptyText?: string\n /**\n * A title above the table, which also names it for assistive technology. It is ignored when\n * the `#header` slot replaces the title and subtitle.\n */\n title?: string\n /**\n * A line under the title saying what the table holds. It also describes the table for\n * assistive technology.\n */\n subtitle?: string\n /** Adds a search field to the header. */\n searchable?: boolean\n /** What that field says while empty. It falls back to the design system dictionary. */\n searchPlaceholder?: string\n /**\n * What screen readers announce for the search field. It falls back to the design\n * system dictionary.\n */\n searchLabel?: string\n /**\n * When a server does the searching, how long to wait after a keystroke before asking\n * it, in milliseconds. Zero asks at once.\n */\n searchDebounce?: number\n /** Tints every other row, which helps the eye follow a long line across the table. */\n striped?: boolean\n /**\n * Keeps the column headings in place while the rows scroll under them. It needs a\n * bounded scrolling area to work: either the `height` prop, or a parent with a height\n * of its own.\n */\n stickyHeader?: boolean\n /** Tightens the cells by one step, and everything the table renders with them. */\n compact?: boolean\n /**\n * The height of the whole component, header, toolbar and pagination included: a number is read as\n * pixels, anything else as a CSS length. Left out, the table takes its parent's height\n * whenever the parent has one.\n */\n height?: number | string\n /** The heading icon of a column that can be sorted but currently is not. */\n sortIcon?: IconSource\n /**\n * The icon of an ascending sort. It points DOWN by default, the spreadsheet\n * convention: sorting A to Z reads downwards.\n */\n sortAscIcon?: IconSource\n /** The icon of a descending sort. */\n sortDescIcon?: IconSource\n /** The choices offered for how many rows a page holds. */\n perPageOptions?: number[]\n /** What that choice is called. It falls back to the design system dictionary. */\n perPageText?: string\n /**\n * How many rows there are in all on the server. It is what lets the pagination and the\n * range be right when the table only ever holds one page.\n */\n total?: number\n /** Shows which rows are being looked at (\"1–10 of 42\") in the footer. */\n showRange?: boolean\n /** Rephrases that range. It falls back to the design system dictionary. */\n rangeText?: (range: DataTableRange) => string\n /** Adds a checkbox to every row, and one in the heading to take the whole page. */\n selectable?: boolean\n /**\n * What the heading checkbox is announced as. It falls back to the design system\n * dictionary.\n */\n selectAllLabel?: string\n /**\n * How the selection is summed up in the footer. It says nothing at all when nothing is\n * selected, and falls back to the design system dictionary.\n */\n selectionText?: (count: number) => string\n /**\n * What a row's checkbox is announced as. \"Select row\" tells a screen reader user nothing\n * about WHICH row, so this is worth supplying with something from the row itself. It falls\n * back to the design system dictionary, which numbers the rows from 1.\n */\n selectRowLabel?: (row: Row, index: number) => string\n /**\n * Hands the searching, the sorting and the paging over to a server: the rows are shown\n * exactly as they arrive, and every change of what is being asked for is reported so\n * the server can answer it.\n */\n serverSide?: boolean\n /**\n * Renders only the rows near the visible part of the table, for tables of thousands of rows.\n * It needs a bounded height, like `stickyHeader`. Rows are measured as they render, so they\n * may vary in height, and each one is announced with its place in the whole table.\n */\n virtual?: boolean\n /**\n * Says that more rows are to come, which makes the table ask for them through `load-more` as\n * the end of its rows comes into view. While `loading`, the rows already there stay on show.\n */\n hasMore?: boolean\n}\n\nconst props = withDefaults(defineProps<DataTableProps<Row>>(), {\n rowKey: undefined,\n variant: 'flat',\n loading: false,\n loadingText: undefined,\n emptyText: undefined,\n title: undefined,\n subtitle: undefined,\n searchable: false,\n searchPlaceholder: undefined,\n searchLabel: undefined,\n searchDebounce: 250,\n striped: false,\n stickyHeader: false,\n compact: false,\n height: undefined,\n sortIcon: () => swapVertIcon,\n sortAscIcon: () => arrowDownwardIcon,\n sortDescIcon: () => arrowUpwardIcon,\n perPageOptions: undefined,\n perPageText: undefined,\n total: undefined,\n showRange: false,\n rangeText: undefined,\n selectable: false,\n selectAllLabel: undefined,\n selectionText: undefined,\n selectRowLabel: undefined,\n serverSide: false,\n virtual: false,\n hasMore: false,\n})\n\nconst m = useMessages()\nconst vectisLocale = useLocale()\nconst resolvedLoadingText = computed(() => props.loadingText ?? m.value.dataTable.loading)\nconst resolvedSearchPlaceholder = computed(\n () => props.searchPlaceholder ?? m.value.dataTable.searchPlaceholder,\n)\nconst resolvedSearchLabel = computed(() => props.searchLabel ?? m.value.dataTable.searchLabel)\nconst resolvedPerPageText = computed(() => props.perPageText ?? m.value.dataTable.perPage)\nconst resolvedSelectAllLabel = computed(() => props.selectAllLabel ?? m.value.dataTable.selectAll)\n\n/** Which column the rows are sorted by, and in which direction. */\nconst sort = defineModel<DataTableSort | null>('sort', { default: null })\n/** The page being shown, counted from 1. */\nconst page = defineModel<number>('page', { default: 1 })\n/**\n * How many rows a page holds. Any value above zero turns the pagination on, so passing\n * one down without binding it is enough to enable it.\n */\nconst perPage = defineModel<number | undefined>('perPage', { default: undefined })\n/*\n * `sort` is `null` because the TABLE writes that state itself, a third click on a heading\n * clearing the order, and a model the component writes needs a value a consumer can store and\n * compare. `perPage` is `undefined` because nothing here ever clears it: it is simply a model\n * that was not given.\n */\n/** The selected rows, as the identities `rowKey` gives them, never the row objects themselves. */\nconst selected = defineModel<DataTableRowId[]>('selected', { default: () => [] })\n/**\n * What is typed in the search field, empty to begin with. Only the declared columns are\n * searched, accent- and case-insensitively; in `serverSide` mode nothing is filtered here\n * and the term is reported through `update:params` instead.\n */\nconst search = defineModel<string>('search', { default: '' })\n\nconst emit = defineEmits<{\n /**\n * What the table is now being asked for, when a server is answering: the page, the page size,\n * the sort or the search has changed, the last one after its delay.\n */\n 'update:params': [params: DataTableParams]\n /** The end of the rows has come into view while `hasMore` is set: send the next ones. */\n 'load-more': []\n}>()\n\ndefineSlots<{\n /** What a cell of a given column shows: a slot named after that column's key. */\n [name: `cell-${string}`]: (scope: DataTableCellSlotProps<Row>) => unknown\n /** What a column's heading shows: a slot named after that column's key. */\n [name: `head-${string}`]: (scope: DataTableHeadSlotProps) => unknown\n /**\n * Replaces the title and subtitle with content of your own; the search field stays beside it.\n * Name the table with `aria-label` or `aria-labelledby` then.\n */\n header?(): unknown\n /** A row between the header and the table, for actions and filters. */\n toolbar?(): unknown\n /** What the table shows while its rows are loading, replacing the spinner and its text. */\n loading?(): unknown\n /**\n * What the table shows when there is no row to show, replacing `emptyText`. It receives the\n * search that produced the empty result, empty when nothing was searched for.\n */\n empty?(scope: DataTableEmptySlotProps): unknown\n}>()\n\n// `class` and `style` stay on the wrapper, where a consumer expects to place the component;\n// everything else; an id, the aria-*; goes to the `<table>` itself, the only element they\n// validly describe.\ndefineOptions({ inheritAttrs: false })\nconst { attrs, rootClass, rootStyle, forwardedAttrs } = useRootAttrs()\nconst slots = useSlots()\n\n// A template ref on the component reaches the wrapper, a layout box; the `<table>` is where\n// the consumer's attributes land and what they describe.\nconst tableEl = ref<HTMLTableElement | null>(null)\ndefineExpose({\n /** The `<table>` element, where the consumer's attributes land. */\n el: tableEl,\n})\n\n// @a11y\n/*\n * The title names the table unless the `#header` slot replaced it, or the consumer named the\n * table, whose own `aria-label` a reference to the title would override. Bound before the\n * forwarded attributes, like every state the component owns.\n */\nconst titleId = useId()\nconst subtitleId = useId()\nconst namedByConsumer = () =>\n attrs['aria-label'] !== undefined || attrs['aria-labelledby'] !== undefined\nconst tableLabelledBy = computed(() =>\n props.title && !slots.header && !namedByConsumer() ? titleId : undefined,\n)\nconst tableDescribedBy = computed(() => (props.subtitle && !slots.header ? subtitleId : undefined))\n\n// @devwarn\nif (isDev) {\n if (!tableLabelledBy.value && !namedByConsumer())\n console.warn(\n '[VDataTable] the table has no accessible name: set `title`, or aria-label or aria-labelledby when the `#header` slot replaces it.',\n )\n if (props.selectable && !props.rowKey)\n console.warn(\n '[VDataTable] `selectable` without `rowKey` — index-based identities are corrupted by sorting, filtering and pagination.',\n )\n /*\n * A key that is missing, or not a string or a number, turns into the same text on every\n * row (\"undefined\"), and two rows sharing a key share an identity: ticking one ticks them\n * all, and the rows' own `:key`s collide. Once per instance and per kind.\n */\n const warned = new Set<string>()\n watchEffect(() => {\n const key = props.rowKey\n if (!key) return\n const seen = new Set<unknown>()\n for (const row of props.rows) {\n const value = row[key]\n if (typeof value !== 'string' && typeof value !== 'number') {\n if (!warned.has('type')) {\n warned.add('type')\n console.warn(\n `[VDataTable] \\`rowKey\\` \"${key}\" is missing or is not a string or a number on some rows: those rows share one identity.`,\n )\n }\n } else if (seen.has(value)) {\n if (!warned.has('duplicate')) {\n warned.add('duplicate')\n console.warn(\n `[VDataTable] \\`rowKey\\` \"${key}\" holds the value \"${value}\" twice: rows are told apart by it, so it must be unique.`,\n )\n }\n } else seen.add(value)\n }\n })\n}\n\n/*\n * A key that is already a string or a number is returned AS IT IS. The selection holds these\n * identities and is looked up with a Set, which tells the number 7 from the string \"7\": turned\n * into text, a table keyed by numeric ids never found a selected row again, so every checkbox\n * stayed unticked.\n */\nfunction rowIdentity(row: Row, index: number): DataTableRowId {\n if (!props.rowKey) return index\n const key = row[props.rowKey]\n return typeof key === 'string' || typeof key === 'number' ? key : String(key)\n}\n\n// Searching fields the reader cannot see would return rows for reasons nothing on screen\n// explains.\n/*\n * The filter below re-reads the whole table on every keystroke: ten thousand rows across five\n * columns is fifty thousand normalizations per character typed without it.\n */\nconst normalizedOf = createNormalizedCache<Row>()\nconst normalizedCell = (row: Row, key: string) => normalizedOf(row, String(row[key] ?? ''), key)\n\nconst filteredRows = computed(() => {\n if (props.serverSide || !props.searchable) return props.rows\n const needle = normalizeText((search.value ?? '').trim())\n if (!needle) return props.rows\n return props.rows.filter((row) =>\n props.columns.some((column) => normalizedCell(row, column.key).includes(needle)),\n )\n})\n\n/*\n * The locale must nonetheless stay EXPLICIT: an `undefined` one resolves differently in Node\n * and in the browser, so the row order would diverge across hydration.\n */\nconst collator = computed(() => new Intl.Collator(vectisLocale.value, { numeric: true }))\n\n/*\n * What a cell is compared by. A `Date` by its instant: as text it collates on `toString()`,\n * which opens with the WEEKDAY, so Monday the 5th sorted before Saturday the 3rd.\n */\nconst NUMERIC_TEXT = /^\\s*[+-]?(\\d+\\.?\\d*|\\.\\d+)(e[+-]?\\d+)?\\s*$/i\nfunction sortKey(value: unknown): unknown {\n if (value instanceof Date) return value.getTime()\n if (typeof value === 'string' && NUMERIC_TEXT.test(value)) return Number(value)\n return value\n}\n\nconst sortedRows = computed(() => {\n const current = sort.value\n if (!current || props.serverSide) return filteredRows.value\n const factor = current.direction === 'asc' ? 1 : -1\n const compare = collator.value.compare\n return [...filteredRows.value].sort((a, b) => {\n const av = sortKey(a[current.key])\n const bv = sortKey(b[current.key])\n if (typeof av === 'number' && typeof bv === 'number') return (av - bv) * factor\n return compare(String(av ?? ''), String(bv ?? '')) * factor\n })\n})\n\nconst paginated = computed(() => (perPage.value ?? 0) > 0)\nconst totalCount = computed(() =>\n props.serverSide ? (props.total ?? props.rows.length) : filteredRows.value.length,\n)\nconst pageCount = computed(() =>\n paginated.value ? Math.max(1, Math.ceil(totalCount.value / (perPage.value ?? 1))) : 1,\n)\n// The page actually shown is CLAMPED by derivation and the model is never rewritten: a\n// search that leaves fewer pages simply falls back to the last one, and typing a\n// character that would have emptied the table does not silently move the consumer's own\n// page number.\nconst currentPage = computed(() => clamp(page.value, 1, pageCount.value))\n\nconst displayedRows = computed(() => {\n // With a server answering, the rows received ARE the current page: cutting them again\n // would show a tenth of a page.\n if (props.serverSide || !paginated.value) return sortedRows.value\n const start = (currentPage.value - 1) * (perPage.value ?? 0)\n return sortedRows.value.slice(start, start + (perPage.value ?? 0))\n})\n\nfunction toggleSort(key: string) {\n const current = sort.value\n if (!current || current.key !== key) sort.value = { key, direction: 'asc' }\n else if (current.direction === 'asc') sort.value = { key, direction: 'desc' }\n else sort.value = null\n}\n\n// @a11y\n// Only the column actually sorted carries the attribute. Setting it on every heading would have a screen reader announce \"not sorted\" on each one in turn, drowning\n// the single piece of information that matters: which column the order comes from.\nfunction ariaSort(column: DataTableColumn): 'ascending' | 'descending' | undefined {\n if (sort.value?.key !== column.key) return undefined\n return sort.value.direction === 'asc' ? 'ascending' : 'descending'\n}\n\n/**\n * Which icon a column's heading shows: a neutral one on any sortable column, and the\n * arrow of the current direction on the one being sorted by.\n *\n * It is deliberately named differently from the prop it falls back to: written the same,\n * the function would shadow the prop inside the template and the icons would never be\n * overridable.\n */\nfunction sortIconFor(column: DataTableColumn): IconSource {\n if (sort.value?.key !== column.key) return props.sortIcon\n return sort.value.direction === 'asc' ? props.sortAscIcon : props.sortDescIcon\n}\n\n// With `serverSide`, the search reaches the server only once the reader pauses: nothing native\n// waits before asking. The term actually committed is what the parameters below report.\nconst committedSearch = ref(search.value)\nconst searchTimer = useTimer()\n\nfunction commitSearch() {\n // A term typed and erased inside the debounce is no new search: going back to page 1\n // and asking the server again would be a request for what is already on screen.\n if (search.value === committedSearch.value) return\n committedSearch.value = search.value\n page.value = 1\n}\n\nwatch(search, () => {\n if (!props.serverSide) {\n page.value = 1\n return\n }\n searchTimer.start(commitSearch, props.searchDebounce)\n})\n\nconst emptySearch = computed(() => (props.serverSide ? committedSearch.value : search.value))\n/** The title of the empty state: a table with no data does not read like a search with no match. */\nconst resolvedEmptyText = computed(\n () =>\n props.emptyText ?? (emptySearch.value ? m.value.dataTable.noResults : m.value.dataTable.empty),\n)\n\n/*\n * `page` is the model, never the clamped `currentPage`. The clamp reads `total`, which is the\n * server's own answer: read here, a response that changed the total would move the parameters\n * and ask for the page again, and a consumer clearing `total` while it loads would send the\n * reader back to page 1.\n */\n// Committing a search and going back to the first page happen one after the other, but both\n// land in the same flush, so this runs once on the final values; never two requests for what\n// the reader experienced as a single action. Compared by value: a parent handing down an equal\n// `sort` object is no new request.\nwatch(\n [\n page,\n () => perPage.value ?? null,\n () => sort.value?.key ?? null,\n () => sort.value?.direction ?? null,\n committedSearch,\n ],\n ([page, perPage, sortKey, sortDirection, search]) => {\n if (props.serverSide) emit('update:params', { page, perPage, sortKey, sortDirection, search })\n },\n)\n\n// The selection. The heading checkbox covers the rows currently VISIBLE and not the whole\n// table: a box that silently selected forty thousand rows would be a trap.\nconst selectedSet = computed(() => new Set<DataTableRowId>(selected.value))\nconst visibleIds = computed(() => displayedRows.value.map((row, index) => rowIdentity(row, index)))\nconst allVisibleSelected = computed(\n () => visibleIds.value.length > 0 && visibleIds.value.every((id) => selectedSet.value.has(id)),\n)\nconst masterIndeterminate = computed(\n () => !allVisibleSelected.value && visibleIds.value.some((id) => selectedSet.value.has(id)),\n)\n\n/*\n * A row is asked about by the identity `visibleIds` already holds for it: the template reads\n * `visibleIds[index]` for the key, the tint and the checkbox alike, rather than deriving it\n * again three or four times per row per render.\n */\nconst isSelected = (id: DataTableRowId) => selectedSet.value.has(id)\n\nfunction toggleRow(id: DataTableRowId) {\n selected.value = toggleValue(selected.value, id)\n}\n\n// It only ever touches the rows on screen, so what was selected on the other pages\n// survives moving between them.\n// Refused with no row on screen, or while the rows on screen are the PREVIOUS ones behind\n// the loading state: ticked there, it stayed ticked with nothing selected, or selected rows\n// the reader could not see.\nconst masterDisabled = computed(() => visibleIds.value.length === 0 || props.loading)\n\nfunction toggleMaster() {\n if (masterDisabled.value) return\n const ids = visibleIds.value\n if (allVisibleSelected.value) {\n const visible = new Set(ids)\n selected.value = selected.value.filter((id) => !visible.has(id))\n } else {\n const current = selectedSet.value\n selected.value = [...selected.value, ...ids.filter((id) => !current.has(id))]\n }\n}\n\n// @a11y\n// Without this every checkbox in the column would be announced identically, and a screen\n// reader user would have no way of knowing which row they were about to select.\nfunction rowSelectLabel(row: Row, index: number): string {\n // The position in the whole table, or every page would have its own \"Select row 1\". The\n // dictionary counts from one as a human does, the prop from zero as code does.\n const position = pageOffset.value + index\n return props.selectRowLabel?.(row, position) ?? m.value.dataTable.selectRow(position + 1)\n}\n\n/** How many rows of the whole table come before the page on show. */\nconst pageOffset = computed(() =>\n paginated.value ? (currentPage.value - 1) * (perPage.value ?? 0) : 0,\n)\n\nconst scrollerEl = ref<HTMLElement | null>(null)\nconst theadEl = ref<HTMLElement | null>(null)\nconst tbodyEl = ref<HTMLElement | null>(null)\n\n// @a11y\n// The row holding the focus stays rendered while the table scrolls away from it: dropping it\n// would send the focus back to the page.\nconst focusedIndex = ref(-1)\n\nfunction rowIndexOf(target: EventTarget | null) {\n if (!(target instanceof Element)) return -1\n const row = target.closest('tr')\n if (!row || row.parentElement !== tbodyEl.value || row.dataset.index === undefined) return -1\n return Number(row.dataset.index)\n}\n\n// Only a starting guess, every row being measured once rendered: a line of body text between\n// the cells' block padding, and the border under it.\nconst ROW_HEIGHT = { regular: 46, compact: 38 }\n\nconst virtualList = useVirtualList({\n scrollEl: computed(() => (props.virtual ? scrollerEl.value : null)),\n listEl: tbodyEl,\n count: () => displayedRows.value.length,\n key: (index) => visibleIds.value[index],\n itemSize: () => (props.compact ? ROW_HEIGHT.compact : ROW_HEIGHT.regular),\n overscan: () => 5,\n initialCount: () => 20,\n pinned: () => (focusedIndex.value >= 0 ? [focusedIndex.value] : []),\n insetStart: () => (props.stickyHeader ? (theadEl.value?.offsetHeight ?? 0) : 0),\n})\nconst measureRow = virtualList.measure\n\n/** The rows to render: those of the window and the space for the others, or every row. */\nconst rowSegments = computed<VirtualSegment[]>(() =>\n props.virtual\n ? virtualList.segments.value\n : displayedRows.value.map((_, index) => ({ type: 'row', index })),\n)\n\n// @a11y\n// Only some rows exist in the virtual mode, so the table says how many it has and each row\n// where it stands, the heading row being the first. The total is unknown while more may come.\nconst ariaRowCount = computed(() => {\n if (!props.virtual) return undefined\n return props.hasMore ? -1 : totalCount.value + 1\n})\n\n// The full loading state replaces the rows, except while the next ones are on their way: the\n// rows already loaded then stay, and the foot of the table says it is loading.\nconst loadingMore = computed(() => props.loading && props.hasMore && displayedRows.value.length > 0)\n\nconst sentinelEl = ref<HTMLElement | null>(null)\nuseInfiniteScroll({\n sentinelEl,\n root: () => scrollerEl.value,\n canLoad: () => props.hasMore && !props.loading,\n loaded: () => props.rows,\n onLoadMore: () => emit('load-more'),\n})\n\n// @devwarn\n// A table without a bounded height grows with its rows, so every row is in view and rendered.\nif (isDev) {\n watch(\n rowSegments,\n (segments) => {\n const el = scrollerEl.value\n if (!props.virtual || !el || displayedRows.value.length < 100) return\n if (el.scrollHeight > el.clientHeight) return\n if (segments.some((segment) => segment.type === 'spacer')) return\n console.warn(\n '[VDataTable] `virtual` renders every row because the table does not scroll: give it a `height` or a parent with a height.',\n )\n },\n { flush: 'post', once: true },\n )\n}\n\nwatch(perPage, () => {\n page.value = 1\n})\n\nconst colCount = computed(() => props.columns.length + (props.selectable ? 1 : 0))\n\n// @a11y\n/**\n * It is rendered, empty, as soon as rows can be selected at all. A region meant to announce its\n * own changes must already exist before the first change: inserted into the page at the same\n * moment as its text, it announces nothing, and the first row selected would pass in silence.\n */\nconst selectionSummary = computed(() => {\n const count = selected.value.length\n if (count === 0) return ''\n if (props.selectionText) return props.selectionText(count)\n return m.value.dataTable.selection(count)\n})\n\nconst rangeSummary = computed(() => {\n const per = perPage.value ?? 0\n const total = totalCount.value\n const start = total === 0 ? 0 : (currentPage.value - 1) * per + 1\n const end = Math.min(currentPage.value * per, total)\n return props.rangeText?.({ start, end, total }) ?? m.value.dataTable.range({ start, end, total })\n})\n\n// The height is applied to the whole component and not as a ceiling on the scrolling area. A\n// soft ceiling remains available to the consumer through a maximum height of their own: the\n// component is a column whose scrolling area can be compressed.\nconst heightStyle = computed<StyleValue | undefined>(() =>\n props.height !== undefined ? { blockSize: cssSize(props.height) } : undefined,\n)\n</script>\n\n<template>\n <div\n class=\"v-data-table\"\n :class=\"rootClass\"\n :style=\"[heightStyle, rootStyle]\"\n :data-variant=\"variant\"\n :data-striped=\"striped ? '' : undefined\"\n :data-compact=\"compact ? '' : undefined\"\n :data-sticky-header=\"stickyHeader ? '' : undefined\"\n :data-selectable=\"selectable ? '' : undefined\"\n :data-virtual=\"virtual ? '' : undefined\"\n >\n <div v-if=\"title || subtitle || $slots.header || searchable\" class=\"v-data-table-header\">\n <slot name=\"header\">\n <div v-if=\"title || subtitle\" class=\"v-data-table-titles\">\n <VTypography\n v-if=\"title\"\n :id=\"titleId\"\n as=\"div\"\n variant=\"heading-4\"\n class=\"v-data-table-title\"\n >\n {{ title }}\n </VTypography>\n <VTypography\n v-if=\"subtitle\"\n :id=\"subtitleId\"\n variant=\"subtitle\"\n tone=\"muted\"\n class=\"v-data-table-subtitle\"\n >\n {{ subtitle }}\n </VTypography>\n </div>\n </slot>\n <VInput\n v-if=\"searchable\"\n v-model=\"search\"\n class=\"v-data-table-search\"\n type=\"search\"\n size=\"sm\"\n :compact=\"compact\"\n :icon-start=\"searchIcon\"\n clearable\n :placeholder=\"resolvedSearchPlaceholder\"\n :aria-label=\"resolvedSearchLabel\"\n />\n </div>\n\n <div v-if=\"$slots.toolbar\" class=\"v-data-table-toolbar\">\n <slot name=\"toolbar\" />\n </div>\n\n <!-- What the variant frames: the rows and the footer under them, while the header and the\n toolbar stay outside, on the surface of the page. -->\n <div class=\"v-data-table-frame\">\n <div ref=\"scrollerEl\" class=\"v-data-table-scroller\">\n <table\n ref=\"tableEl\"\n class=\"v-data-table-table\"\n :aria-labelledby=\"tableLabelledBy\"\n :aria-describedby=\"tableDescribedBy\"\n :aria-rowcount=\"ariaRowCount\"\n :aria-busy=\"loadingMore ? 'true' : undefined\"\n v-bind=\"forwardedAttrs\"\n >\n <thead ref=\"theadEl\" class=\"v-data-table-head\">\n <tr :aria-rowindex=\"virtual ? 1 : undefined\">\n <th v-if=\"selectable\" scope=\"col\" class=\"v-data-table-select\">\n <VCheckbox\n :model-value=\"allVisibleSelected\"\n :indeterminate=\"masterIndeterminate\"\n :disabled=\"masterDisabled\"\n :aria-label=\"resolvedSelectAllLabel\"\n @update:model-value=\"toggleMaster\"\n />\n </th>\n <th\n v-for=\"column in columns\"\n :key=\"column.key\"\n scope=\"col\"\n :data-align=\"column.align\"\n :aria-sort=\"ariaSort(column)\"\n >\n <button\n v-if=\"column.sortable\"\n type=\"button\"\n class=\"v-data-table-sort\"\n :data-direction=\"sort?.key === column.key ? sort.direction : undefined\"\n @click=\"toggleSort(column.key)\"\n >\n <slot :name=\"`head-${column.key}`\" :column=\"column\">{{ column.label }}</slot>\n <!-- Decorative, and deliberately so: given no label, an icon hides itself\n from screen readers. What the sort state is, is already carried by\n the heading itself. -->\n <VIcon class=\"v-data-table-sort-icon\" v-bind=\"iconProps(sortIconFor(column))\" />\n </button>\n <template v-else>\n <slot :name=\"`head-${column.key}`\" :column=\"column\">{{ column.label }}</slot>\n </template>\n </th>\n </tr>\n </thead>\n <tbody\n ref=\"tbodyEl\"\n @focusin=\"focusedIndex = rowIndexOf($event.target)\"\n @focusout=\"focusedIndex = rowIndexOf($event.relatedTarget)\"\n >\n <!--\n The order matters: loading is checked before emptiness, so a table waiting for its\n rows never claims there are none.\n -->\n <tr v-if=\"loading && !loadingMore\">\n <td :colspan=\"colCount\" class=\"v-data-table-state\">\n <slot name=\"loading\">\n <!-- The spinner carries the text for a screen reader, so the visible copy is\n hidden from it: read twice, the cell would say it is loading twice. -->\n <span class=\"v-data-table-state-loading\">\n <VSpinner :label=\"resolvedLoadingText\" />\n <span aria-hidden=\"true\">{{ resolvedLoadingText }}</span>\n </span>\n </slot>\n </td>\n </tr>\n <tr v-else-if=\"displayedRows.length === 0\">\n <td :colspan=\"colCount\" class=\"v-data-table-state\">\n <slot name=\"empty\" :search=\"emptySearch\">\n <VEmptyState\n size=\"sm\"\n :icon=\"emptySearch ? searchOffIcon : inboxIcon\"\n :title=\"resolvedEmptyText\"\n />\n </slot>\n </td>\n </tr>\n <template v-else>\n <template\n v-for=\"segment in rowSegments\"\n :key=\"segment.type === 'row' ? visibleIds[segment.index] : segment.key\"\n >\n <tr v-if=\"segment.type === 'spacer'\" class=\"v-data-table-spacer\" aria-hidden=\"true\">\n <td :colspan=\"colCount\" :style=\"{ blockSize: `${segment.size}px` }\" />\n </tr>\n <tr\n v-else\n :ref=\"\n virtual ? (el) => measureRow(el as Element | null, segment.index) : undefined\n \"\n :data-index=\"virtual ? segment.index : undefined\"\n :aria-rowindex=\"virtual ? pageOffset + segment.index + 2 : undefined\"\n :data-stripe=\"striped && segment.index % 2 === 1 ? '' : undefined\"\n :data-selected=\"\n selectable && isSelected(visibleIds[segment.index]!) ? '' : undefined\n \"\n >\n <!--\n The selection is marked with a plain attribute and not with the ARIA selected\n state, which is invalid on the row of a table: it belongs to a grid. What tells\n assistive technology that a row is selected is its checkbox being checked.\n -->\n <td v-if=\"selectable\" class=\"v-data-table-select\">\n <VCheckbox\n :model-value=\"isSelected(visibleIds[segment.index]!)\"\n :aria-label=\"rowSelectLabel(displayedRows[segment.index]!, segment.index)\"\n @update:model-value=\"toggleRow(visibleIds[segment.index]!)\"\n />\n </td>\n <td v-for=\"column in columns\" :key=\"column.key\" :data-align=\"column.align\">\n <slot\n :name=\"`cell-${column.key}`\"\n :row=\"displayedRows[segment.index]!\"\n :value=\"displayedRows[segment.index]![column.key]\"\n :column=\"column\"\n >\n {{ displayedRows[segment.index]![column.key] }}\n </slot>\n </td>\n </tr>\n </template>\n <!--\n A single element for as long as more rows may come: replacing it would cancel the\n observation, and no further rows would be asked for. Hidden from assistive\n technology, which hears `aria-busy` on the table instead.\n -->\n <tr v-if=\"hasMore\" ref=\"sentinelEl\" class=\"v-data-table-more\" aria-hidden=\"true\">\n <td :colspan=\"colCount\">\n <span v-if=\"loading\" class=\"v-data-table-state-loading\">\n <VSpinner />\n <span>{{ resolvedLoadingText }}</span>\n </span>\n </td>\n </tr>\n </template>\n </tbody>\n </table>\n </div>\n\n <!-- The footer has two zones: what is selected on the left, and on the right the page\n size, the range and the pagination, in that order. -->\n <div v-if=\"paginated || selectable\" class=\"v-data-table-footer\">\n <span v-if=\"selectable\" class=\"v-data-table-selection\" aria-live=\"polite\">{{\n selectionSummary\n }}</span>\n <div v-if=\"paginated\" class=\"v-data-table-footer-end\">\n <div v-if=\"perPageOptions?.length\" class=\"v-data-table-per-page\">\n <span class=\"v-data-table-per-page-label\" aria-hidden=\"true\">{{\n resolvedPerPageText\n }}</span>\n <!-- The panel is told to match its trigger, which here replaces the default\n minimum width with something sensible: a menu of \"10\", \"25\", \"50\" has no\n use for the width a menu of commands assumes, and it still cannot end up\n narrower than the button opening it. -->\n <VMenu size=\"sm\" :compact=\"compact\" placement=\"top-end\" match-trigger>\n <template #trigger=\"{ triggerProps }\">\n <VButton\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n :compact=\"compact\"\n v-bind=\"triggerProps\"\n :aria-label=\"m.dataTable.perPageValue(resolvedPerPageText, perPage ?? 0)\"\n >\n {{ perPage }}\n <VIcon :name=\"arrowDropDownIcon\" />\n </VButton>\n </template>\n <VMenuItem\n v-for=\"option in perPageOptions\"\n :key=\"option\"\n :label=\"String(option)\"\n :selected=\"option === perPage\"\n @select=\"perPage = option\"\n />\n </VMenu>\n </div>\n <span v-if=\"showRange\" class=\"v-data-table-range\" aria-live=\"polite\">{{\n rangeSummary\n }}</span>\n <!--\n Named after the table rather than with the generic pagination wording: a page holding\n this table and a pagination of its own would otherwise expose two navigation landmarks\n with the same name, and a screen reader user could not tell them apart.\n -->\n <VPagination\n v-model=\"page\"\n :label=\"m.dataTable.pagination\"\n :length=\"pageCount\"\n size=\"sm\"\n item-variant=\"ghost\"\n :compact=\"compact\"\n align=\"end\"\n :total-visible=\"0\"\n edge-controls\n detached\n />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<style>\n@layer vectis.components {\n .v-data-table {\n /*\n * It does not go through the shared control scale; there is no single control height in a\n * table; which is the same case VAccordion is in.\n */\n --data-table-pad-block: var(--vectis-space-3);\n --data-table-pad-inline: var(--vectis-space-3);\n --data-table-head-pad-block: var(--vectis-space-2);\n\n /* The gutter between the frame and the footer it holds: nothing when the table is\n unframed, so the footer sits flush with the edge, and the cells' own inline padding\n as soon as a frame appears. */\n --data-table-frame-pad: 0px;\n\n font-family: var(--vectis-text-family);\n\n /*\n * Deliberately no `min-block-size: 0` here. Inside a flex column parent too short for it,\n * the automatic minimum is what keeps the table at its natural height instead of letting it\n * be crushed to nothing.\n */\n display: flex;\n flex-direction: column;\n block-size: 100%;\n }\n\n .v-data-table[data-compact] {\n --data-table-pad-block: var(--vectis-space-2);\n --data-table-pad-inline: var(--vectis-space-2);\n --data-table-head-pad-block: var(--vectis-space-1);\n }\n\n /* The same `min-block-size: 0` as the scrolling area below, one level up. */\n .v-data-table-frame {\n flex: 1 1 auto;\n display: flex;\n flex-direction: column;\n min-block-size: 0;\n }\n\n /*\n * The card. The unframed default has nothing to undo, since it declares no decoration at all;\n * whatever surrounds the table is what provides the surface then. The border is transparent\n * rather than absent on `filled`: forced colours paint it. `elevated` has none, so that the\n * rules between the rows reach the edge its shadow draws.\n */\n .v-data-table:is([data-variant='outline'], [data-variant='elevated'], [data-variant='filled'])\n > .v-data-table-frame {\n --data-table-frame-pad: var(--data-table-pad-inline);\n\n border: 1px solid transparent;\n border-radius: var(--vectis-radius-surface);\n /*\n * `clip` and not `hidden`. Hiding the overflow would make this element a scroll container\n * of its own, and the sticky heading would then anchor to IT rather than to the area that\n * actually scrolls; which is to say it would not stick at all.\n */\n overflow: clip;\n }\n\n .v-data-table[data-variant='outline'] > .v-data-table-frame {\n background: var(--vectis-color-surface);\n border-color: var(--vectis-color-border);\n }\n\n .v-data-table[data-variant='elevated'] > .v-data-table-frame {\n border: none;\n background: var(--vectis-color-surface-raised);\n box-shadow: var(--vectis-shadow-sm);\n }\n\n /* The heading's usual tint is the muted surface itself, which would merge into this fill. */\n .v-data-table[data-variant='filled'] {\n --data-table-head-bg: color-mix(\n in oklab,\n var(--vectis-color-surface-muted),\n var(--vectis-color-text) 4%\n );\n }\n\n .v-data-table[data-variant='filled'] > .v-data-table-frame {\n background: var(--vectis-color-surface-muted);\n }\n\n /*\n * `min-block-size: 0` is load-bearing; a flex item refuses by default to shrink below its\n * content, so without it the area never compresses and the table overflows instead of\n * scrolling.\n */\n .v-data-table-scroller {\n /*\n * Positioned, so it contains the absolutely positioned parts of the cells, a consumer's\n * included: positioned against an ancestor beyond it, they escape its clip and stretch the\n * page.\n */\n position: relative;\n flex: 1 1 auto;\n min-block-size: 0;\n overflow: auto;\n }\n\n /*\n * Unframed, the tinted heading and rows are rounded by the area that already clips them,\n * not by the frame: the footer sits flush with the frame's edges, and a clip there would\n * crop its focus rings.\n */\n .v-data-table[data-variant='flat'] > .v-data-table-frame > .v-data-table-scroller {\n border-radius: var(--vectis-radius-surface);\n }\n\n .v-data-table-header,\n .v-data-table-toolbar {\n flex: none;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--vectis-space-3);\n padding-block-end: var(--vectis-space-3);\n }\n\n .v-data-table-titles {\n display: flex;\n flex-direction: column;\n min-inline-size: 0;\n }\n\n /*\n * It is set through the colour VARIABLE that component reads, and not with a plain colour\n * declaration. That declaration would collide with VTypography's own at equal specificity,\n * and the winner would be decided by whichever sheet the consumer's bundler put last.\n */\n .v-data-table-title {\n --typography-color: var(--vectis-color-text);\n }\n\n /* The search field is given a width of its own, overriding the full width VInput takes\n by default, and is pushed to the end of the row even with no title beside it. The\n selector is qualified by its context, which makes it one step more specific than\n VInput's own rule and therefore independent of the order the two sheets end up in. */\n .v-data-table-header > .v-data-table-search {\n inline-size: var(--vectis-control-size-table-search);\n max-inline-size: 100%;\n margin-inline-start: auto;\n }\n\n .v-data-table-table {\n width: 100%;\n border-collapse: collapse;\n font-size: var(--vectis-text-body-md-size);\n color: var(--vectis-color-text);\n }\n\n .v-data-table-table th {\n padding: var(--data-table-head-pad-block) var(--data-table-pad-inline);\n text-align: start;\n font-size: var(--vectis-text-body-md-size);\n /*\n * The heavier weight distinguishes a heading from the data under it, which is emphasis\n * rather than a typographic role; hence a font token read directly.\n */\n font-weight: var(--vectis-font-weight-semibold);\n color: var(--vectis-color-text-muted);\n /*\n * The heading row gets a tint of its own so it reads apart from the data. `muted` and not\n * `sunken`: the striped rows already take `sunken`, and a heading painted the same would\n * read as one more stripe.\n */\n background-color: var(--data-table-head-bg, var(--vectis-color-surface-muted));\n border-block-end: 1px solid var(--vectis-color-border);\n }\n\n .v-data-table-table td {\n padding: var(--data-table-pad-block) var(--data-table-pad-inline);\n border-block-end: 1px solid var(--vectis-color-border);\n }\n\n .v-data-table-table tbody tr:last-child td {\n border-block-end: none;\n }\n\n .v-data-table-table [data-align='end'] {\n text-align: end;\n }\n\n .v-data-table-table [data-align='center'] {\n text-align: center;\n }\n\n /* The checkbox column is reduced to the width of its content. A table lays its columns\n out automatically, so asking for no width at all is what makes it take the least\n possible. */\n .v-data-table-table .v-data-table-select {\n inline-size: 0;\n }\n\n /* By the row's own index: in the virtual mode, the space standing for hidden rows is a row too. */\n .v-data-table[data-striped] tbody tr[data-stripe] {\n background-color: var(--vectis-color-surface-sunken);\n }\n\n /* Placed after the striping on purpose: the specificity is the same, so it is the order\n that makes a selected row keep its tint on both odd and even rows. */\n .v-data-table[data-selectable] tbody tr[data-selected] {\n background-color: var(--vectis-color-accent-surface);\n }\n\n /* Forced colours flatten both tints to `Canvas`: the stripes are only a reading aid, but\n a selected row would be told apart by its checkbox alone. It draws an inward outline in\n the system selection colour, which the mode keeps. */\n @media (forced-colors: active) {\n .v-data-table[data-selectable] tbody tr[data-selected] {\n outline: var(--vectis-focus-ring-width) solid Highlight;\n outline-offset: calc(-1 * var(--vectis-focus-ring-width));\n }\n }\n\n /*\n * A frozen heading relies on the opaque background every `th` already carries: the rows\n * scroll underneath it, and a consumer restyling that background with a translucent colour\n * will see them through.\n */\n .v-data-table[data-sticky-header] th {\n position: sticky;\n inset-block-start: 0;\n z-index: 1;\n }\n\n .v-data-table-sort {\n /*\n * The icon context for the sort glyph. Without it the icon would fall back to one em; the\n * heading's own text size; and come out visibly smaller than every other icon in the\n * component.\n */\n --vectis-icon-size: var(--vectis-icon-size-md);\n --vectis-icon-opsz: 20;\n\n display: inline-flex;\n align-items: center;\n gap: var(--vectis-space-1);\n border: none;\n background: transparent;\n padding: 0;\n color: inherit;\n font: inherit;\n cursor: pointer;\n /* Seen only on the focus ring: the control radius capped at half a line, VBreadcrumb's\n link recipe, since a heading that wraps would otherwise round to half its height. */\n border-radius: min(var(--vectis-radius-interactive), 0.5lh);\n }\n\n .v-data-table-sort:hover {\n color: var(--vectis-color-text);\n }\n\n .v-data-table-sort:focus-visible {\n outline: var(--vectis-focus-ring-width) solid var(--vectis-focus-ring-color);\n outline-offset: var(--vectis-focus-ring-offset);\n }\n\n /* The glyph stays faint on every column that merely COULD be sorted: it announces that\n the heading can be clicked without competing for attention with the one column\n actually carrying the order. */\n .v-data-table-sort-icon {\n opacity: 0.35;\n }\n\n .v-data-table-sort[data-direction] .v-data-table-sort-icon {\n opacity: 1;\n }\n\n /* The table corrects its scroll itself when a row above the view changes height. */\n .v-data-table[data-virtual] .v-data-table-scroller {\n overflow-anchor: none;\n }\n\n .v-data-table-table .v-data-table-spacer td {\n padding: 0;\n border: none;\n }\n\n /*\n * The foot of the rows: the marker watched for their end, and where the next rows are said\n * to be loading. It keeps a real height, a box of none making the crossing unreliable.\n */\n .v-data-table-table .v-data-table-more td {\n block-size: var(--vectis-control-height-md);\n padding: var(--vectis-space-2);\n border: none;\n text-align: center;\n color: var(--vectis-color-text-muted);\n }\n\n .v-data-table-state {\n padding: var(--vectis-space-6);\n text-align: center;\n color: var(--vectis-color-text-muted);\n }\n\n /*\n * The cell already pads the default empty state. `[data-size]` lifts the selector above\n * VEmptyState's own size rules, whose sheet may load after this one.\n */\n .v-data-table-state > .v-empty-state[data-size] {\n padding: 0;\n }\n\n .v-data-table-state-loading {\n display: inline-flex;\n align-items: center;\n gap: var(--vectis-space-2);\n }\n\n .v-data-table-footer {\n flex: none;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: var(--vectis-space-4);\n padding-block-start: var(--vectis-space-3);\n padding-block-end: var(--data-table-frame-pad);\n padding-inline: var(--data-table-frame-pad);\n }\n\n /*\n * The right-hand zone is pushed to the edge by an automatic margin rather than by an\n * alignment on the footer. The two zones are siblings in the same row, and the count on the\n * left has to stay at the OPPOSITE edge: any alignment set on the footer would move both of\n * them together.\n */\n .v-data-table-footer-end {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: var(--vectis-space-4);\n margin-inline-start: auto;\n }\n\n .v-data-table-selection,\n .v-data-table-range,\n .v-data-table-per-page-label {\n font-size: var(--vectis-text-body-md-size);\n color: var(--vectis-color-text-muted);\n }\n\n .v-data-table-per-page {\n display: flex;\n align-items: center;\n gap: var(--vectis-space-2);\n }\n}\n</style>\n"],"mappings":""}
1
+ {"version":3,"file":"VDataTable.js","names":["_sfc_main","VDataTable_vue_vue_type_script_setup_true_lang_default","VDataTable_default"],"sources":["../../../src/components/VDataTable/VDataTable.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"Row extends Record<string, unknown>\">\n// @core\n/**\n * Native table semantics remain intact. JavaScript adds sorting, paging, selection and\n * debounced search; browser measurements stay in browser tests.\n */\n\nimport { computed, ref, useId, useSlots, watch, watchEffect } from 'vue'\nimport type { StyleValue } from 'vue'\n\nimport VButton from '../VButton/VButton.vue'\nimport VCheckbox from '../VCheckbox/VCheckbox.vue'\nimport VEmptyState from '../VEmptyState/VEmptyState.vue'\nimport VIcon from '../VIcon/VIcon.vue'\nimport { iconProps } from '../VIcon/iconProps'\nimport { arrow_downward as arrowDownwardIcon } from '../VIcon/icons/arrow_downward'\nimport { arrow_drop_down as arrowDropDownIcon } from '../VIcon/icons/arrow_drop_down'\nimport { arrow_upward as arrowUpwardIcon } from '../VIcon/icons/arrow_upward'\nimport { inbox as inboxIcon } from '../VIcon/icons/inbox'\nimport { search as searchIcon } from '../VIcon/icons/search'\nimport { search_off as searchOffIcon } from '../VIcon/icons/search_off'\nimport { swap_vert as swapVertIcon } from '../VIcon/icons/swap_vert'\nimport type { IconSource } from '../VIcon/types'\nimport VInput from '../VInput/VInput.vue'\nimport VMenu from '../VMenu/VMenu.vue'\nimport VMenuItem from '../VMenu/VMenuItem.vue'\nimport VPagination from '../VPagination/VPagination.vue'\nimport VSpinner from '../VSpinner/VSpinner.vue'\nimport VTypography from '../VTypography/VTypography.vue'\n\nimport { toggleValue } from '../../utils/array'\nimport { cssSize } from '../../utils/css'\nimport { isDev } from '../../utils/env'\nimport { clamp } from '../../utils/number'\nimport { createNormalizedCache, normalizeText } from '../../utils/text'\n\nimport { useInfiniteScroll } from '../../composables/useInfiniteScroll'\nimport { useRootAttrs } from '../../composables/useRootAttrs'\nimport { useVirtualList, type VirtualSegment } from '../../composables/useVirtualList'\n\nimport { useTimer } from '../../composables/useTimer'\nimport { useLocale, useMessages } from '../../i18n/state'\n\n/** How a column's content is aligned. */\nexport type DataTableColumnAlign = 'start' | 'center' | 'end'\n\n/** One column of the table. */\nexport interface DataTableColumn {\n /** Which field of a row it shows, and the name its slots are addressed by. */\n key: string\n /** Its heading. */\n label: string\n /** Lets the reader sort by this column. */\n sortable?: boolean\n /** How its content is aligned. Numbers usually belong at the end. */\n align?: DataTableColumnAlign\n}\n\n/** Which way a column is sorted: A to Z, or Z to A. */\nexport type DataTableSortDirection = 'asc' | 'desc'\n\n/** Which column the table is sorted by, and in which direction. */\nexport interface DataTableSort {\n /** The `key` of the column the rows are ordered by. */\n key: string\n /** Which way they are ordered. */\n direction: DataTableSortDirection\n}\n\n/** How a row is identified: by the field named in `rowKey`, or failing that by its position. */\nexport type DataTableRowId = string | number\n\n/**\n * Everything the table is currently being asked for, reported whenever it changes so a\n * server can answer it. What is not set is `null` rather than left out, so the object keeps\n * the same keys once serialized into a request.\n */\nexport interface DataTableParams {\n /** The page asked for, from 1. */\n page: number\n /** How many rows a page holds, `null` when the table is not paginated. */\n perPage: number | null\n /** The `key` of the sorted column, `null` when the rows are not sorted. */\n sortKey: string | null\n /** Which way they are sorted, `null` when they are not. */\n sortDirection: DataTableSortDirection | null\n /** The committed search, empty when nothing is searched for. */\n search: string\n}\n\n/** What the `cell-<key>` slots receive. */\nexport interface DataTableCellSlotProps<Row extends Record<string, unknown>> {\n /** The row the cell belongs to. */\n row: Row\n /** The value of the column's field in that row. */\n value: unknown\n /** The column the cell belongs to. */\n column: DataTableColumn\n}\n\n/** What the `head-<key>` slots receive. */\nexport interface DataTableHeadSlotProps {\n /** The column the heading belongs to. */\n column: DataTableColumn\n}\n\n/** What the `#empty` slot receives. */\nexport interface DataTableEmptySlotProps {\n /** The search that produced the empty result, empty when nothing was searched for. */\n search: string\n}\n\n/** The rows on show, as `rangeText` receives them, counted from 1. */\nexport interface DataTableRange {\n /** The position of the first row on show. */\n start: number\n /** The position of the last row on show. */\n end: number\n /** How many rows there are in all. */\n total: number\n}\n\n/** How the rows are set off from the page: nothing, a border, a shadow, or a muted fill. */\nexport type DataTableVariant = 'flat' | 'outline' | 'elevated' | 'filled'\n\n// This interface is exported rather than kept local, and it is generic rather than referring to\n// the component's own type parameter. A component typed over its rows inlines the whole\n// signature of its props into the declarations it emits, so a name that is not exported cannot\n// be written there and the build of the type declarations fails.\nexport interface DataTableProps<Row extends Record<string, unknown>> {\n /** The columns to show, in order. */\n columns: DataTableColumn[]\n /** The rows to show. */\n rows: Row[]\n /** Which field identifies a row. */\n rowKey?: string\n /**\n * How the rows and the footer are framed: nothing at all (`flat`, the default), or a card\n * with rounded corners set off by a border on the page surface (`outline`), a shadow over a\n * raised surface (`elevated`), or a muted fill (`filled`). The header and the toolbar stay\n * outside the frame.\n */\n variant?: DataTableVariant\n /** Shows that the rows are being loaded. */\n loading?: boolean\n /**\n * What is written beside the spinner while the rows are loading. It falls back to the design\n * system dictionary.\n */\n loadingText?: string\n /**\n * The title of the empty state shown when there is no row to show. It falls back to the design\n * system dictionary, which words a table with no data and a search with no match differently.\n */\n emptyText?: string\n /**\n * A title above the table, which also names it for assistive technology. It is ignored when\n * the `#header` slot replaces the title and subtitle.\n */\n title?: string\n /**\n * A line under the title saying what the table holds. It also describes the table for\n * assistive technology.\n */\n subtitle?: string\n /** Adds a search field to the header. */\n searchable?: boolean\n /** What that field says while empty. It falls back to the design system dictionary. */\n searchPlaceholder?: string\n /**\n * What screen readers announce for the search field. It falls back to the design\n * system dictionary.\n */\n searchLabel?: string\n /**\n * When a server does the searching, how long to wait after a keystroke before asking\n * it, in milliseconds. Zero asks at once.\n */\n searchDebounce?: number\n /** Tints every other row, which helps the eye follow a long line across the table. */\n striped?: boolean\n /**\n * Keeps the column headings in place while the rows scroll under them. It needs a\n * bounded scrolling area to work: either the `height` prop, or a parent with a height\n * of its own.\n */\n stickyHeader?: boolean\n /**\n * The height of the whole component, header, toolbar and pagination included: a number is read as\n * pixels, anything else as a CSS length. Left out, the table takes its parent's height\n * whenever the parent has one.\n */\n height?: number | string\n /** The heading icon of a column that can be sorted but currently is not. */\n sortIcon?: IconSource\n /**\n * The icon of an ascending sort. It points DOWN by default, the spreadsheet\n * convention: sorting A to Z reads downwards.\n */\n sortAscIcon?: IconSource\n /** The icon of a descending sort. */\n sortDescIcon?: IconSource\n /** The choices offered for how many rows a page holds. */\n perPageOptions?: number[]\n /** What that choice is called. It falls back to the design system dictionary. */\n perPageText?: string\n /**\n * How many rows there are in all on the server. It is what lets the pagination and the\n * range be right when the table only ever holds one page.\n */\n total?: number\n /** Shows which rows are being looked at (\"1–10 of 42\") in the footer. */\n showRange?: boolean\n /** Rephrases that range. It falls back to the design system dictionary. */\n rangeText?: (range: DataTableRange) => string\n /** Adds a checkbox to every row, and one in the heading to take the whole page. */\n selectable?: boolean\n /**\n * What the heading checkbox is announced as. It falls back to the design system\n * dictionary.\n */\n selectAllLabel?: string\n /**\n * How the selection is summed up in the footer. It says nothing at all when nothing is\n * selected, and falls back to the design system dictionary.\n */\n selectionText?: (count: number) => string\n /**\n * What a row's checkbox is announced as. \"Select row\" tells a screen reader user nothing\n * about WHICH row, so this is worth supplying with something from the row itself. It falls\n * back to the design system dictionary, which numbers the rows from 1.\n */\n selectRowLabel?: (row: Row, index: number) => string\n /**\n * Hands the searching, the sorting and the paging over to a server: the rows are shown\n * exactly as they arrive, and every change of what is being asked for is reported so\n * the server can answer it.\n */\n serverSide?: boolean\n /**\n * Renders only the rows near the visible part of the table, for tables of thousands of rows.\n * It needs a bounded height, like `stickyHeader`. Rows are measured as they render, so they\n * may vary in height, and each one is announced with its place in the whole table.\n */\n virtual?: boolean\n /**\n * Says that more rows are to come, which makes the table ask for them through `load-more` as\n * the end of its rows comes into view. While `loading`, the rows already there stay on show.\n */\n hasMore?: boolean\n}\n\nconst props = withDefaults(defineProps<DataTableProps<Row>>(), {\n rowKey: undefined,\n variant: 'flat',\n loading: false,\n loadingText: undefined,\n emptyText: undefined,\n title: undefined,\n subtitle: undefined,\n searchable: false,\n searchPlaceholder: undefined,\n searchLabel: undefined,\n searchDebounce: 250,\n striped: false,\n stickyHeader: false,\n height: undefined,\n sortIcon: () => swapVertIcon,\n sortAscIcon: () => arrowDownwardIcon,\n sortDescIcon: () => arrowUpwardIcon,\n perPageOptions: undefined,\n perPageText: undefined,\n total: undefined,\n showRange: false,\n rangeText: undefined,\n selectable: false,\n selectAllLabel: undefined,\n selectionText: undefined,\n selectRowLabel: undefined,\n serverSide: false,\n virtual: false,\n hasMore: false,\n})\n\nconst m = useMessages()\nconst vectisLocale = useLocale()\nconst resolvedLoadingText = computed(() => props.loadingText ?? m.value.dataTable.loading)\nconst resolvedSearchPlaceholder = computed(\n () => props.searchPlaceholder ?? m.value.dataTable.searchPlaceholder,\n)\nconst resolvedSearchLabel = computed(() => props.searchLabel ?? m.value.dataTable.searchLabel)\nconst resolvedPerPageText = computed(() => props.perPageText ?? m.value.dataTable.perPage)\nconst resolvedSelectAllLabel = computed(() => props.selectAllLabel ?? m.value.dataTable.selectAll)\n\n/** Which column the rows are sorted by, and in which direction. */\nconst sort = defineModel<DataTableSort | null>('sort', { default: null })\n/** The page being shown, counted from 1. */\nconst page = defineModel<number>('page', { default: 1 })\n/**\n * How many rows a page holds. Any value above zero turns the pagination on, so passing\n * one down without binding it is enough to enable it.\n */\nconst perPage = defineModel<number | undefined>('perPage', { default: undefined })\n/*\n * `sort` is `null` because the TABLE writes that state itself, a third click on a heading\n * clearing the order, and a model the component writes needs a value a consumer can store and\n * compare. `perPage` is `undefined` because nothing here ever clears it: it is simply a model\n * that was not given.\n */\n/** The selected rows, as the identities `rowKey` gives them, never the row objects themselves. */\nconst selected = defineModel<DataTableRowId[]>('selected', { default: () => [] })\n/**\n * What is typed in the search field, empty to begin with. Only the declared columns are\n * searched, accent- and case-insensitively; in `serverSide` mode nothing is filtered here\n * and the term is reported through `update:params` instead.\n */\nconst search = defineModel<string>('search', { default: '' })\n\nconst emit = defineEmits<{\n /**\n * What the table is now being asked for, when a server is answering: the page, the page size,\n * the sort or the search has changed, the last one after its delay.\n */\n 'update:params': [params: DataTableParams]\n /** The end of the rows has come into view while `hasMore` is set: send the next ones. */\n 'load-more': []\n}>()\n\ndefineSlots<{\n /** What a cell of a given column shows: a slot named after that column's key. */\n [name: `cell-${string}`]: (scope: DataTableCellSlotProps<Row>) => unknown\n /** What a column's heading shows: a slot named after that column's key. */\n [name: `head-${string}`]: (scope: DataTableHeadSlotProps) => unknown\n /**\n * Replaces the title and subtitle with content of your own; the search field stays beside it.\n * Name the table with `aria-label` or `aria-labelledby` then.\n */\n header?(): unknown\n /** A row between the header and the table, for actions and filters. */\n toolbar?(): unknown\n /** What the table shows while its rows are loading, replacing the spinner and its text. */\n loading?(): unknown\n /**\n * What the table shows when there is no row to show, replacing `emptyText`. It receives the\n * search that produced the empty result, empty when nothing was searched for.\n */\n empty?(scope: DataTableEmptySlotProps): unknown\n}>()\n\n// `class` and `style` stay on the wrapper, where a consumer expects to place the component;\n// everything else; an id, the aria-*; goes to the `<table>` itself, the only element they\n// validly describe.\ndefineOptions({ inheritAttrs: false })\nconst { attrs, rootClass, rootStyle, forwardedAttrs } = useRootAttrs()\nconst slots = useSlots()\n\n// A template ref on the component reaches the wrapper, a layout box; the `<table>` is where\n// the consumer's attributes land and what they describe.\nconst tableEl = ref<HTMLTableElement | null>(null)\ndefineExpose({\n /** The `<table>` element, where the consumer's attributes land. */\n el: tableEl,\n})\n\n// @a11y\n/*\n * The title names the table unless the `#header` slot replaced it, or the consumer named the\n * table, whose own `aria-label` a reference to the title would override. Bound before the\n * forwarded attributes, like every state the component owns.\n */\nconst titleId = useId()\nconst subtitleId = useId()\nconst namedByConsumer = () =>\n attrs['aria-label'] !== undefined || attrs['aria-labelledby'] !== undefined\nconst tableLabelledBy = computed(() =>\n props.title && !slots.header && !namedByConsumer() ? titleId : undefined,\n)\nconst tableDescribedBy = computed(() => (props.subtitle && !slots.header ? subtitleId : undefined))\n\n// @devwarn\nif (isDev) {\n if (!tableLabelledBy.value && !namedByConsumer())\n console.warn(\n '[VDataTable] the table has no accessible name: set `title`, or aria-label or aria-labelledby when the `#header` slot replaces it.',\n )\n if (props.selectable && !props.rowKey)\n console.warn(\n '[VDataTable] `selectable` without `rowKey` — index-based identities are corrupted by sorting, filtering and pagination.',\n )\n /*\n * A key that is missing, or not a string or a number, turns into the same text on every\n * row (\"undefined\"), and two rows sharing a key share an identity: ticking one ticks them\n * all, and the rows' own `:key`s collide. Once per instance and per kind.\n */\n const warned = new Set<string>()\n watchEffect(() => {\n const key = props.rowKey\n if (!key) return\n const seen = new Set<unknown>()\n for (const row of props.rows) {\n const value = row[key]\n if (typeof value !== 'string' && typeof value !== 'number') {\n if (!warned.has('type')) {\n warned.add('type')\n console.warn(\n `[VDataTable] \\`rowKey\\` \"${key}\" is missing or is not a string or a number on some rows: those rows share one identity.`,\n )\n }\n } else if (seen.has(value)) {\n if (!warned.has('duplicate')) {\n warned.add('duplicate')\n console.warn(\n `[VDataTable] \\`rowKey\\` \"${key}\" holds the value \"${value}\" twice: rows are told apart by it, so it must be unique.`,\n )\n }\n } else seen.add(value)\n }\n })\n}\n\n/*\n * A key that is already a string or a number is returned AS IT IS. The selection holds these\n * identities and is looked up with a Set, which tells the number 7 from the string \"7\": turned\n * into text, a table keyed by numeric ids never found a selected row again, so every checkbox\n * stayed unticked.\n */\nfunction rowIdentity(row: Row, index: number): DataTableRowId {\n if (!props.rowKey) return index\n const key = row[props.rowKey]\n return typeof key === 'string' || typeof key === 'number' ? key : String(key)\n}\n\n// Searching fields the reader cannot see would return rows for reasons nothing on screen\n// explains.\n/*\n * The filter below re-reads the whole table on every keystroke: ten thousand rows across five\n * columns is fifty thousand normalizations per character typed without it.\n */\nconst normalizedOf = createNormalizedCache<Row>()\nconst normalizedCell = (row: Row, key: string) => normalizedOf(row, String(row[key] ?? ''), key)\n\nconst filteredRows = computed(() => {\n if (props.serverSide || !props.searchable) return props.rows\n const needle = normalizeText((search.value ?? '').trim())\n if (!needle) return props.rows\n return props.rows.filter((row) =>\n props.columns.some((column) => normalizedCell(row, column.key).includes(needle)),\n )\n})\n\n/*\n * The locale must nonetheless stay EXPLICIT: an `undefined` one resolves differently in Node\n * and in the browser, so the row order would diverge across hydration.\n */\nconst collator = computed(() => new Intl.Collator(vectisLocale.value, { numeric: true }))\n\n/*\n * What a cell is compared by. A `Date` by its instant: as text it collates on `toString()`,\n * which opens with the WEEKDAY, so Monday the 5th sorted before Saturday the 3rd.\n */\nconst NUMERIC_TEXT = /^\\s*[+-]?(\\d+\\.?\\d*|\\.\\d+)(e[+-]?\\d+)?\\s*$/i\nfunction sortKey(value: unknown): unknown {\n if (value instanceof Date) return value.getTime()\n if (typeof value === 'string' && NUMERIC_TEXT.test(value)) return Number(value)\n return value\n}\n\nconst sortedRows = computed(() => {\n const current = sort.value\n if (!current || props.serverSide) return filteredRows.value\n const factor = current.direction === 'asc' ? 1 : -1\n const compare = collator.value.compare\n return [...filteredRows.value].sort((a, b) => {\n const av = sortKey(a[current.key])\n const bv = sortKey(b[current.key])\n if (typeof av === 'number' && typeof bv === 'number') return (av - bv) * factor\n return compare(String(av ?? ''), String(bv ?? '')) * factor\n })\n})\n\nconst paginated = computed(() => (perPage.value ?? 0) > 0)\nconst totalCount = computed(() =>\n props.serverSide ? (props.total ?? props.rows.length) : filteredRows.value.length,\n)\nconst pageCount = computed(() =>\n paginated.value ? Math.max(1, Math.ceil(totalCount.value / (perPage.value ?? 1))) : 1,\n)\n// The page actually shown is CLAMPED by derivation and the model is never rewritten: a\n// search that leaves fewer pages simply falls back to the last one, and typing a\n// character that would have emptied the table does not silently move the consumer's own\n// page number.\nconst currentPage = computed(() => clamp(page.value, 1, pageCount.value))\n\nconst displayedRows = computed(() => {\n // With a server answering, the rows received ARE the current page: cutting them again\n // would show a tenth of a page.\n if (props.serverSide || !paginated.value) return sortedRows.value\n const start = (currentPage.value - 1) * (perPage.value ?? 0)\n return sortedRows.value.slice(start, start + (perPage.value ?? 0))\n})\n\nfunction toggleSort(key: string) {\n const current = sort.value\n if (!current || current.key !== key) sort.value = { key, direction: 'asc' }\n else if (current.direction === 'asc') sort.value = { key, direction: 'desc' }\n else sort.value = null\n}\n\n// @a11y\n// Only the column actually sorted carries the attribute. Setting it on every heading would have a screen reader announce \"not sorted\" on each one in turn, drowning\n// the single piece of information that matters: which column the order comes from.\nfunction ariaSort(column: DataTableColumn): 'ascending' | 'descending' | undefined {\n if (sort.value?.key !== column.key) return undefined\n return sort.value.direction === 'asc' ? 'ascending' : 'descending'\n}\n\n/**\n * Which icon a column's heading shows: a neutral one on any sortable column, and the\n * arrow of the current direction on the one being sorted by.\n *\n * It is deliberately named differently from the prop it falls back to: written the same,\n * the function would shadow the prop inside the template and the icons would never be\n * overridable.\n */\nfunction sortIconFor(column: DataTableColumn): IconSource {\n if (sort.value?.key !== column.key) return props.sortIcon\n return sort.value.direction === 'asc' ? props.sortAscIcon : props.sortDescIcon\n}\n\n// With `serverSide`, the search reaches the server only once the reader pauses: nothing native\n// waits before asking. The term actually committed is what the parameters below report.\nconst committedSearch = ref(search.value)\nconst searchTimer = useTimer()\n\nfunction commitSearch() {\n // A term typed and erased inside the debounce is no new search: going back to page 1\n // and asking the server again would be a request for what is already on screen.\n if (search.value === committedSearch.value) return\n committedSearch.value = search.value\n page.value = 1\n}\n\nwatch(search, () => {\n if (!props.serverSide) {\n page.value = 1\n return\n }\n searchTimer.start(commitSearch, props.searchDebounce)\n})\n\nconst emptySearch = computed(() => (props.serverSide ? committedSearch.value : search.value))\n/** The title of the empty state: a table with no data does not read like a search with no match. */\nconst resolvedEmptyText = computed(\n () =>\n props.emptyText ?? (emptySearch.value ? m.value.dataTable.noResults : m.value.dataTable.empty),\n)\n\n/*\n * `page` is the model, never the clamped `currentPage`. The clamp reads `total`, which is the\n * server's own answer: read here, a response that changed the total would move the parameters\n * and ask for the page again, and a consumer clearing `total` while it loads would send the\n * reader back to page 1.\n */\n// Committing a search and going back to the first page happen one after the other, but both\n// land in the same flush, so this runs once on the final values; never two requests for what\n// the reader experienced as a single action. Compared by value: a parent handing down an equal\n// `sort` object is no new request.\nwatch(\n [\n page,\n () => perPage.value ?? null,\n () => sort.value?.key ?? null,\n () => sort.value?.direction ?? null,\n committedSearch,\n ],\n ([page, perPage, sortKey, sortDirection, search]) => {\n if (props.serverSide) emit('update:params', { page, perPage, sortKey, sortDirection, search })\n },\n)\n\n// The selection. The heading checkbox covers the rows currently VISIBLE and not the whole\n// table: a box that silently selected forty thousand rows would be a trap.\nconst selectedSet = computed(() => new Set<DataTableRowId>(selected.value))\nconst visibleIds = computed(() => displayedRows.value.map((row, index) => rowIdentity(row, index)))\nconst allVisibleSelected = computed(\n () => visibleIds.value.length > 0 && visibleIds.value.every((id) => selectedSet.value.has(id)),\n)\nconst masterIndeterminate = computed(\n () => !allVisibleSelected.value && visibleIds.value.some((id) => selectedSet.value.has(id)),\n)\n\n/*\n * A row is asked about by the identity `visibleIds` already holds for it: the template reads\n * `visibleIds[index]` for the key, the tint and the checkbox alike, rather than deriving it\n * again three or four times per row per render.\n */\nconst isSelected = (id: DataTableRowId) => selectedSet.value.has(id)\n\nfunction toggleRow(id: DataTableRowId) {\n selected.value = toggleValue(selected.value, id)\n}\n\n// It only ever touches the rows on screen, so what was selected on the other pages\n// survives moving between them.\n// Refused with no row on screen, or while the rows on screen are the PREVIOUS ones behind\n// the loading state: ticked there, it stayed ticked with nothing selected, or selected rows\n// the reader could not see.\nconst masterDisabled = computed(() => visibleIds.value.length === 0 || props.loading)\n\nfunction toggleMaster() {\n if (masterDisabled.value) return\n const ids = visibleIds.value\n if (allVisibleSelected.value) {\n const visible = new Set(ids)\n selected.value = selected.value.filter((id) => !visible.has(id))\n } else {\n const current = selectedSet.value\n selected.value = [...selected.value, ...ids.filter((id) => !current.has(id))]\n }\n}\n\n// @a11y\n// Without this every checkbox in the column would be announced identically, and a screen\n// reader user would have no way of knowing which row they were about to select.\nfunction rowSelectLabel(row: Row, index: number): string {\n // The position in the whole table, or every page would have its own \"Select row 1\". The\n // dictionary counts from one as a human does, the prop from zero as code does.\n const position = pageOffset.value + index\n return props.selectRowLabel?.(row, position) ?? m.value.dataTable.selectRow(position + 1)\n}\n\n/** How many rows of the whole table come before the page on show. */\nconst pageOffset = computed(() =>\n paginated.value ? (currentPage.value - 1) * (perPage.value ?? 0) : 0,\n)\n\nconst scrollerEl = ref<HTMLElement | null>(null)\nconst theadEl = ref<HTMLElement | null>(null)\nconst tbodyEl = ref<HTMLElement | null>(null)\n\n// @a11y\n// The row holding the focus stays rendered while the table scrolls away from it: dropping it\n// would send the focus back to the page.\nconst focusedIndex = ref(-1)\n\nfunction rowIndexOf(target: EventTarget | null) {\n if (!(target instanceof Element)) return -1\n const row = target.closest('tr')\n if (!row || row.parentElement !== tbodyEl.value || row.dataset.index === undefined) return -1\n return Number(row.dataset.index)\n}\n\n// Only a starting guess, every row being measured once rendered: a line of body text between\n// the cells' block padding in the standard density, and the border under it.\nconst ROW_HEIGHT = 46\n\nconst virtualList = useVirtualList({\n scrollEl: computed(() => (props.virtual ? scrollerEl.value : null)),\n listEl: tbodyEl,\n count: () => displayedRows.value.length,\n key: (index) => visibleIds.value[index],\n itemSize: () => ROW_HEIGHT,\n overscan: () => 5,\n initialCount: () => 20,\n pinned: () => (focusedIndex.value >= 0 ? [focusedIndex.value] : []),\n insetStart: () => (props.stickyHeader ? (theadEl.value?.offsetHeight ?? 0) : 0),\n})\nconst measureRow = virtualList.measure\n\n/** The rows to render: those of the window and the space for the others, or every row. */\nconst rowSegments = computed<VirtualSegment[]>(() =>\n props.virtual\n ? virtualList.segments.value\n : displayedRows.value.map((_, index) => ({ type: 'row', index })),\n)\n\n// @a11y\n// Only some rows exist in the virtual mode, so the table says how many it has and each row\n// where it stands, the heading row being the first. The total is unknown while more may come.\nconst ariaRowCount = computed(() => {\n if (!props.virtual) return undefined\n return props.hasMore ? -1 : totalCount.value + 1\n})\n\n// The full loading state replaces the rows, except while the next ones are on their way: the\n// rows already loaded then stay, and the foot of the table says it is loading.\nconst loadingMore = computed(() => props.loading && props.hasMore && displayedRows.value.length > 0)\n\nconst sentinelEl = ref<HTMLElement | null>(null)\nuseInfiniteScroll({\n sentinelEl,\n root: () => scrollerEl.value,\n canLoad: () => props.hasMore && !props.loading,\n loaded: () => props.rows,\n onLoadMore: () => emit('load-more'),\n})\n\n// @devwarn\n// A table without a bounded height grows with its rows, so every row is in view and rendered.\nif (isDev) {\n watch(\n rowSegments,\n (segments) => {\n const el = scrollerEl.value\n if (!props.virtual || !el || displayedRows.value.length < 100) return\n if (el.scrollHeight > el.clientHeight) return\n if (segments.some((segment) => segment.type === 'spacer')) return\n console.warn(\n '[VDataTable] `virtual` renders every row because the table does not scroll: give it a `height` or a parent with a height.',\n )\n },\n { flush: 'post', once: true },\n )\n}\n\nwatch(perPage, () => {\n page.value = 1\n})\n\nconst colCount = computed(() => props.columns.length + (props.selectable ? 1 : 0))\n\n// @a11y\n/**\n * It is rendered, empty, as soon as rows can be selected at all. A region meant to announce its\n * own changes must already exist before the first change: inserted into the page at the same\n * moment as its text, it announces nothing, and the first row selected would pass in silence.\n */\nconst selectionSummary = computed(() => {\n const count = selected.value.length\n if (count === 0) return ''\n if (props.selectionText) return props.selectionText(count)\n return m.value.dataTable.selection(count)\n})\n\nconst rangeSummary = computed(() => {\n const per = perPage.value ?? 0\n const total = totalCount.value\n const start = total === 0 ? 0 : (currentPage.value - 1) * per + 1\n const end = Math.min(currentPage.value * per, total)\n return props.rangeText?.({ start, end, total }) ?? m.value.dataTable.range({ start, end, total })\n})\n\n// The height is applied to the whole component and not as a ceiling on the scrolling area. A\n// soft ceiling remains available to the consumer through a maximum height of their own: the\n// component is a column whose scrolling area can be compressed.\nconst heightStyle = computed<StyleValue | undefined>(() =>\n props.height !== undefined ? { blockSize: cssSize(props.height) } : undefined,\n)\n</script>\n\n<template>\n <div\n class=\"v-data-table\"\n :class=\"rootClass\"\n :style=\"[heightStyle, rootStyle]\"\n :data-variant=\"variant\"\n :data-striped=\"striped ? '' : undefined\"\n :data-sticky-header=\"stickyHeader ? '' : undefined\"\n :data-selectable=\"selectable ? '' : undefined\"\n :data-virtual=\"virtual ? '' : undefined\"\n >\n <div v-if=\"title || subtitle || $slots.header || searchable\" class=\"v-data-table-header\">\n <slot name=\"header\">\n <div v-if=\"title || subtitle\" class=\"v-data-table-titles\">\n <VTypography\n v-if=\"title\"\n :id=\"titleId\"\n as=\"div\"\n variant=\"heading-4\"\n class=\"v-data-table-title\"\n >\n {{ title }}\n </VTypography>\n <VTypography\n v-if=\"subtitle\"\n :id=\"subtitleId\"\n variant=\"subtitle\"\n tone=\"muted\"\n class=\"v-data-table-subtitle\"\n >\n {{ subtitle }}\n </VTypography>\n </div>\n </slot>\n <VInput\n v-if=\"searchable\"\n v-model=\"search\"\n class=\"v-data-table-search\"\n type=\"search\"\n size=\"sm\"\n :icon-start=\"searchIcon\"\n clearable\n :placeholder=\"resolvedSearchPlaceholder\"\n :aria-label=\"resolvedSearchLabel\"\n />\n </div>\n\n <div v-if=\"$slots.toolbar\" class=\"v-data-table-toolbar\">\n <slot name=\"toolbar\" />\n </div>\n\n <!-- What the variant frames: the rows and the footer under them, while the header and the\n toolbar stay outside, on the surface of the page. -->\n <div class=\"v-data-table-frame\">\n <div ref=\"scrollerEl\" class=\"v-data-table-scroller\">\n <table\n ref=\"tableEl\"\n class=\"v-data-table-table\"\n :aria-labelledby=\"tableLabelledBy\"\n :aria-describedby=\"tableDescribedBy\"\n :aria-rowcount=\"ariaRowCount\"\n :aria-busy=\"loadingMore ? 'true' : undefined\"\n v-bind=\"forwardedAttrs\"\n >\n <thead ref=\"theadEl\" class=\"v-data-table-head\">\n <tr :aria-rowindex=\"virtual ? 1 : undefined\">\n <th v-if=\"selectable\" scope=\"col\" class=\"v-data-table-select\">\n <VCheckbox\n :model-value=\"allVisibleSelected\"\n :indeterminate=\"masterIndeterminate\"\n :disabled=\"masterDisabled\"\n :aria-label=\"resolvedSelectAllLabel\"\n @update:model-value=\"toggleMaster\"\n />\n </th>\n <th\n v-for=\"column in columns\"\n :key=\"column.key\"\n scope=\"col\"\n :data-align=\"column.align\"\n :aria-sort=\"ariaSort(column)\"\n >\n <button\n v-if=\"column.sortable\"\n type=\"button\"\n class=\"v-data-table-sort\"\n :data-direction=\"sort?.key === column.key ? sort.direction : undefined\"\n @click=\"toggleSort(column.key)\"\n >\n <slot :name=\"`head-${column.key}`\" :column=\"column\">{{ column.label }}</slot>\n <!-- Decorative, and deliberately so: given no label, an icon hides itself\n from screen readers. What the sort state is, is already carried by\n the heading itself. -->\n <VIcon class=\"v-data-table-sort-icon\" v-bind=\"iconProps(sortIconFor(column))\" />\n </button>\n <template v-else>\n <slot :name=\"`head-${column.key}`\" :column=\"column\">{{ column.label }}</slot>\n </template>\n </th>\n </tr>\n </thead>\n <tbody\n ref=\"tbodyEl\"\n @focusin=\"focusedIndex = rowIndexOf($event.target)\"\n @focusout=\"focusedIndex = rowIndexOf($event.relatedTarget)\"\n >\n <!--\n The order matters: loading is checked before emptiness, so a table waiting for its\n rows never claims there are none.\n -->\n <tr v-if=\"loading && !loadingMore\">\n <td :colspan=\"colCount\" class=\"v-data-table-state\">\n <slot name=\"loading\">\n <!-- The spinner carries the text for a screen reader, so the visible copy is\n hidden from it: read twice, the cell would say it is loading twice. -->\n <span class=\"v-data-table-state-loading\">\n <VSpinner :label=\"resolvedLoadingText\" />\n <span aria-hidden=\"true\">{{ resolvedLoadingText }}</span>\n </span>\n </slot>\n </td>\n </tr>\n <tr v-else-if=\"displayedRows.length === 0\">\n <td :colspan=\"colCount\" class=\"v-data-table-state\">\n <slot name=\"empty\" :search=\"emptySearch\">\n <VEmptyState\n size=\"sm\"\n :icon=\"emptySearch ? searchOffIcon : inboxIcon\"\n :title=\"resolvedEmptyText\"\n />\n </slot>\n </td>\n </tr>\n <template v-else>\n <template\n v-for=\"segment in rowSegments\"\n :key=\"segment.type === 'row' ? visibleIds[segment.index] : segment.key\"\n >\n <tr v-if=\"segment.type === 'spacer'\" class=\"v-data-table-spacer\" aria-hidden=\"true\">\n <td :colspan=\"colCount\" :style=\"{ blockSize: `${segment.size}px` }\" />\n </tr>\n <tr\n v-else\n :ref=\"\n virtual ? (el) => measureRow(el as Element | null, segment.index) : undefined\n \"\n :data-index=\"virtual ? segment.index : undefined\"\n :aria-rowindex=\"virtual ? pageOffset + segment.index + 2 : undefined\"\n :data-stripe=\"striped && segment.index % 2 === 1 ? '' : undefined\"\n :data-selected=\"\n selectable && isSelected(visibleIds[segment.index]!) ? '' : undefined\n \"\n >\n <!--\n The selection is marked with a plain attribute and not with the ARIA selected\n state, which is invalid on the row of a table: it belongs to a grid. What tells\n assistive technology that a row is selected is its checkbox being checked.\n -->\n <td v-if=\"selectable\" class=\"v-data-table-select\">\n <VCheckbox\n :model-value=\"isSelected(visibleIds[segment.index]!)\"\n :aria-label=\"rowSelectLabel(displayedRows[segment.index]!, segment.index)\"\n @update:model-value=\"toggleRow(visibleIds[segment.index]!)\"\n />\n </td>\n <td v-for=\"column in columns\" :key=\"column.key\" :data-align=\"column.align\">\n <slot\n :name=\"`cell-${column.key}`\"\n :row=\"displayedRows[segment.index]!\"\n :value=\"displayedRows[segment.index]![column.key]\"\n :column=\"column\"\n >\n {{ displayedRows[segment.index]![column.key] }}\n </slot>\n </td>\n </tr>\n </template>\n <!--\n A single element for as long as more rows may come: replacing it would cancel the\n observation, and no further rows would be asked for. Hidden from assistive\n technology, which hears `aria-busy` on the table instead.\n -->\n <tr v-if=\"hasMore\" ref=\"sentinelEl\" class=\"v-data-table-more\" aria-hidden=\"true\">\n <td :colspan=\"colCount\">\n <span v-if=\"loading\" class=\"v-data-table-state-loading\">\n <VSpinner />\n <span>{{ resolvedLoadingText }}</span>\n </span>\n </td>\n </tr>\n </template>\n </tbody>\n </table>\n </div>\n\n <!-- The footer has two zones: what is selected on the left, and on the right the page\n size, the range and the pagination, in that order. -->\n <div v-if=\"paginated || selectable\" class=\"v-data-table-footer\">\n <span v-if=\"selectable\" class=\"v-data-table-selection\" aria-live=\"polite\">{{\n selectionSummary\n }}</span>\n <div v-if=\"paginated\" class=\"v-data-table-footer-end\">\n <div v-if=\"perPageOptions?.length\" class=\"v-data-table-per-page\">\n <span class=\"v-data-table-per-page-label\" aria-hidden=\"true\">{{\n resolvedPerPageText\n }}</span>\n <!-- The panel is told to match its trigger, which here replaces the default\n minimum width with something sensible: a menu of \"10\", \"25\", \"50\" has no\n use for the width a menu of commands assumes, and it still cannot end up\n narrower than the button opening it. -->\n <VMenu size=\"sm\" placement=\"top-end\" match-trigger>\n <template #trigger=\"{ triggerProps }\">\n <VButton\n variant=\"ghost\"\n tone=\"neutral\"\n size=\"sm\"\n v-bind=\"triggerProps\"\n :aria-label=\"m.dataTable.perPageValue(resolvedPerPageText, perPage ?? 0)\"\n >\n {{ perPage }}\n <VIcon :name=\"arrowDropDownIcon\" />\n </VButton>\n </template>\n <VMenuItem\n v-for=\"option in perPageOptions\"\n :key=\"option\"\n :label=\"String(option)\"\n :selected=\"option === perPage\"\n @select=\"perPage = option\"\n />\n </VMenu>\n </div>\n <span v-if=\"showRange\" class=\"v-data-table-range\" aria-live=\"polite\">{{\n rangeSummary\n }}</span>\n <!--\n Named after the table rather than with the generic pagination wording: a page holding\n this table and a pagination of its own would otherwise expose two navigation landmarks\n with the same name, and a screen reader user could not tell them apart.\n -->\n <VPagination\n v-model=\"page\"\n :label=\"m.dataTable.pagination\"\n :length=\"pageCount\"\n size=\"sm\"\n item-variant=\"ghost\"\n align=\"end\"\n :total-visible=\"0\"\n edge-controls\n detached\n />\n </div>\n </div>\n </div>\n </div>\n</template>\n\n<style>\n@layer vectis.components {\n .v-data-table {\n /*\n * It does not go through the shared control scale; there is no single control height in a\n * table; which is the same case VAccordion is in. The density comes off every padding.\n */\n --data-table-pad-block: calc(var(--vectis-space-3) - var(--vectis-density-delta));\n --data-table-pad-inline: calc(var(--vectis-space-3) - var(--vectis-density-delta));\n --data-table-head-pad-block: calc(var(--vectis-space-2) - var(--vectis-density-delta));\n\n /* The gutter between the frame and the footer it holds: nothing when the table is\n unframed, so the footer sits flush with the edge, and the cells' own inline padding\n as soon as a frame appears. */\n --data-table-frame-pad: 0px;\n\n font-family: var(--vectis-text-family);\n\n /*\n * Deliberately no `min-block-size: 0` here. Inside a flex column parent too short for it,\n * the automatic minimum is what keeps the table at its natural height instead of letting it\n * be crushed to nothing.\n */\n display: flex;\n flex-direction: column;\n block-size: 100%;\n }\n\n /* The same `min-block-size: 0` as the scrolling area below, one level up. */\n .v-data-table-frame {\n flex: 1 1 auto;\n display: flex;\n flex-direction: column;\n min-block-size: 0;\n }\n\n /*\n * The card. The unframed default has nothing to undo, since it declares no decoration at all;\n * whatever surrounds the table is what provides the surface then. The border is transparent\n * rather than absent on `filled`: forced colours paint it. `elevated` has none, so that the\n * rules between the rows reach the edge its shadow draws.\n */\n .v-data-table:is([data-variant='outline'], [data-variant='elevated'], [data-variant='filled'])\n > .v-data-table-frame {\n --data-table-frame-pad: var(--data-table-pad-inline);\n\n border: 1px solid transparent;\n border-radius: var(--vectis-radius-surface);\n /*\n * `clip` and not `hidden`. Hiding the overflow would make this element a scroll container\n * of its own, and the sticky heading would then anchor to IT rather than to the area that\n * actually scrolls; which is to say it would not stick at all.\n */\n overflow: clip;\n }\n\n .v-data-table[data-variant='outline'] > .v-data-table-frame {\n background: var(--vectis-color-surface);\n border-color: var(--vectis-color-border);\n }\n\n .v-data-table[data-variant='elevated'] > .v-data-table-frame {\n border: none;\n background: var(--vectis-color-surface-raised);\n box-shadow: var(--vectis-shadow-sm);\n }\n\n /* The heading's usual tint is the muted surface itself, which would merge into this fill. */\n .v-data-table[data-variant='filled'] {\n --data-table-head-bg: color-mix(\n in oklab,\n var(--vectis-color-surface-muted),\n var(--vectis-color-text) 4%\n );\n }\n\n .v-data-table[data-variant='filled'] > .v-data-table-frame {\n background: var(--vectis-color-surface-muted);\n }\n\n /*\n * `min-block-size: 0` is load-bearing; a flex item refuses by default to shrink below its\n * content, so without it the area never compresses and the table overflows instead of\n * scrolling.\n */\n .v-data-table-scroller {\n /*\n * Positioned, so it contains the absolutely positioned parts of the cells, a consumer's\n * included: positioned against an ancestor beyond it, they escape its clip and stretch the\n * page.\n */\n position: relative;\n flex: 1 1 auto;\n min-block-size: 0;\n overflow: auto;\n }\n\n /*\n * Unframed, the tinted heading and rows are rounded by the area that already clips them,\n * not by the frame: the footer sits flush with the frame's edges, and a clip there would\n * crop its focus rings.\n */\n .v-data-table[data-variant='flat'] > .v-data-table-frame > .v-data-table-scroller {\n border-radius: var(--vectis-radius-surface);\n }\n\n .v-data-table-header,\n .v-data-table-toolbar {\n flex: none;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--vectis-space-3);\n padding-block-end: var(--vectis-space-3);\n }\n\n .v-data-table-titles {\n display: flex;\n flex-direction: column;\n min-inline-size: 0;\n }\n\n /*\n * It is set through the colour VARIABLE that component reads, and not with a plain colour\n * declaration. That declaration would collide with VTypography's own at equal specificity,\n * and the winner would be decided by whichever sheet the consumer's bundler put last.\n */\n .v-data-table-title {\n --typography-color: var(--vectis-color-text);\n }\n\n /* The search field is given a width of its own, overriding the full width VInput takes\n by default, and is pushed to the end of the row even with no title beside it. The\n selector is qualified by its context, which makes it one step more specific than\n VInput's own rule and therefore independent of the order the two sheets end up in. */\n .v-data-table-header > .v-data-table-search {\n inline-size: var(--vectis-control-size-table-search);\n max-inline-size: 100%;\n margin-inline-start: auto;\n }\n\n .v-data-table-table {\n width: 100%;\n border-collapse: collapse;\n font-size: var(--vectis-text-body-md-size);\n color: var(--vectis-color-text);\n }\n\n .v-data-table-table th {\n padding: var(--data-table-head-pad-block) var(--data-table-pad-inline);\n text-align: start;\n font-size: var(--vectis-text-body-md-size);\n /*\n * The heavier weight distinguishes a heading from the data under it, which is emphasis\n * rather than a typographic role; hence a font token read directly.\n */\n font-weight: var(--vectis-font-weight-semibold);\n color: var(--vectis-color-text-muted);\n /*\n * The heading row gets a tint of its own so it reads apart from the data. `muted` and not\n * `sunken`: the striped rows already take `sunken`, and a heading painted the same would\n * read as one more stripe.\n */\n background-color: var(--data-table-head-bg, var(--vectis-color-surface-muted));\n border-block-end: 1px solid var(--vectis-color-border);\n }\n\n .v-data-table-table td {\n padding: var(--data-table-pad-block) var(--data-table-pad-inline);\n border-block-end: 1px solid var(--vectis-color-border);\n }\n\n .v-data-table-table tbody tr:last-child td {\n border-block-end: none;\n }\n\n .v-data-table-table [data-align='end'] {\n text-align: end;\n }\n\n .v-data-table-table [data-align='center'] {\n text-align: center;\n }\n\n /* The checkbox column is reduced to the width of its content. A table lays its columns\n out automatically, so asking for no width at all is what makes it take the least\n possible. */\n .v-data-table-table .v-data-table-select {\n inline-size: 0;\n }\n\n /* By the row's own index: in the virtual mode, the space standing for hidden rows is a row too. */\n .v-data-table[data-striped] tbody tr[data-stripe] {\n background-color: var(--vectis-color-surface-sunken);\n }\n\n /* Placed after the striping on purpose: the specificity is the same, so it is the order\n that makes a selected row keep its tint on both odd and even rows. */\n .v-data-table[data-selectable] tbody tr[data-selected] {\n background-color: var(--vectis-color-accent-surface);\n }\n\n /* Forced colours flatten both tints to `Canvas`: the stripes are only a reading aid, but\n a selected row would be told apart by its checkbox alone. It draws an inward outline in\n the system selection colour, which the mode keeps. */\n @media (forced-colors: active) {\n .v-data-table[data-selectable] tbody tr[data-selected] {\n outline: var(--vectis-focus-ring-width) solid Highlight;\n outline-offset: calc(-1 * var(--vectis-focus-ring-width));\n }\n }\n\n /*\n * A frozen heading relies on the opaque background every `th` already carries: the rows\n * scroll underneath it, and a consumer restyling that background with a translucent colour\n * will see them through.\n */\n .v-data-table[data-sticky-header] th {\n position: sticky;\n inset-block-start: 0;\n z-index: 1;\n }\n\n .v-data-table-sort {\n /*\n * The icon context for the sort glyph. Without it the icon would fall back to one em; the\n * heading's own text size; and come out visibly smaller than every other icon in the\n * component.\n */\n --vectis-icon-size: var(--vectis-icon-size-md);\n --vectis-icon-opsz: 20;\n\n display: inline-flex;\n align-items: center;\n gap: var(--vectis-space-1);\n border: none;\n background: transparent;\n padding: 0;\n color: inherit;\n font: inherit;\n cursor: pointer;\n /* Seen only on the focus ring: the control radius capped at half a line, VBreadcrumb's\n link recipe, since a heading that wraps would otherwise round to half its height. */\n border-radius: min(var(--vectis-radius-interactive), 0.5lh);\n }\n\n .v-data-table-sort:hover {\n color: var(--vectis-color-text);\n }\n\n .v-data-table-sort:focus-visible {\n outline: var(--vectis-focus-ring-width) solid var(--vectis-focus-ring-color);\n outline-offset: var(--vectis-focus-ring-offset);\n }\n\n /* The glyph stays faint on every column that merely COULD be sorted: it announces that\n the heading can be clicked without competing for attention with the one column\n actually carrying the order. */\n .v-data-table-sort-icon {\n opacity: 0.35;\n }\n\n .v-data-table-sort[data-direction] .v-data-table-sort-icon {\n opacity: 1;\n }\n\n /* The table corrects its scroll itself when a row above the view changes height. */\n .v-data-table[data-virtual] .v-data-table-scroller {\n overflow-anchor: none;\n }\n\n .v-data-table-table .v-data-table-spacer td {\n padding: 0;\n border: none;\n }\n\n /*\n * The foot of the rows: the marker watched for their end, and where the next rows are said\n * to be loading. It keeps a real height, a box of none making the crossing unreliable.\n */\n .v-data-table-table .v-data-table-more td {\n block-size: var(--vectis-control-height-md);\n padding: var(--vectis-space-2);\n border: none;\n text-align: center;\n color: var(--vectis-color-text-muted);\n }\n\n .v-data-table-state {\n padding: var(--vectis-space-6);\n text-align: center;\n color: var(--vectis-color-text-muted);\n }\n\n /*\n * The cell already pads the default empty state. `[data-size]` lifts the selector above\n * VEmptyState's own size rules, whose sheet may load after this one.\n */\n .v-data-table-state > .v-empty-state[data-size] {\n padding: 0;\n }\n\n .v-data-table-state-loading {\n display: inline-flex;\n align-items: center;\n gap: var(--vectis-space-2);\n }\n\n .v-data-table-footer {\n flex: none;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: var(--vectis-space-4);\n padding-block-start: var(--vectis-space-3);\n padding-block-end: var(--data-table-frame-pad);\n padding-inline: var(--data-table-frame-pad);\n }\n\n /*\n * The right-hand zone is pushed to the edge by an automatic margin rather than by an\n * alignment on the footer. The two zones are siblings in the same row, and the count on the\n * left has to stay at the OPPOSITE edge: any alignment set on the footer would move both of\n * them together.\n */\n .v-data-table-footer-end {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: var(--vectis-space-4);\n margin-inline-start: auto;\n }\n\n .v-data-table-selection,\n .v-data-table-range,\n .v-data-table-per-page-label {\n font-size: var(--vectis-text-body-md-size);\n color: var(--vectis-color-text-muted);\n }\n\n .v-data-table-per-page {\n display: flex;\n align-items: center;\n gap: var(--vectis-space-2);\n }\n}\n</style>\n"],"mappings":""}