edvoyui-component-library-test-flight 0.0.170 → 0.0.173
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.
- package/dist/{edvoy-ui.cjs.js → library-vue-ts.cjs.js} +26 -26
- package/dist/{edvoy-ui.css → library-vue-ts.css} +1 -1
- package/dist/{edvoy-ui.es.js → library-vue-ts.es.js} +2262 -2249
- package/dist/library-vue-ts.umd.js +168 -0
- package/dist/selectSearch/EUISelectSearch.vue.d.ts.map +1 -0
- package/package.json +10 -11
- package/src/App.vue +16 -0
- package/src/App.vue.js.map +1 -0
- package/src/assets/fonts/gilroy/GilroyBold/font.woff +0 -0
- package/src/assets/fonts/gilroy/GilroyBold/font.woff2 +0 -0
- package/src/assets/fonts/gilroy/GilroyBoldItalic/font.woff +0 -0
- package/src/assets/fonts/gilroy/GilroyBoldItalic/font.woff2 +0 -0
- package/src/assets/fonts/gilroy/GilroyExtraBold/font.woff +0 -0
- package/src/assets/fonts/gilroy/GilroyExtraBold/font.woff2 +0 -0
- package/src/assets/fonts/gilroy/GilroyExtraBoldItalic/font.woff +0 -0
- package/src/assets/fonts/gilroy/GilroyExtraBoldItalic/font.woff2 +0 -0
- package/src/assets/fonts/gilroy/GilroyMedium/font.woff +0 -0
- package/src/assets/fonts/gilroy/GilroyMedium/font.woff2 +0 -0
- package/src/assets/fonts/gilroy/GilroyRegular/font.woff +0 -0
- package/src/assets/fonts/gilroy/GilroyRegular/font.woff2 +0 -0
- package/src/assets/fonts/gilroy/GilroySemiBold/font.woff +0 -0
- package/src/assets/fonts/gilroy/GilroySemiBold/font.woff2 +0 -0
- package/src/assets/fonts/inter/Inter-Bold.woff +0 -0
- package/src/assets/fonts/inter/Inter-Bold.woff2 +0 -0
- package/src/assets/fonts/inter/Inter-Italic.woff +0 -0
- package/src/assets/fonts/inter/Inter-Italic.woff2 +0 -0
- package/src/assets/fonts/inter/Inter-Medium.woff +0 -0
- package/src/assets/fonts/inter/Inter-Medium.woff2 +0 -0
- package/src/assets/fonts/inter/Inter-MediumItalic.woff +0 -0
- package/src/assets/fonts/inter/Inter-MediumItalic.woff2 +0 -0
- package/src/assets/fonts/inter/Inter-Regular.woff +0 -0
- package/src/assets/fonts/inter/Inter-Regular.woff2 +0 -0
- package/src/assets/fonts/inter/Inter-SemiBold.woff +0 -0
- package/src/assets/fonts/inter/Inter-SemiBold.woff2 +0 -0
- package/src/assets/fonts/inter/Inter-SemiBoldItalic.woff +0 -0
- package/src/assets/fonts/inter/Inter-SemiBoldItalic.woff2 +0 -0
- package/src/assets/images/search-nodata.png +0 -0
- package/src/assets/scss/body.scss +25 -0
- package/src/assets/svg/CheckTick.vue +21 -0
- package/src/assets/svg/CheckTick.vue.js.map +1 -0
- package/src/assets/svg/ChevronBigDown.vue +22 -0
- package/src/assets/svg/ChevronBigDown.vue.js.map +1 -0
- package/src/assets/svg/ChevronDownSolid.vue +19 -0
- package/src/assets/svg/ChevronDownSolid.vue.js.map +1 -0
- package/src/assets/svg/ChevronDownStroke.vue +22 -0
- package/src/assets/svg/ChevronDownStroke.vue.js.map +1 -0
- package/src/assets/svg/ChevronDownStrokeSolid.vue +19 -0
- package/src/assets/svg/ChevronDownStrokeSolid.vue.js.map +1 -0
- package/src/assets/svg/SearchBigZoomIn.vue +21 -0
- package/src/assets/svg/SearchBigZoomIn.vue.js.map +1 -0
- package/src/assets/svg/SortArrow.vue +24 -0
- package/src/assets/svg/SortArrow.vue.js.map +1 -0
- package/src/assets/svg/Student.vue +30 -0
- package/src/assets/svg/Student.vue.js.map +1 -0
- package/src/assets/svg/partner.vue +33 -0
- package/src/assets/svg/partner.vue.js.map +1 -0
- package/src/assets/svg/people.vue +25 -0
- package/src/assets/svg/people.vue.js.map +1 -0
- package/src/assets/vue.svg +1 -0
- package/src/components/HelloWorld.vue +1974 -0
- package/src/components/HelloWorld.vue.js.map +1 -0
- package/src/components/accordion/EUIAccordion.stories.ts +204 -0
- package/src/components/accordion/EUIAccordion.vue +152 -0
- package/src/components/accordion/EUIAccordion.vue.js.map +1 -0
- package/src/components/alerts/EUIAlerts.stories.ts +217 -0
- package/src/components/alerts/EUIAlerts.vue +194 -0
- package/src/components/alerts/EUIAlerts.vue.js.map +1 -0
- package/src/components/avatar/EUIAvatar.stories.ts +157 -0
- package/src/components/avatar/EUIAvatar.vue +96 -0
- package/src/components/avatar/EUIAvatar.vue.js.map +1 -0
- package/src/components/breadcrumb/EUIBreadcrumb.stories.ts +75 -0
- package/src/components/breadcrumb/EUIBreadcrumb.vue +59 -0
- package/src/components/breadcrumb/EUIBreadcrumb.vue.js.map +1 -0
- package/src/components/button/EUIButton.stories.ts +270 -0
- package/src/components/button/EUIButton.vue +154 -0
- package/src/components/button/EUIButton.vue.js.map +1 -0
- package/src/components/button/EUIButtonGroup.vue +287 -0
- package/src/components/button/EUIButtonGroup.vue.js.map +1 -0
- package/src/components/button/buttonAnimateTab.vue +74 -0
- package/src/components/button/buttonAnimateTab.vue.js.map +1 -0
- package/src/components/checkbox/EUICheckbox.stories.ts +58 -0
- package/src/components/checkbox/EUICheckbox.vue +110 -0
- package/src/components/checkbox/EUICheckbox.vue.js.map +1 -0
- package/src/components/datepicker/EUIDatepicker.stories.ts +492 -0
- package/src/components/datepicker/EUIDatepicker.vue +295 -0
- package/src/components/datepicker/EUIDatepicker.vue.js.map +1 -0
- package/src/components/delete.vue +262 -0
- package/src/components/delete.vue.js.map +1 -0
- package/src/components/dragModal/EUIDrag.vue +179 -0
- package/src/components/dragModal/EUIDrag.vue.js.map +1 -0
- package/src/components/dropdown/EUIMultiDropdown.stories.ts +294 -0
- package/src/components/dropdown/EUIMultiDropdown.vue +187 -0
- package/src/components/dropdown/EUIMultiDropdown.vue.js.map +1 -0
- package/src/components/errorMessage/EUIErrorMessage.scss +0 -0
- package/src/components/errorMessage/EUIErrorMessage.stories.ts +41 -0
- package/src/components/errorMessage/EUIErrorMessage.vue +25 -0
- package/src/components/errorMessage/EUIErrorMessage.vue.js.map +1 -0
- package/src/components/index.js.map +1 -0
- package/src/components/index.ts +62 -0
- package/src/components/input/EUIInput.stories.ts +387 -0
- package/src/components/input/EUIInput.vue +223 -0
- package/src/components/input/EUIInput.vue.js.map +1 -0
- package/src/components/input/EUINumberInput.vue +250 -0
- package/src/components/loader/EUICircleLoader.vue +31 -0
- package/src/components/loader/EUICircleLoader.vue.js.map +1 -0
- package/src/components/loader/EUICubeLoader.vue +237 -0
- package/src/components/loader/EUICubeLoader.vue.js.map +1 -0
- package/src/components/loader/EUILoader.stories.ts +99 -0
- package/src/components/loader/EUILoader.vue +17 -0
- package/src/components/loader/EUILoader.vue.js.map +1 -0
- package/src/components/loader/EUISquareLoader.vue +47 -0
- package/src/components/loader/EUISquareLoader.vue.js.map +1 -0
- package/src/components/modal/EUIModal.stories.ts +412 -0
- package/src/components/modal/EUIModal.vue +224 -0
- package/src/components/modal/EUIModal.vue.js.map +1 -0
- package/src/components/pillSelect/EUIPillSelect.stories.ts +74 -0
- package/src/components/pillSelect/EUIPillSelect.vue +149 -0
- package/src/components/pillSelect/EUIPillSelect.vue.js.map +1 -0
- package/src/components/popover/EUIPopover.stories.ts +306 -0
- package/src/components/popover/EUIPopover.vue +297 -0
- package/src/components/popover/EUIPopover.vue.js.map +1 -0
- package/src/components/radio/EUIRadio.stories.ts +54 -0
- package/src/components/radio/EUIRadio.vue +75 -0
- package/src/components/radio/EUIRadio.vue.js.map +1 -0
- package/src/components/searchInput/EUISearch.stories.ts +24 -0
- package/src/components/searchInput/EUISearch.vue +223 -0
- package/src/components/searchInput/EUISearch.vue.js.map +1 -0
- package/src/components/searchTagSelect/EUISearchTagSelect.vue +642 -0
- package/src/components/searchTagSelect/EUISearchTagSelect.vue.js.map +1 -0
- package/src/components/searchTagSelect/SearchInput.vue +167 -0
- package/src/components/searchTagSelect/SearchInput.vue.js.map +1 -0
- package/src/components/searchexpand/EUISearchExpand.vue +148 -0
- package/src/components/searchexpand/EUISearchExpand.vue.js.map +1 -0
- package/src/components/searchexpand/EUISearchToggle.vue +86 -0
- package/src/components/searchexpand/EUISearchToggle.vue.js.map +1 -0
- package/src/components/select/EUISelect.stories.ts +101 -0
- package/src/components/select/EUISelect.vue +1092 -0
- package/src/components/select/EUISelect.vue.js.map +1 -0
- package/src/components/selectSearch/EUISelectSearch.vue +23 -0
- package/src/components/selectSearch/EUISelectSearch.vue.js.map +1 -0
- package/src/components/slideover/EUISlideover.stories.ts +318 -0
- package/src/components/slideover/EUISlideover.vue +207 -0
- package/src/components/slideover/EUISlideover.vue.js.map +1 -0
- package/src/components/stepperTimeline/EUIStepperHorizontal.vue +242 -0
- package/src/components/stepperTimeline/EUIStepperHorizontal.vue.js.map +1 -0
- package/src/components/stepperTimeline/EUIStepperTimeline.stories.ts +54 -0
- package/src/components/stepperTimeline/EUIStepperTimeline.vue +16 -0
- package/src/components/stepperTimeline/EUIStepperTimeline.vue.js.map +1 -0
- package/src/components/stepperTimeline/EUIStepperVertical.vue +112 -0
- package/src/components/stepperTimeline/EUIStepperVertical.vue.js.map +1 -0
- package/src/components/table/ColumnResizeTable.vue +740 -0
- package/src/components/table/ColumnResizeTable.vue.js.map +1 -0
- package/src/components/table/EUIDashboardTable.vue +514 -0
- package/src/components/table/EUIDashboardTable.vue.js.map +1 -0
- package/src/components/table/EUIPageLimit.vue +66 -0
- package/src/components/table/EUIPageLimit.vue.js.map +1 -0
- package/src/components/table/EUIPagination.vue +175 -0
- package/src/components/table/EUIPagination.vue.js.map +1 -0
- package/src/components/table/EUIStudentPagination.vue +172 -0
- package/src/components/table/EUIStudentPagination.vue.js.map +1 -0
- package/src/components/table/EUITable.stories.ts +300 -0
- package/src/components/table/EUITable.vue +559 -0
- package/src/components/table/EUITable.vue.js.map +1 -0
- package/src/components/table/EUITableCheckbox.vue +98 -0
- package/src/components/table/EUITableCheckbox.vue.js.map +1 -0
- package/src/components/table/GrowthTable.vue +575 -0
- package/src/components/table/GrowthTable.vue.js.map +1 -0
- package/src/components/table/GrowthTableView.vue +108 -0
- package/src/components/table/GrowthTableView.vue.js.map +1 -0
- package/src/components/table/ResizeTableview.vue +198 -0
- package/src/components/table/ResizeTableview.vue.js.map +1 -0
- package/src/components/table/UCheckbox.vue +169 -0
- package/src/components/table/UCheckbox.vue.js.map +1 -0
- package/src/components/table/UTable.scss +69 -0
- package/src/components/table/UTable.vue +611 -0
- package/src/components/table/UTable.vue.js.map +1 -0
- package/src/components/table/UTableview.vue +189 -0
- package/src/components/table/UTableview.vue.js.map +1 -0
- package/src/components/tabs/EUITabOutline.vue +263 -0
- package/src/components/tabs/EUITabOutline.vue.js.map +1 -0
- package/src/components/tabs/EUITabs.vue +226 -0
- package/src/components/tabs/EUITabs.vue.js.map +1 -0
- package/src/components/tabs/EUItabs.stories.ts +137 -0
- package/src/components/tag/EUITag.stories.ts +53 -0
- package/src/components/tag/EUITag.vue +88 -0
- package/src/components/tag/EUITag.vue.js.map +1 -0
- package/src/components/telephone/EUITelephone.stories.ts +358 -0
- package/src/components/telephone/EUITelephone.vue +299 -0
- package/src/components/telephone/EUITelephone.vue.js.map +1 -0
- package/src/components/textArea/EUITextArea.stories.ts +134 -0
- package/src/components/textArea/EUITextArea.vue +155 -0
- package/src/components/textArea/EUITextArea.vue.js.map +1 -0
- package/src/components/timeLine/EUITimeLine.stories.ts +247 -0
- package/src/components/timeLine/EUITimeLine.vue +148 -0
- package/src/components/timeLine/EUITimeLine.vue.js.map +1 -0
- package/src/components/toggle/EUIToggle.stories.ts +63 -0
- package/src/components/toggle/EUIToggle.vue +101 -0
- package/src/components/toggle/EUIToggle.vue.js.map +1 -0
- package/src/components/tooltip/EUITooltip.stories.ts +53 -0
- package/src/components/tooltip/EUITooltip.vue +111 -0
- package/src/components/tooltip/EUITooltip.vue.js.map +1 -0
- package/src/components/uidemo/select-com.vue +120 -0
- package/src/components/uidemo/select-com.vue.js.map +1 -0
- package/src/data/books.js.map +1 -0
- package/src/data/books.ts +163 -0
- package/src/data/country.ts +56 -0
- package/src/data/tab.js.map +1 -0
- package/src/data/tab.ts +40 -0
- package/src/data/table.js.map +1 -0
- package/src/data/table.ts +5654 -0
- package/src/main.js.map +1 -0
- package/src/main.ts +5 -0
- package/src/style.scss +186 -0
- package/src/utils/helpers.js.map +1 -0
- package/src/utils/helpers.ts +30 -0
- package/src/utils/lodash.js.map +1 -0
- package/src/utils/lodash.ts +9 -0
- package/src/utils/types.js.map +1 -0
- package/src/utils/types.ts +9 -0
- package/src/vite-env.d.ts +5 -0
- package/dist/EUISelectSearch.vue.d.ts.map +0 -1
- package/dist/edvoy-ui.umd.js +0 -168
- /package/dist/{EUISelectSearch.vue.d.ts → selectSearch/EUISelectSearch.vue.d.ts} +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label class="table-checkbox">
|
|
3
|
+
<input v-model="selected" type="checkbox" :value="value" v-bind="mergedAttrs" @change="onChange" />
|
|
4
|
+
<span class="check-icon">
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
class="size-4"
|
|
8
|
+
viewBox="0 0 20 20"
|
|
9
|
+
fill="currentColor"
|
|
10
|
+
stroke="currentColor"
|
|
11
|
+
stroke-width="0.6"
|
|
12
|
+
>
|
|
13
|
+
<path
|
|
14
|
+
fill-rule="evenodd"
|
|
15
|
+
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
|
|
16
|
+
clip-rule="evenodd"
|
|
17
|
+
></path>
|
|
18
|
+
</svg>
|
|
19
|
+
</span>
|
|
20
|
+
</label>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script setup lang="ts">
|
|
24
|
+
import { computed, ref, useAttrs, watch } from 'vue';
|
|
25
|
+
|
|
26
|
+
const props = defineProps({
|
|
27
|
+
indeterminate: Boolean,
|
|
28
|
+
checked: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: false
|
|
31
|
+
},
|
|
32
|
+
value: {
|
|
33
|
+
default: null
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const emit = defineEmits(['change', 'update:checked'])
|
|
38
|
+
const isIndeterminate = ref(props.indeterminate)
|
|
39
|
+
|
|
40
|
+
watch(() => props.indeterminate, (val) => {
|
|
41
|
+
isIndeterminate.value = val
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const selected = computed({
|
|
45
|
+
get() {
|
|
46
|
+
return props.checked
|
|
47
|
+
},
|
|
48
|
+
set(val) {
|
|
49
|
+
emit('update:checked', val)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const onChange = (event: Event) => {
|
|
54
|
+
emit('change', event);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const isActive = computed(() => {
|
|
58
|
+
const modelIsArray = Array.isArray(props.checked) && props.checked.length !== 0
|
|
59
|
+
const sameValue = (element: any) => element === props.value
|
|
60
|
+
if (modelIsArray) {
|
|
61
|
+
return props.checked.some(sameValue)
|
|
62
|
+
}
|
|
63
|
+
return props.checked === true
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const attrs = useAttrs()
|
|
67
|
+
const computedTabIndex = computed(() => (attrs.disabled ? -1 : 0))
|
|
68
|
+
|
|
69
|
+
const mergedAttrs = computed(() => ({
|
|
70
|
+
...attrs,
|
|
71
|
+
tabindex: computedTabIndex.value,
|
|
72
|
+
role: 'checkbox',
|
|
73
|
+
// "aria-checked": isIndeterminate.value ? "mixed" : isActive.value.toString(),
|
|
74
|
+
// "aria-disabled": attrs.disabled || undefined,
|
|
75
|
+
}))
|
|
76
|
+
|
|
77
|
+
watch(isActive, () => {
|
|
78
|
+
if (props.indeterminate) {
|
|
79
|
+
isIndeterminate.value = false
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<style lang="scss">
|
|
85
|
+
.table-checkbox {
|
|
86
|
+
@apply size-10 relative flex items-center justify-center rounded-full cursor-pointer z-10 before:content-[''] before:transform before:translate-x-1/2 before:-translate-y-1/2 before:z-[-1] before:absolute before:top-1/2 before:right-1/2 before:block before:size-10 before:rounded-full before:bg-violet-100 before:opacity-0 before:transition-opacity hover:before:opacity-75;
|
|
87
|
+
|
|
88
|
+
& > input[type='checkbox'] {
|
|
89
|
+
@apply size-5 relative border border-solid border-gray-400 cursor-pointer appearance-none rounded-md z-0 accent-violet-600 checked:border-violet-600 checked:bg-violet-600 focus-within:outline-none focus-within:border-2 focus-within:border-violet-600;
|
|
90
|
+
}
|
|
91
|
+
& .check-icon {
|
|
92
|
+
@apply absolute top-1/2 right-1/2 transform translate-x-1/2 -translate-y-1/2 text-white transition-opacity opacity-0 pointer-events-none;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
.table-checkbox input[type='checkbox']:checked ~ .check-icon {
|
|
96
|
+
@apply opacity-100;
|
|
97
|
+
}
|
|
98
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EUITableCheckbox.vue.js","sourceRoot":"","sources":["EUITableCheckbox.vue"],"names":[],"mappings":"AAAA,OAmGO,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAGrD,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,GAAG,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/H,MAAM,KAAK,GAAG,WAAW,CAAC;IACxB,aAAa,EAAE,OAAO;IACtB,OAAO,EAAE;QACP,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,KAAK;KACf;IACD,KAAK,EAAE;QACL,OAAO,EAAE,IAAI;KACd;CACF,CAAC,CAAA;AAEF,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAA;AACt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AK;QACX,KAAK,EAAE,EAA0C;KACjD,CAAC;AACF,CAAC;AAAA,CAAC;AACF,MAAM,UAAU,GAAG,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC;IACzD,KAAK;QACL,OAAO;YACP,QAAQ,EAAE,QAA2B;YACrC,QAAQ,EAAE,QAA2B;YACrC,WAAW,EAAE,WAAiC;SAC7C,CAAC;IACF,CAAC;IACD,KAAK,EAAE,EAAuC;IAC9C,KAAK,EAAE;QACL,aAAa,EAAE,OAAO;QACtB,OAAO,EAAE;YACP,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,KAAK;SACf;QACD,KAAK,EAAE;YACL,OAAO,EAAE,IAAI;SACd;KACF;CACA,CAAC,CAAC;AAEH,eAAe,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC;IACrD,KAAK;QACL,OAAO,EACN,CAAC;IACF,CAAC;IACD,KAAK,EAAE,EAAuC;IAC9C,KAAK,EAAE;QACL,aAAa,EAAE,OAAO;QACtB,OAAO,EAAE;YACP,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,KAAK;SACf;QACD,KAAK,EAAE;YACL,OAAO,EAAE,IAAI;SACd;KACF;CACA,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<Transition name="fade" mode="out-in">
|
|
4
|
+
<template v-if="loading">
|
|
5
|
+
<slot name="loader" :loading="loading" :height="tableHeight">
|
|
6
|
+
<div
|
|
7
|
+
:class="[
|
|
8
|
+
'overflow-hidden relative z-0 isolate bg-white backdrop-blur transition-colors duration-150 ease-in-out rounded-xl border border-gray-50',
|
|
9
|
+
tableHeight
|
|
10
|
+
? tableHeight
|
|
11
|
+
: 'h-[calc(100svh-9rem)] max-h-[calc(100svh-9rem)]',
|
|
12
|
+
]"
|
|
13
|
+
>
|
|
14
|
+
<div
|
|
15
|
+
class="absolute flex items-center z-[calc(infinity)] w-full h-auto pointer-events-none inset-0"
|
|
16
|
+
>
|
|
17
|
+
<EUICircleLoader />
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</slot>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<div v-else class="relative w-full mx-auto overflow-hidden">
|
|
24
|
+
<div
|
|
25
|
+
id="growth-table"
|
|
26
|
+
:class="[
|
|
27
|
+
'scrollbar--thin overscroll-auto',
|
|
28
|
+
computedItems.length === 0 ? 'overflow-hidden' : 'overflow-auto',
|
|
29
|
+
tableHeight
|
|
30
|
+
? tableHeight
|
|
31
|
+
: 'h-[calc(100svh-13rem)] max-h-[calc(100svh-13rem)]',
|
|
32
|
+
]"
|
|
33
|
+
ref="tableContainer"
|
|
34
|
+
@scroll="handleScroll"
|
|
35
|
+
>
|
|
36
|
+
<table>
|
|
37
|
+
<thead class="sticky top-0 left-0 z-50 bg-violet-100">
|
|
38
|
+
<tr>
|
|
39
|
+
<th v-if="checkable" class="checkable !table-cell">
|
|
40
|
+
<EUITableCheckbox
|
|
41
|
+
:checked="isAllChecked"
|
|
42
|
+
:indeterminate="isIndeterminate"
|
|
43
|
+
:disabled="isAllUncheckable"
|
|
44
|
+
@change="checkAll()"
|
|
45
|
+
/>
|
|
46
|
+
</th>
|
|
47
|
+
<th
|
|
48
|
+
v-for="(header, headerIndex) in headers"
|
|
49
|
+
:key="`item-${headerIndex}`"
|
|
50
|
+
scope="col"
|
|
51
|
+
:class="[
|
|
52
|
+
'px-3 py-1.5 text-gray-600 snap-start snap-always',
|
|
53
|
+
isScrolled && headerIndex === 0 ? stickyClass.head : '',
|
|
54
|
+
{ 'cursor-pointer hover:text-gray-900': header?.sortable },
|
|
55
|
+
]"
|
|
56
|
+
:style="
|
|
57
|
+
header?.width
|
|
58
|
+
? `min-width:${header.width}px;max-width:${header.width}px;`
|
|
59
|
+
: ``
|
|
60
|
+
"
|
|
61
|
+
@click="sortBy(header, $event)"
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
class="flex items-center gap-2 text-xs font-semibold text-current"
|
|
65
|
+
>
|
|
66
|
+
<slot name="header" :header="header" :index="headerIndex">
|
|
67
|
+
<template v-if="!header?.activeYear">{{
|
|
68
|
+
capitalizeText(header?.text ?? header.name ?? "")
|
|
69
|
+
}}</template>
|
|
70
|
+
<div
|
|
71
|
+
v-else
|
|
72
|
+
class="bg-violet-600 text-white rounded-[0.625rem] px-3 py-2 w-full"
|
|
73
|
+
>
|
|
74
|
+
<div class="mb-2">
|
|
75
|
+
{{
|
|
76
|
+
capitalizeText(header?.text ?? header.name ?? "")
|
|
77
|
+
}}
|
|
78
|
+
</div>
|
|
79
|
+
<div
|
|
80
|
+
class="flex items-center justify-start max-w-full gap-4"
|
|
81
|
+
>
|
|
82
|
+
<span
|
|
83
|
+
v-for="(data, idx) in header?.activeYear"
|
|
84
|
+
:key="`year_${idx}`"
|
|
85
|
+
class="min-w-9"
|
|
86
|
+
>{{ data }}</span
|
|
87
|
+
>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</slot>
|
|
91
|
+
<slot name="headerOptionalItem"></slot>
|
|
92
|
+
<SortArrow
|
|
93
|
+
v-if="header?.sortable && !header?.activeYear"
|
|
94
|
+
:class="[
|
|
95
|
+
'transform duration-100 transition-all',
|
|
96
|
+
currentSort === header.value
|
|
97
|
+
? 'text-violet-700'
|
|
98
|
+
: 'text-gray-900',
|
|
99
|
+
sortClass(header),
|
|
100
|
+
]"
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
</th>
|
|
104
|
+
</tr>
|
|
105
|
+
</thead>
|
|
106
|
+
<tbody>
|
|
107
|
+
<template
|
|
108
|
+
v-if="computedItems.length > 0"
|
|
109
|
+
v-for="(row, rowIndex) in computedItems"
|
|
110
|
+
:key="`table-row-${rowIndex}`"
|
|
111
|
+
>
|
|
112
|
+
<tr
|
|
113
|
+
@mouseenter="
|
|
114
|
+
$attrs.mouseenter
|
|
115
|
+
? $emit('mouseenter', row, rowIndex)
|
|
116
|
+
: null
|
|
117
|
+
"
|
|
118
|
+
@mouseleave="
|
|
119
|
+
$attrs.mouseleave
|
|
120
|
+
? $emit('mouseleave', row, rowIndex)
|
|
121
|
+
: null
|
|
122
|
+
"
|
|
123
|
+
>
|
|
124
|
+
<template v-if="checkable">
|
|
125
|
+
<td class="checkable">
|
|
126
|
+
<EUITableCheckbox
|
|
127
|
+
:disabled="!isRowCheckable(row)"
|
|
128
|
+
:checked="isRowChecked(row)"
|
|
129
|
+
@change="($event:boolean) => checkRow(row, rowIndex, $event)"
|
|
130
|
+
/>
|
|
131
|
+
</td>
|
|
132
|
+
</template>
|
|
133
|
+
<td
|
|
134
|
+
v-for="(header, headerIndex) in headers"
|
|
135
|
+
:key="headerIndex"
|
|
136
|
+
:class="[
|
|
137
|
+
isScrolled && headerIndex === 0 ? stickyClass.body : '',
|
|
138
|
+
]"
|
|
139
|
+
>
|
|
140
|
+
<slot
|
|
141
|
+
:name="`item.${header.value}`"
|
|
142
|
+
:row="row"
|
|
143
|
+
:rowIndex="rowIndex"
|
|
144
|
+
>
|
|
145
|
+
{{ getValueByPath(row, header?.value) }}
|
|
146
|
+
</slot>
|
|
147
|
+
</td>
|
|
148
|
+
</tr>
|
|
149
|
+
<template v-if="tableExpanded">
|
|
150
|
+
<slot name="expanded" :row="row" :rowIndex="rowIndex"></slot>
|
|
151
|
+
</template>
|
|
152
|
+
</template>
|
|
153
|
+
<template v-else-if="computedItems.length === 0">
|
|
154
|
+
<tr class="norecords">
|
|
155
|
+
<td
|
|
156
|
+
:colspan="
|
|
157
|
+
checkable === true ? headers.length + 1 : headers.length
|
|
158
|
+
"
|
|
159
|
+
>
|
|
160
|
+
<slot name="no-records">
|
|
161
|
+
<div
|
|
162
|
+
class="flex items-center justify-center text-xl font-medium text-gray-500 h-[calc(100svh-18rem)] max-w-screen-xl"
|
|
163
|
+
>
|
|
164
|
+
No matching records found
|
|
165
|
+
</div>
|
|
166
|
+
</slot>
|
|
167
|
+
</td>
|
|
168
|
+
</tr>
|
|
169
|
+
</template>
|
|
170
|
+
</tbody>
|
|
171
|
+
<tfoot
|
|
172
|
+
v-if="footers.length"
|
|
173
|
+
class="sticky bottom-0 left-0 z-50 bg-[#FEF3C7]"
|
|
174
|
+
>
|
|
175
|
+
<template
|
|
176
|
+
v-if="footers.length > 0"
|
|
177
|
+
v-for="(row, rowIndex) in footers"
|
|
178
|
+
:key="`table-row-${rowIndex}`"
|
|
179
|
+
>
|
|
180
|
+
<tr>
|
|
181
|
+
<th v-if="checkable" class="empty"></th>
|
|
182
|
+
<th
|
|
183
|
+
v-for="(header, headerIndex) in headers"
|
|
184
|
+
:key="headerIndex"
|
|
185
|
+
:class="[
|
|
186
|
+
'px-3 py-1.5 text-gray-900 snap-start snap-always h-14',
|
|
187
|
+
isScrolled && headerIndex === 0 ? stickyClass.foot : '',
|
|
188
|
+
]"
|
|
189
|
+
>
|
|
190
|
+
<slot
|
|
191
|
+
:name="`footer.${header.value}`"
|
|
192
|
+
:row="row"
|
|
193
|
+
:rowIndex="rowIndex"
|
|
194
|
+
>
|
|
195
|
+
{{ getValueByPath(row, header?.value) }}
|
|
196
|
+
</slot>
|
|
197
|
+
</th>
|
|
198
|
+
</tr>
|
|
199
|
+
</template>
|
|
200
|
+
</tfoot>
|
|
201
|
+
</table>
|
|
202
|
+
</div>
|
|
203
|
+
<div
|
|
204
|
+
v-if="paginated && computedItems.length !== 0"
|
|
205
|
+
class="sticky bottom-0 left-0 z-50 flex items-center justify-between px-2 py-2 bg-gray-100"
|
|
206
|
+
>
|
|
207
|
+
<slot name="tableCount">
|
|
208
|
+
<div class="inline-flex items-center gap-x-10">
|
|
209
|
+
<div class="text-sm font-normal text-gray-900">
|
|
210
|
+
1-{{ limit }} of {{ total }}
|
|
211
|
+
</div>
|
|
212
|
+
<div class="inline-flex items-center gap-2">
|
|
213
|
+
<span class="text-sm font-normal text-gray-900"
|
|
214
|
+
>Result per page</span
|
|
215
|
+
>
|
|
216
|
+
<EUIPageLimit
|
|
217
|
+
:page-limit="limit"
|
|
218
|
+
@update-limit="changeLimit($event)"
|
|
219
|
+
@refetch="searchData($event)"
|
|
220
|
+
/>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
</slot>
|
|
224
|
+
<template v-if="paginated && computedItems.length !== 0">
|
|
225
|
+
<slot name="tablepagination">
|
|
226
|
+
<EUIPagination
|
|
227
|
+
:activePage="newCurrentPage"
|
|
228
|
+
:pageLimit="limit"
|
|
229
|
+
:totalCount="total"
|
|
230
|
+
@change-page="pageChanged($event)"
|
|
231
|
+
/>
|
|
232
|
+
</slot>
|
|
233
|
+
</template>
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
</Transition>
|
|
237
|
+
</div>
|
|
238
|
+
</template>
|
|
239
|
+
|
|
240
|
+
<script setup lang="ts">
|
|
241
|
+
import {
|
|
242
|
+
computed,
|
|
243
|
+
onMounted,
|
|
244
|
+
onUnmounted,
|
|
245
|
+
PropType,
|
|
246
|
+
ref,
|
|
247
|
+
toRefs,
|
|
248
|
+
watch,
|
|
249
|
+
} from "vue";
|
|
250
|
+
import EUIPagination from "./EUIPagination.vue";
|
|
251
|
+
import EUITableCheckbox from "./EUITableCheckbox.vue";
|
|
252
|
+
import SortArrow from "../../assets/svg/SortArrow.vue";
|
|
253
|
+
import EUIPageLimit from "./EUIPageLimit.vue";
|
|
254
|
+
import { capitalizeText } from "../../utils/lodash";
|
|
255
|
+
import EUICircleLoader from "../loader/EUICircleLoader.vue";
|
|
256
|
+
import { indexOf, getValueByPath, defaultFilter } from "../../utils/helpers";
|
|
257
|
+
|
|
258
|
+
interface Header {
|
|
259
|
+
value: string;
|
|
260
|
+
text?: string;
|
|
261
|
+
name?: string;
|
|
262
|
+
width?: number;
|
|
263
|
+
sortable?: boolean;
|
|
264
|
+
activeYear?: string[];
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const props = defineProps({
|
|
268
|
+
checkable: {
|
|
269
|
+
type: Boolean,
|
|
270
|
+
default: false,
|
|
271
|
+
},
|
|
272
|
+
stickyColumn: { type: Boolean, default: true },
|
|
273
|
+
paginated: { type: Boolean, default: false },
|
|
274
|
+
tableExpanded: { type: Boolean, default: false },
|
|
275
|
+
backendPagination: { type: Boolean, default: false },
|
|
276
|
+
checkedRows: { type: Array, default: () => ({}), required: true },
|
|
277
|
+
headers: {
|
|
278
|
+
type: Array as PropType<Header[]>,
|
|
279
|
+
default: () => ({}),
|
|
280
|
+
required: true,
|
|
281
|
+
},
|
|
282
|
+
items: { type: Array, required: true, default: () => ({}) },
|
|
283
|
+
footers: { type: Array, default: () => ({}) },
|
|
284
|
+
defaultSort: { type: String, default: "" },
|
|
285
|
+
defaultSortDirection: { type: String, default: "asc" },
|
|
286
|
+
search: { type: String, default: "" },
|
|
287
|
+
perPage: { type: Number, default: 5 },
|
|
288
|
+
currentPage: { type: Number, default: 0 },
|
|
289
|
+
total: { type: Number, default: 0 },
|
|
290
|
+
customIsChecked: {
|
|
291
|
+
type: Function as PropType<(item: any, obj: any) => boolean>,
|
|
292
|
+
default: () => () => false,
|
|
293
|
+
},
|
|
294
|
+
isRowCheckable: { type: Function, default: () => true },
|
|
295
|
+
tableHeight: {
|
|
296
|
+
type: String,
|
|
297
|
+
required: false,
|
|
298
|
+
default: "",
|
|
299
|
+
},
|
|
300
|
+
tableLoading: { type: Boolean, default: false },
|
|
301
|
+
});
|
|
302
|
+
const {
|
|
303
|
+
defaultSort,
|
|
304
|
+
defaultSortDirection,
|
|
305
|
+
checkedRows,
|
|
306
|
+
currentPage,
|
|
307
|
+
items,
|
|
308
|
+
backendPagination,
|
|
309
|
+
total,
|
|
310
|
+
search,
|
|
311
|
+
headers,
|
|
312
|
+
paginated,
|
|
313
|
+
isRowCheckable,
|
|
314
|
+
} = toRefs(props);
|
|
315
|
+
|
|
316
|
+
const currentSort = ref(defaultSort.value);
|
|
317
|
+
const currentSortDir = ref(defaultSortDirection.value);
|
|
318
|
+
const newCheckedRows = ref([...checkedRows.value]);
|
|
319
|
+
const newCurrentPage = ref(currentPage.value);
|
|
320
|
+
const limit = ref(props.perPage);
|
|
321
|
+
const loading = computed(() => props.tableLoading);
|
|
322
|
+
|
|
323
|
+
// Computed Property
|
|
324
|
+
const filteredItems = computed(() => {
|
|
325
|
+
let filteredItems = items.value.slice();
|
|
326
|
+
if (!backendPagination.value && search.value !== "") {
|
|
327
|
+
if (search.value.trim() === "") return filteredItems;
|
|
328
|
+
const props = headers.value.map((h) => h.value);
|
|
329
|
+
filteredItems = items.value.filter((item) =>
|
|
330
|
+
props.some((prop) =>
|
|
331
|
+
defaultFilter(
|
|
332
|
+
getValueByPath(item, prop),
|
|
333
|
+
search.value.toString().toLowerCase()
|
|
334
|
+
)
|
|
335
|
+
)
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
return filteredItems;
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const computedItems = computed(() => {
|
|
342
|
+
let items = filteredItems.value;
|
|
343
|
+
// Sort items before slicing for pagination
|
|
344
|
+
items.sort((a: any, b: any) => {
|
|
345
|
+
const modifier = currentSortDir.value === "desc" ? -1 : 1;
|
|
346
|
+
if (a[currentSort.value] < b[currentSort.value]) return -1 * modifier;
|
|
347
|
+
if (a[currentSort.value] > b[currentSort.value]) return 1 * modifier;
|
|
348
|
+
return 0;
|
|
349
|
+
});
|
|
350
|
+
return items;
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
const searchData = (_data: any) => {
|
|
354
|
+
// console.log(_data);
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
const sortClass = computed(() => (header: any) => {
|
|
358
|
+
return currentSortDir.value === "asc" && currentSort.value === header.value
|
|
359
|
+
? "rotate-0"
|
|
360
|
+
: currentSortDir.value === "desc" && currentSort.value === header.value
|
|
361
|
+
? "rotate-180"
|
|
362
|
+
: "";
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
const isIndeterminate = computed(() => {
|
|
366
|
+
const validVisibleData = computedItems.value.filter((row) =>
|
|
367
|
+
isRowCheckable.value(row)
|
|
368
|
+
);
|
|
369
|
+
return (
|
|
370
|
+
newCheckedRows.value.length > 0 &&
|
|
371
|
+
newCheckedRows.value.length < validVisibleData.length
|
|
372
|
+
);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
const isAllChecked = computed(() => {
|
|
376
|
+
return (
|
|
377
|
+
computedItems.value.length > 0 &&
|
|
378
|
+
computedItems.value.every((row) => newCheckedRows.value.includes(row))
|
|
379
|
+
);
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
const isAllUncheckable = computed(() => {
|
|
383
|
+
const validVisibleData = computedItems.value?.filter((row) =>
|
|
384
|
+
isRowCheckable.value!(row)
|
|
385
|
+
);
|
|
386
|
+
return validVisibleData.length === 0;
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
const emit = defineEmits([
|
|
390
|
+
"update:currentPage",
|
|
391
|
+
"changePage",
|
|
392
|
+
"sort",
|
|
393
|
+
"check",
|
|
394
|
+
"check-all",
|
|
395
|
+
"update:checkedRows",
|
|
396
|
+
"update:selectedRows",
|
|
397
|
+
"changeLimit",
|
|
398
|
+
"mouseenter",
|
|
399
|
+
"mouseleave",
|
|
400
|
+
]);
|
|
401
|
+
|
|
402
|
+
const changeLimit = (limitData: number) => {
|
|
403
|
+
limit.value = limitData;
|
|
404
|
+
newCurrentPage.value = 0;
|
|
405
|
+
emit("update:currentPage", newCurrentPage.value);
|
|
406
|
+
emit("changeLimit", limitData);
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
const pageChanged = (page: number) => {
|
|
410
|
+
newCurrentPage.value = page > 0 ? page : 0;
|
|
411
|
+
emit("update:currentPage", newCurrentPage.value);
|
|
412
|
+
emit("changePage", page);
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
const sortBy = (header: any, event: any) => {
|
|
416
|
+
if (!header || !header.sortable) return;
|
|
417
|
+
if (header.value === currentSort.value) {
|
|
418
|
+
currentSortDir.value = currentSortDir.value === "asc" ? "desc" : "asc";
|
|
419
|
+
}
|
|
420
|
+
currentSort.value = header.value;
|
|
421
|
+
emit("sort", currentSort.value, currentSortDir.value, event);
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
const isRowChecked = (row: any) => {
|
|
425
|
+
return indexOf(newCheckedRows.value, row) >= 0;
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
const removeCheckedRow = (row: any) => {
|
|
429
|
+
const index = indexOf(newCheckedRows.value, row);
|
|
430
|
+
if (index >= 0) {
|
|
431
|
+
newCheckedRows.value.splice(index, 1);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
const checkAll = () => {
|
|
436
|
+
if (isAllChecked.value) {
|
|
437
|
+
// Uncheck all rows
|
|
438
|
+
newCheckedRows.value = [];
|
|
439
|
+
} else {
|
|
440
|
+
// Check all rows
|
|
441
|
+
const rowsToCheck = computedItems.value.filter(
|
|
442
|
+
(row) => !newCheckedRows.value.includes(row)
|
|
443
|
+
);
|
|
444
|
+
newCheckedRows.value.push(...rowsToCheck);
|
|
445
|
+
}
|
|
446
|
+
emit("check", newCheckedRows.value);
|
|
447
|
+
emit("check-all", newCheckedRows.value);
|
|
448
|
+
emit("update:checkedRows", newCheckedRows.value);
|
|
449
|
+
emit("update:selectedRows", newCheckedRows.value);
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
const checkRow = (row: any, _rowIndex: number, _event: any) => {
|
|
453
|
+
const isChecked = newCheckedRows.value.includes(row);
|
|
454
|
+
if (_event && isChecked) {
|
|
455
|
+
removeCheckedRow(row);
|
|
456
|
+
} else {
|
|
457
|
+
newCheckedRows.value.push(row);
|
|
458
|
+
}
|
|
459
|
+
emit("check", newCheckedRows.value, row);
|
|
460
|
+
emit("update:checkedRows", newCheckedRows.value);
|
|
461
|
+
emit("update:selectedRows", newCheckedRows.value);
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
// watch
|
|
465
|
+
watch(
|
|
466
|
+
() => currentPage.value,
|
|
467
|
+
(newVal) => {
|
|
468
|
+
newCurrentPage.value = newVal;
|
|
469
|
+
},
|
|
470
|
+
{ immediate: true }
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
watch(
|
|
474
|
+
() => checkedRows.value,
|
|
475
|
+
(rows) => {
|
|
476
|
+
newCheckedRows.value = [...rows];
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
immediate: true,
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
// table scroll to add class
|
|
484
|
+
const stickyClass = computed(() => {
|
|
485
|
+
return props.checkable && props.stickyColumn
|
|
486
|
+
? {
|
|
487
|
+
head: "bg-violet-100 sticky left-[4.5rem] top-0 z-20",
|
|
488
|
+
foot: "bg-[#FEF3C7] sticky left-[4.5rem] top-0 z-20",
|
|
489
|
+
body: "bg-white sticky left-[4.5rem] top-0 z-10",
|
|
490
|
+
}
|
|
491
|
+
: {
|
|
492
|
+
head: "bg-violet-100 sticky left-0 top-0 z-20",
|
|
493
|
+
foot: "bg-[#FEF3C7] sticky left-0 top-0 z-20",
|
|
494
|
+
body: "bg-white sticky left-0 top-0 z-10",
|
|
495
|
+
};
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
const isOverflowing = ref(false);
|
|
499
|
+
const isScrolled = ref(false);
|
|
500
|
+
const tableContainer = ref<HTMLElement | null>(null);
|
|
501
|
+
|
|
502
|
+
const handleScroll = () => {
|
|
503
|
+
const container = tableContainer.value;
|
|
504
|
+
if (container) {
|
|
505
|
+
isScrolled.value = container.scrollLeft > 0;
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
const checkOverflow = () => {
|
|
510
|
+
const container = tableContainer.value;
|
|
511
|
+
if (container) {
|
|
512
|
+
isOverflowing.value = container.scrollWidth > container.clientWidth;
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
onMounted(() => {
|
|
517
|
+
window.addEventListener("resize", checkOverflow);
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
onUnmounted(() => {
|
|
521
|
+
window.removeEventListener("resize", checkOverflow);
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
// Watch for changes in the container's width to check for overflow
|
|
525
|
+
watch(() => tableContainer.value?.clientWidth, checkOverflow);
|
|
526
|
+
</script>
|
|
527
|
+
|
|
528
|
+
<style lang="scss" scoped>
|
|
529
|
+
#growth-table {
|
|
530
|
+
& table {
|
|
531
|
+
// border-spacing: 0 0.5rem;
|
|
532
|
+
@apply min-w-full text-sm font-light text-left table table-auto w-full -mt-2 box-border border-separate border-spacing-y-2 relative;
|
|
533
|
+
thead tr {
|
|
534
|
+
@apply snap-x snap-mandatory;
|
|
535
|
+
th {
|
|
536
|
+
@apply snap-always snap-start last-of-type:rounded-r-xl first-of-type:rounded-l-xl;
|
|
537
|
+
&:first-of-type.checkable {
|
|
538
|
+
min-height: 45px;
|
|
539
|
+
@apply flex items-center justify-center px-4 max-w-[4.5rem] w-[4.5rem] sticky left-0 top-0 z-20 bg-violet-100;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
tbody {
|
|
544
|
+
@apply snap-y snap-mandatory snap-always;
|
|
545
|
+
tr:not(.norecords) {
|
|
546
|
+
@apply text-gray-500 transition-all duration-150 rounded-xl bg-white snap-start ease-in-out snap-x snap-mandatory;
|
|
547
|
+
&:hover {
|
|
548
|
+
@apply shadow-[1px_2px_40px_0px_#03022912] ring-1 ring-gray-100 ring-inset z-30;
|
|
549
|
+
}
|
|
550
|
+
td {
|
|
551
|
+
@apply px-3 py-1.5 text-sm font-normal last-of-type:rounded-r-xl first-of-type:rounded-l-xl transition-transform duration-100 ease-in-out border-solid border border-l-0 border-r-0 border-white first:border-s last:border-e h-14;
|
|
552
|
+
&:first-of-type.checkable {
|
|
553
|
+
@apply w-14 text-center sticky left-0 top-0 z-[11] bg-white;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
&:hover td {
|
|
557
|
+
@apply font-medium text-gray-900 bg-white border-gray-100;
|
|
558
|
+
&:first-of-type.checkable {
|
|
559
|
+
@apply bg-white;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
tfoot tr {
|
|
565
|
+
@apply snap-x snap-mandatory;
|
|
566
|
+
th {
|
|
567
|
+
@apply snap-always snap-start last-of-type:rounded-r-xl first-of-type:rounded-l-xl font-semibold;
|
|
568
|
+
&:first-of-type.empty {
|
|
569
|
+
@apply table-cell min-h-10 px-2 max-w-[45px] w-[45px] sticky left-0 top-0 z-20 bg-[#FEF3C7];
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
</style>
|