Skip to content

Commit f38a733

Browse files
committed
feat: add support for column tooltips
1 parent b523252 commit f38a733

File tree

6 files changed

+63
-3
lines changed

6 files changed

+63
-3
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-screener",
3-
"version": "0.15.13",
3+
"version": "0.15.14",
44
"type": "module",
55
"description": "Easily search and filter data in Vue3.",
66
"author": "Francis Ashley",
@@ -30,6 +30,7 @@
3030
"lint": "eslint src --ext .ts,.vue"
3131
},
3232
"dependencies": {
33+
"floating-vue": "^5.2.2",
3334
"vue": "^3.4.27"
3435
},
3536
"devDependencies": {

src/components/table/VueScreenerTableHeadCell.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
Boolean(column.isSortable && getSortDirection(column.field)) && props.sortingClass,
1414
]"
1515
@click="handleClickColumnHeader(column)"
16-
:title="text"
1716
>
1817
<SortIcon v-if="column.isSortable && getSortDirection(column.field)" :direction="getSortDirection(column.field)" />
1918
<slot>{{ text }}</slot>
19+
<Icon v-if="column.info" icon="codicon:info" class="vsc-ml-auto vsc-min-w-3 vsc-min-h-3" v-tooltip="column.info" />
2020
</VueScreenerTableCell>
2121
</template>
2222

@@ -26,6 +26,8 @@ import type { IVueScreener, Column } from '../../interfaces/vue-screener'
2626
import VueScreenerTableCell from '../table/VueScreenerTableCell.vue'
2727
import SortIcon from '../icons/SortIcon.vue'
2828
import { twMerge } from '../../utils/tailwind-merge.utils'
29+
import { Icon } from '@iconify/vue'
30+
import { vTooltip } from 'floating-vue'
2931
3032
const props = defineProps<{
3133
screener: IVueScreener

src/interfaces/vue-screener.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export type Column = {
6868
isOverlayingColumns?: boolean // Flag indicating if this pinned column should show overlay shadow
6969
truncate?: boolean // Flag indicating if the content should be truncated with an ellipsis
7070
invertSort?: boolean // When true, reverses sort logic while maintaining arrow direction
71+
info?: string // Display an info tooltip in the column header
7172
format?: <T>(value: T, row: Row) => string // Format the value of the field.
7273
}
7374

src/stories/2-configure-columns/8-format-column.story.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Story title="9. Format column" source="-">
2+
<Story title="8. Format column" source="-">
33
<div class="vsc-p-4 vsc-bg-zinc-800">
44
<VueScreener
55
title="Results"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
<Story title="9. Column tooltips" source="-">
3+
<div class="vsc-p-4 vsc-bg-zinc-800">
4+
<VueScreener
5+
title="Results"
6+
:data="baseData"
7+
:columns="{
8+
id: { info: 'The ID column' },
9+
first_name: { info: 'The First Name column' },
10+
last_name: { info: 'The Last Name column' },
11+
full_name: { info: 'The Full Name column' },
12+
email: { info: 'The Email column' },
13+
gender: { info: 'The Gender column' },
14+
ip_address: { info: 'The IP column' },
15+
}"
16+
/>
17+
</div>
18+
</Story>
19+
</template>
20+
21+
<script lang="ts" setup>
22+
import { VueScreener } from '../../index'
23+
import baseData from '../../fixtures/data.json'
24+
</script>

yarn.lock

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,25 @@
378378
resolved "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz"
379379
integrity sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==
380380

381+
"@floating-ui/core@^1.1.0":
382+
version "1.6.8"
383+
resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.6.8.tgz#aa43561be075815879305965020f492cdb43da12"
384+
integrity sha512-7XJ9cPU+yI2QeLS+FCSlqNFZJq8arvswefkZrYI1yQBbftw6FyrZOxYSh+9S7z7TpeWlRt9zJ5IhM1WIL334jA==
385+
dependencies:
386+
"@floating-ui/utils" "^0.2.8"
387+
388+
"@floating-ui/dom@~1.1.1":
389+
version "1.1.1"
390+
resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.1.1.tgz#66aa747e15894910869bf9144fc54fc7d6e9f975"
391+
integrity sha512-TpIO93+DIujg3g7SykEAGZMDtbJRrmnYRCNYSjJlvIbGhBjRSNTLVbNeDQBrzy9qDgUbiWdc7KA0uZHZ2tJmiw==
392+
dependencies:
393+
"@floating-ui/core" "^1.1.0"
394+
395+
"@floating-ui/utils@^0.2.8":
396+
version "0.2.8"
397+
resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.2.8.tgz#21a907684723bbbaa5f0974cf7730bd797eb8e62"
398+
integrity sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig==
399+
381400
"@histoire/app@^0.17.17":
382401
version "0.17.17"
383402
resolved "https://registry.npmjs.org/@histoire/app/-/app-0.17.17.tgz"
@@ -1931,6 +1950,14 @@ [email protected]:
19311950
resolved "https://registry.npmjs.org/flexsearch/-/flexsearch-0.7.21.tgz"
19321951
integrity sha512-W7cHV7Hrwjid6lWmy0IhsWDFQboWSng25U3VVywpHOTJnnAZNPScog67G+cVpeX9f7yDD21ih0WDrMMT+JoaYg==
19331952

1953+
floating-vue@^5.2.2:
1954+
version "5.2.2"
1955+
resolved "https://registry.yarnpkg.com/floating-vue/-/floating-vue-5.2.2.tgz#e263932042753f59f3e36e7c1188f3f3e272a539"
1956+
integrity sha512-afW+h2CFafo+7Y9Lvw/xsqjaQlKLdJV7h1fCHfcYQ1C4SVMlu7OAekqWgu5d4SgvkBVU0pVpLlVsrSTBURFRkg==
1957+
dependencies:
1958+
"@floating-ui/dom" "~1.1.1"
1959+
vue-resize "^2.0.0-alpha.1"
1960+
19341961
foreground-child@^3.1.0:
19351962
version "3.3.0"
19361963
resolved "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz"
@@ -3659,6 +3686,11 @@ vue-eslint-parser@^9.4.2, vue-eslint-parser@^9.4.3:
36593686
lodash "^4.17.21"
36603687
semver "^7.3.6"
36613688

3689+
vue-resize@^2.0.0-alpha.1:
3690+
version "2.0.0-alpha.1"
3691+
resolved "https://registry.yarnpkg.com/vue-resize/-/vue-resize-2.0.0-alpha.1.tgz#43eeb79e74febe932b9b20c5c57e0ebc14e2df3a"
3692+
integrity sha512-7+iqOueLU7uc9NrMfrzbG8hwMqchfVfSzpVlCMeJQe4pyibqyoifDNbKTZvwxZKDvGkB+PdFeKvnGZMoEb8esg==
3693+
36623694
vue-tsc@^2.0.29:
36633695
version "2.0.29"
36643696
resolved "https://registry.yarnpkg.com/vue-tsc/-/vue-tsc-2.0.29.tgz#bf7e9605af9fadec7fd6037d242217f5c6ad2c3b"

0 commit comments

Comments
 (0)