cynx-lib 1.3.64 → 1.3.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cynx-lib",
3
- "version": "1.3.64",
3
+ "version": "1.3.65",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, ref } from "vue";
2
+ import { computed, ref, onMounted, onUnmounted, watch, nextTick } from "vue";
3
3
  import {
4
4
  ChevronUp,
5
5
  ChevronDown,
@@ -64,6 +64,45 @@ const emit = defineEmits<{
64
64
  const rootRef = ref<HTMLElement | null>(null);
65
65
  const headerScrollRef = ref<HTMLElement | null>(null);
66
66
  const bodyScrollRef = ref<HTMLElement | null>(null);
67
+ const gutterWidth = ref(0);
68
+
69
+ const updateGutter = () => {
70
+ if (bodyScrollRef.value) {
71
+ const hasVScroll = bodyScrollRef.value.scrollHeight > bodyScrollRef.value.clientHeight;
72
+ if (hasVScroll) {
73
+ const scrollWidth = bodyScrollRef.value.offsetWidth - bodyScrollRef.value.clientWidth;
74
+ gutterWidth.value = scrollWidth > 0 ? scrollWidth : 6;
75
+ } else {
76
+ gutterWidth.value = 0;
77
+ }
78
+ } else {
79
+ gutterWidth.value = 0;
80
+ }
81
+ };
82
+
83
+ let resizeObserver: ResizeObserver | null = null;
84
+
85
+ onMounted(() => {
86
+ if (bodyScrollRef.value && typeof ResizeObserver !== "undefined") {
87
+ resizeObserver = new ResizeObserver(() => {
88
+ updateGutter();
89
+ });
90
+ resizeObserver.observe(bodyScrollRef.value);
91
+ }
92
+ nextTick(updateGutter);
93
+ });
94
+
95
+ onUnmounted(() => {
96
+ resizeObserver?.disconnect();
97
+ });
98
+
99
+ watch(
100
+ () => [props.data, props.columns, props.loading],
101
+ () => {
102
+ nextTick(updateGutter);
103
+ },
104
+ { deep: true }
105
+ );
67
106
 
68
107
  const handleBodyScroll = () => {
69
108
  if (headerScrollRef.value && bodyScrollRef.value) {
@@ -148,6 +187,7 @@ const getSkeletonWidth = (rIdx: number, cIdx: number, key: string) => {
148
187
  minWidth: formatWidth(col.minWidth || col.width || 100),
149
188
  }"
150
189
  />
190
+ <col v-if="gutterWidth > 0" :style="{ width: `${gutterWidth}px` }" />
151
191
  </colgroup>
152
192
  <thead>
153
193
  <tr>
@@ -198,6 +238,11 @@ const getSkeletonWidth = (rIdx: number, cIdx: number, key: string) => {
198
238
  </span>
199
239
  </div>
200
240
  </th>
241
+ <th
242
+ v-if="gutterWidth > 0"
243
+ class="bg-[#f8fafc] dark:bg-[#16192e] p-0 border-0 pointer-events-none"
244
+ :style="{ width: `${gutterWidth}px`, minWidth: `${gutterWidth}px` }"
245
+ />
201
246
  </tr>
202
247
  </thead>
203
248
  </table>