@soft-stech/bootsman-ui-shadcn 2.0.22 → 2.0.23
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.
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { ref as o, computed as H } from "vue";
|
|
2
2
|
import "vee-validate";
|
|
3
3
|
import { useEventListener as N } from "@vueuse/core";
|
|
4
|
-
const
|
|
4
|
+
const R = 90, j = 56, X = 10;
|
|
5
5
|
function V() {
|
|
6
|
-
const p = o(!1), W = o(""),
|
|
6
|
+
const p = o(!1), W = o(""), C = o(""), t = o(void 0), n = o(void 0), d = o(null), l = o(null), M = o(0), h = o(0), m = o(void 0), w = (e) => {
|
|
7
7
|
d.value && d.value.headRef && [...d.value.headRef.querySelectorAll("th")].forEach((u) => {
|
|
8
8
|
const s = r(u);
|
|
9
|
-
u.style.width = e && e[s] ? e[s] + "px" : "";
|
|
9
|
+
u.style.width = e && e[s] && e[s] !== 0 ? e[s] + "px" : "";
|
|
10
10
|
});
|
|
11
11
|
}, E = () => {
|
|
12
12
|
if (d.value && d.value.headRef && l.value && l.value?.tableRef) {
|
|
13
|
-
const e = [...d.value.headRef.querySelectorAll("th")]
|
|
13
|
+
const e = [...d.value.headRef.querySelectorAll("th")];
|
|
14
|
+
n.value && n.value.table === 0 && (n.value = {}, l.value.tableRef.style.width = "");
|
|
15
|
+
const a = x();
|
|
14
16
|
l.value.tableRef.style.width = "min-content";
|
|
15
17
|
const u = e.reduce((s, i, f, c) => {
|
|
16
18
|
const b = r(i);
|
|
@@ -21,7 +23,7 @@ function V() {
|
|
|
21
23
|
isLast: f === c.length - 1,
|
|
22
24
|
initialWidth: Math.floor(i.offsetWidth),
|
|
23
25
|
baseWidth: Math.floor(i.offsetWidth),
|
|
24
|
-
minWidth: b === "actions" ? X : i.offsetWidth <
|
|
26
|
+
minWidth: b === "actions" ? X : i.offsetWidth < R ? R : i.offsetWidth
|
|
25
27
|
}
|
|
26
28
|
};
|
|
27
29
|
}, {});
|
|
@@ -35,11 +37,11 @@ function V() {
|
|
|
35
37
|
if (a && (p.value = !0, W.value = e, t.value)) {
|
|
36
38
|
const u = t.value[e].cell;
|
|
37
39
|
let s = u.nextElementSibling;
|
|
38
|
-
s || (s = u.previousElementSibling),
|
|
40
|
+
s || (s = u.previousElementSibling), C.value = s ? s.id.split("_")[0] : "", m.value = N(document, "mousemove", _);
|
|
39
41
|
}
|
|
40
42
|
}, z = (e) => {
|
|
41
43
|
const a = e.target;
|
|
42
|
-
if (y.value = a.className.includes && a.className.includes("resize-handler"), !!p.value && (p.value = !1, W.value = "",
|
|
44
|
+
if (y.value = a.className.includes && a.className.includes("resize-handler"), !!p.value && (p.value = !1, W.value = "", C.value = "", m.value && m.value(), t.value)) {
|
|
43
45
|
const u = {};
|
|
44
46
|
for (const s in t.value) {
|
|
45
47
|
const i = t.value[s], f = i.cell.hasAttribute("can-resize") ? Math.floor(i.cell.offsetWidth) <= i.minWidth ? i.minWidth : i.cell.offsetWidth : i.initialWidth;
|
|
@@ -50,30 +52,30 @@ function V() {
|
|
|
50
52
|
}, I = (e) => r(e) === "actions" ? j : 0, v = H(() => {
|
|
51
53
|
if (t.value)
|
|
52
54
|
return Object.values(t.value).find((e) => e.isLast);
|
|
53
|
-
}), r = (e) => e.id.split("_")[0],
|
|
55
|
+
}), r = (e) => e.id.split("_")[0], A = (e, a) => {
|
|
54
56
|
if (!e || !l.value?.tableRef || !v.value) {
|
|
55
|
-
W.value = "",
|
|
57
|
+
W.value = "", C.value = "";
|
|
56
58
|
return;
|
|
57
59
|
}
|
|
58
60
|
const u = a.movementX, s = u < 0 ? "left" : "right", i = Math.floor(parseInt(e.style.width)) + u, f = Math.floor(parseInt(l.value?.tableRef?.style.width)) + u, c = Math.floor(parseInt(v.value.cell.style.width)) - u;
|
|
59
61
|
if (s === "left") {
|
|
60
|
-
const b = t.value && t.value[r(e)] ? t.value[r(e)].minWidth :
|
|
62
|
+
const b = t.value && t.value[r(e)] ? t.value[r(e)].minWidth : R;
|
|
61
63
|
if (i >= b)
|
|
62
64
|
e.style.width = i + "px", f >= h.value ? l.value.tableRef.style.width = f + "px" : (l.value.tableRef.style.width = h.value + "px", v.value.cell.style.width = c + "px");
|
|
63
65
|
else
|
|
64
66
|
return;
|
|
65
67
|
} else {
|
|
66
|
-
const b = t.value && t.value[r(v.value.cell)] ? t.value[r(v.value.cell)].minWidth + I(v.value.cell) :
|
|
68
|
+
const b = t.value && t.value[r(v.value.cell)] ? t.value[r(v.value.cell)].minWidth + I(v.value.cell) : R;
|
|
67
69
|
c >= b && l.value.tableRef.offsetWidth <= h.value ? v.value.cell.style.width = c + "px" : l.value.tableRef.style.width = f + "px", e.style.width = i + "px";
|
|
68
70
|
}
|
|
69
|
-
},
|
|
71
|
+
}, _ = (e) => {
|
|
70
72
|
if (e.preventDefault(), t.value) {
|
|
71
73
|
const a = t.value[W.value]?.cell;
|
|
72
|
-
|
|
74
|
+
A(a, e);
|
|
73
75
|
}
|
|
74
|
-
},
|
|
75
|
-
t.value && l.value && l.value?.tableRef && (l.value.tableRef.style.width = "", n.value = {},
|
|
76
|
-
},
|
|
76
|
+
}, O = () => {
|
|
77
|
+
t.value && l.value && l.value?.tableRef && (l.value.tableRef.style.width = "", n.value = {}, g());
|
|
78
|
+
}, S = (e) => {
|
|
77
79
|
if (t.value && n.value && v.value && l.value && l.value?.tableRef) {
|
|
78
80
|
const a = t.value[e].baseWidth, u = n.value[e], s = a - u;
|
|
79
81
|
let i = n.value.table + s;
|
|
@@ -83,14 +85,14 @@ function V() {
|
|
|
83
85
|
}
|
|
84
86
|
t.value[e].cell.style.width = a + "px", l.value.tableRef.style.width = i + "px", n.value[e] = a, n.value.table = i;
|
|
85
87
|
}
|
|
86
|
-
}, D = () => l.value && l.value.scrollAreaElementRef?.tableWrapperRef ? l.value.scrollAreaElementRef?.tableWrapperRef.$el.offsetWidth - 3 : 0,
|
|
88
|
+
}, D = () => l.value && l.value.scrollAreaElementRef?.tableWrapperRef ? l.value.scrollAreaElementRef?.tableWrapperRef.$el.offsetWidth - 3 : 0, x = () => l.value && l.value?.tableRef ? l.value.tableRef.offsetWidth : 0, g = () => {
|
|
87
89
|
if (t.value = E(), t.value) {
|
|
88
90
|
const e = {};
|
|
89
91
|
for (const a in t.value)
|
|
90
92
|
t.value[a].cell.style.width || (t.value[a].cell.style.width = t.value[a].initialWidth + "px"), t.value[a].cell.style.minWidth = t.value[a].minWidth + "px", e[a] = t.value[a].cell.offsetWidth;
|
|
91
93
|
if (l.value && l.value?.tableRef) {
|
|
92
|
-
const a =
|
|
93
|
-
n.value?.table && !l.value.tableRef.style.width ? l.value.tableRef.style.width = n.value.table + "px" : (M.value = a, l.value.tableRef.style.width = a + "px", e.table = a);
|
|
94
|
+
const a = x();
|
|
95
|
+
n.value?.table && !l.value.tableRef.style.width ? l.value.tableRef.style.width = n.value.table + "px" : (M.value = a, l.value.tableRef.style.width = a + "px", l.value.tableRef.setAttribute("initialResize", "set"), e.table = a);
|
|
94
96
|
}
|
|
95
97
|
h.value = D(), n.value = e;
|
|
96
98
|
}
|
|
@@ -104,9 +106,9 @@ function V() {
|
|
|
104
106
|
resizingCellId: W,
|
|
105
107
|
handleResizeControlMouseDown: T,
|
|
106
108
|
handleResizeControlMouseUp: z,
|
|
107
|
-
resetCell:
|
|
108
|
-
resetCells:
|
|
109
|
-
setInitialColumnWidths:
|
|
109
|
+
resetCell: S,
|
|
110
|
+
resetCells: O,
|
|
111
|
+
setInitialColumnWidths: g,
|
|
110
112
|
setProvidedCellWidths: w,
|
|
111
113
|
isMouseDownOnHandler: L,
|
|
112
114
|
isMouseUpOnHandler: y
|
package/package.json
CHANGED
|
@@ -299,16 +299,35 @@ const {
|
|
|
299
299
|
isMouseUpOnHandler
|
|
300
300
|
} = useResizeColumns()
|
|
301
301
|
|
|
302
|
+
const isColumnSizingEnabled = computed(() => props.enableColumnResizing && columnSizing.value)
|
|
303
|
+
|
|
302
304
|
onBeforeMount(() => {
|
|
303
305
|
calculatedColumnSizing.value = columnSizing.value
|
|
304
306
|
})
|
|
305
307
|
|
|
306
308
|
onMounted(() => {
|
|
307
|
-
if (tableElementRef.value && tableHeaderRef.value) {
|
|
309
|
+
if (isColumnSizingEnabled.value && tableElementRef.value && tableHeaderRef.value) {
|
|
308
310
|
tableElement.value = tableElementRef.value
|
|
309
311
|
tableHeaderElement.value = tableHeaderRef.value
|
|
310
312
|
|
|
311
|
-
|
|
313
|
+
//проставляем изначальные значения ширины колонок, только если на маунте таблицу видно
|
|
314
|
+
if (tableElementRef.value.tableRef?.offsetWidth !== 0) {
|
|
315
|
+
setInitialColumnWidths()
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
//дополнительно проставляем значения ширины колонок, когда таблица появляется на экране
|
|
319
|
+
const { stop } = useIntersectionObserver(
|
|
320
|
+
tableElementRef.value.tableRef,
|
|
321
|
+
([{ isIntersecting }]) => {
|
|
322
|
+
if (isIntersecting) {
|
|
323
|
+
if (!tableElementRef.value?.tableRef?.getAttribute('initialResize')) {
|
|
324
|
+
setInitialColumnWidths()
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
stop()
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
)
|
|
312
331
|
}
|
|
313
332
|
|
|
314
333
|
groupsOpenStateInStorage.value = {}
|
|
@@ -587,7 +606,7 @@ watch(rowsLength, async () => {
|
|
|
587
606
|
/>
|
|
588
607
|
<div
|
|
589
608
|
v-if="
|
|
590
|
-
|
|
609
|
+
isColumnSizingEnabled &&
|
|
591
610
|
index < tableHeaders.length - 1 &&
|
|
592
611
|
header.column.getCanResize()
|
|
593
612
|
"
|
|
@@ -36,7 +36,10 @@ export function useResizeColumns() {
|
|
|
36
36
|
headerCells.forEach((cell) => {
|
|
37
37
|
const cellId = getCellId(cell)
|
|
38
38
|
|
|
39
|
-
cell.style.width =
|
|
39
|
+
cell.style.width =
|
|
40
|
+
columnSizing && columnSizing[cellId] && columnSizing[cellId] !== 0
|
|
41
|
+
? columnSizing[cellId] + 'px'
|
|
42
|
+
: ''
|
|
40
43
|
})
|
|
41
44
|
}
|
|
42
45
|
}
|
|
@@ -49,6 +52,12 @@ export function useResizeColumns() {
|
|
|
49
52
|
tableElement.value?.tableRef
|
|
50
53
|
) {
|
|
51
54
|
const headerCells = [...tableHeaderElement.value.headRef.querySelectorAll('th')]
|
|
55
|
+
|
|
56
|
+
if (calculatedColumnSizing.value && calculatedColumnSizing.value['table'] === 0) {
|
|
57
|
+
calculatedColumnSizing.value = {}
|
|
58
|
+
tableElement.value.tableRef.style.width = ''
|
|
59
|
+
}
|
|
60
|
+
|
|
52
61
|
const tableInitialWidth = getTableWidth()
|
|
53
62
|
|
|
54
63
|
tableElement.value.tableRef.style.width = 'min-content'
|
|
@@ -316,11 +325,14 @@ export function useResizeColumns() {
|
|
|
316
325
|
} else {
|
|
317
326
|
initialTableWidth.value = tableOffsetWidth
|
|
318
327
|
tableElement.value.tableRef.style.width = tableOffsetWidth + 'px'
|
|
328
|
+
|
|
329
|
+
tableElement.value.tableRef.setAttribute('initialResize', 'set')
|
|
319
330
|
updatedColumnSizingValue['table'] = tableOffsetWidth
|
|
320
331
|
}
|
|
321
332
|
}
|
|
322
333
|
|
|
323
334
|
minTableWidth.value = getTableWrapperWidth()
|
|
335
|
+
|
|
324
336
|
calculatedColumnSizing.value = updatedColumnSizingValue
|
|
325
337
|
}
|
|
326
338
|
}
|