|
1 | 1 | <template> |
2 | 2 | <div class="vue-ui-table-main" :style="`font-family: ${FINAL_CONFIG.fontFamily}`"> |
3 | | - <div class="vue-ui-table-export-hub" v-if="FINAL_CONFIG.style.exportMenu.show"> |
| 3 | + <div class="vue-ui-table-export-hub" |
| 4 | + :style="{ top: exportButtonTop + 'px' }" v-if="FINAL_CONFIG.style.exportMenu.show"> |
4 | 5 | <button @click="isExportRequest = !isExportRequest" v-html="icons.export" |
5 | 6 | :style="`background:${FINAL_CONFIG.style.exportMenu.backgroundColor};color:${FINAL_CONFIG.style.exportMenu.color}`" /> |
6 | 7 | <div class="vue-ui-table-export-hub-dropdown" :data-is-open="isExportRequest || 'false'" |
|
48 | 49 | </div> |
49 | 50 | <div class="vue-ui-table__wrapper" :style="`max-height:${FINAL_CONFIG.maxHeight}px`" ref="tableWrapper"> |
50 | 51 | <table class="vue-ui-table"> |
| 52 | + <caption |
| 53 | + class="vue-ui-table__caption" |
| 54 | + ref="tableCaption" |
| 55 | + v-if="FINAL_CONFIG.style.title.text" |
| 56 | + :style="{ |
| 57 | + textAlign: FINAL_CONFIG.style.title.textAlign, |
| 58 | + paddingLeft: FINAL_CONFIG.style.title.paddingLeft + 'px', |
| 59 | + paddingRight: FINAL_CONFIG.style.title.paddingRight + 'px', |
| 60 | + backgroundColor: FINAL_CONFIG.style.title.backgroundColor, |
| 61 | + boxShadow: `${FINAL_CONFIG.style.title.backgroundColor} -1px 0px 0px 0px` |
| 62 | + }" |
| 63 | + > |
| 64 | + <span |
| 65 | + :style="{ |
| 66 | + fontSize: FINAL_CONFIG.style.title.fontSize + 'px', |
| 67 | + fontWeight: FINAL_CONFIG.style.title.bold ? 'bold' : 'normal', |
| 68 | + color: FINAL_CONFIG.style.title.color |
| 69 | + }" |
| 70 | + > |
| 71 | + {{ FINAL_CONFIG.style.title.text }} |
| 72 | + </span> |
| 73 | + <template v-if="FINAL_CONFIG.style.title.subtitle.text"> |
| 74 | + <br> |
| 75 | + <span |
| 76 | + :style="{ |
| 77 | + fontSize: FINAL_CONFIG.style.title.subtitle.fontSize, |
| 78 | + fontWeight: FINAL_CONFIG.style.title.subtitle.bold ? 'bold' : 'normal', |
| 79 | + color: FINAL_CONFIG.style.title.subtitle.color |
| 80 | + }" |
| 81 | + > |
| 82 | + {{ FINAL_CONFIG.style.title.subtitle.text }} |
| 83 | + </span> |
| 84 | + </template> |
| 85 | + </caption> |
51 | 86 | <!-- TABLE HEAD --> |
52 | 87 | <thead id="tableHead" class="vue-ui-table__head" :style="{ |
53 | 88 | background: FINAL_CONFIG.style.th.backgroundColor, |
54 | | - boxShadow: `-1px 0 0 ${FINAL_CONFIG.style.th.backgroundColor}` |
| 89 | + boxShadow: `-1px 0 0 ${FINAL_CONFIG.style.th.backgroundColor}`, |
| 90 | + top: exportButtonTop - 3 + 'px' |
55 | 91 | }"> |
56 | 92 | <!-- HEADERS --> |
57 | 93 | <tr> |
@@ -573,6 +609,7 @@ import { useConfig } from "../useConfig"; |
573 | 609 | import VueUiXy from "./vue-ui-xy.vue"; |
574 | 610 | import VueUiDonut from "./vue-ui-donut.vue"; |
575 | 611 | import BaseIcon from "../atoms/BaseIcon.vue"; |
| 612 | +import { computed, ref } from "vue"; |
576 | 613 |
|
577 | 614 | export default { |
578 | 615 | name: "vue-ui-table", |
@@ -691,6 +728,19 @@ export default { |
691 | 728 | filename: '', |
692 | 729 | } |
693 | 730 | }, |
| 731 | + setup() { |
| 732 | + const tableCaption = ref(null); |
| 733 | +
|
| 734 | + const exportButtonTop = computed(() => { |
| 735 | + if (!tableCaption.value) return 3; |
| 736 | + return tableCaption.value.getBoundingClientRect().height + 3; |
| 737 | + }); |
| 738 | +
|
| 739 | + return { |
| 740 | + tableCaption, |
| 741 | + exportButtonTop |
| 742 | + } |
| 743 | + }, |
694 | 744 | mounted() { |
695 | 745 | if (this.dataset.header.length === 0) { |
696 | 746 | throw new Error("vue-ui-table error: missing header data.\nProvide an array of objects of type:\n{\n name: string;\n type: string; ('text' | 'numeric' | 'date')\n average: boolean;\n decimals: number | undefined;\n sum: boolean;\n isSort:boolean;\n isSearch: boolean;\n isMultiselect: boolean;\n isPercentage: boolean;\n percentageTo: string; (or '')\n}"); |
@@ -1866,6 +1916,13 @@ export default { |
1866 | 1916 | top: 0; |
1867 | 1917 | } |
1868 | 1918 |
|
| 1919 | +.vue-ui-table-main caption { |
| 1920 | + caption-side: top; |
| 1921 | + position: sticky; |
| 1922 | + top: 0; |
| 1923 | + z-index: 2; |
| 1924 | +} |
| 1925 | +
|
1869 | 1926 | .vue-ui-table { |
1870 | 1927 | width: 100%; |
1871 | 1928 | position: relative; |
@@ -2396,7 +2453,6 @@ button.th-reset:not(:disabled) { |
2396 | 2453 | .vue-ui-table-main .vue-ui-table-export-hub { |
2397 | 2454 | left: 20px; |
2398 | 2455 | position: absolute; |
2399 | | - top: 3px; |
2400 | 2456 | z-index: 1001; |
2401 | 2457 | } |
2402 | 2458 |
|
|
0 commit comments