@soft-stech/bootsman-ui-shadcn 2.0.23 → 2.0.24
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/{BuiTable.vue_vue_type_script_setup_true_lang-BQRl7YR1.js → BuiTable.vue_vue_type_script_setup_true_lang-CHEsIAc7.js} +8 -7
- package/dist/components/table/BuiTable.js +1 -1
- package/dist/components/table/index.js +430 -424
- package/dist/index.js +1 -1
- package/dist/lib/useResizeColumns.d.ts +2 -2
- package/dist/lib/useResizeColumns.js +159 -99
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/table/BuiDataTable.vue +49 -33
- package/src/components/table/BuiTable.vue +1 -0
- package/src/lib/useResizeColumns.ts +255 -171
package/dist/index.js
CHANGED
|
@@ -129,7 +129,7 @@ import { _ as ba } from "./BuiAlertTitle.vue_vue_type_script_setup_true_lang-DtZ
|
|
|
129
129
|
import { _ as Aa } from "./BuiAlertDescription.vue_vue_type_script_setup_true_lang-CGkBGnhJ.js";
|
|
130
130
|
import { _ as Pa } from "./BuiAvatarImage.vue_vue_type_script_setup_true_lang-CzKZeFgo.js";
|
|
131
131
|
import { _ as wa } from "./BuiAvatarFallback.vue_vue_type_script_setup_true_lang-jxz_saON.js";
|
|
132
|
-
import { _ as Va } from "./BuiTable.vue_vue_type_script_setup_true_lang-
|
|
132
|
+
import { _ as Va } from "./BuiTable.vue_vue_type_script_setup_true_lang-CHEsIAc7.js";
|
|
133
133
|
import { _ as La } from "./BuiTableBody.vue_vue_type_script_setup_true_lang-CZvFJVkb.js";
|
|
134
134
|
import { _ as Ra } from "./BuiTableCell.vue_vue_type_script_setup_true_lang-BzFROkZg.js";
|
|
135
135
|
import { _ as ka } from "./BuiTableHead.vue_vue_type_script_setup_true_lang-DA2KX8Pg.js";
|
|
@@ -5,7 +5,6 @@ export declare function useResizeColumns(): {
|
|
|
5
5
|
initialWidth: number;
|
|
6
6
|
minWidth: number;
|
|
7
7
|
baseWidth: number;
|
|
8
|
-
isLast: boolean;
|
|
9
8
|
};
|
|
10
9
|
} | undefined, {
|
|
11
10
|
[key: string]: {
|
|
@@ -13,7 +12,6 @@ export declare function useResizeColumns(): {
|
|
|
13
12
|
initialWidth: number;
|
|
14
13
|
minWidth: number;
|
|
15
14
|
baseWidth: number;
|
|
16
|
-
isLast: boolean;
|
|
17
15
|
};
|
|
18
16
|
} | undefined>;
|
|
19
17
|
tableElement: import('vue').Ref<({
|
|
@@ -3947,6 +3945,8 @@ export declare function useResizeColumns(): {
|
|
|
3947
3945
|
resetCells: () => void;
|
|
3948
3946
|
setInitialColumnWidths: () => void;
|
|
3949
3947
|
setProvidedCellWidths: (columnSizing: Record<string, number> | undefined) => void;
|
|
3948
|
+
setColumnWidthsOnColumnVisibilityChange: () => void;
|
|
3949
|
+
setColumnWidthsOnWindowResize: () => void;
|
|
3950
3950
|
isMouseDownOnHandler: import('vue').Ref<boolean, boolean>;
|
|
3951
3951
|
isMouseUpOnHandler: import('vue').Ref<boolean, boolean>;
|
|
3952
3952
|
};
|
|
@@ -1,119 +1,179 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as c, computed as S } from "vue";
|
|
2
2
|
import "vee-validate";
|
|
3
|
-
import { useEventListener as
|
|
4
|
-
const R = 90,
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { useEventListener as F } from "@vueuse/core";
|
|
4
|
+
const R = 90, $ = 56, k = 10, C = "table";
|
|
5
|
+
function Q() {
|
|
6
|
+
const y = c(!1), w = c(""), l = c(void 0), n = c(void 0), W = c(null), s = c(null), A = c(0), f = c(0), m = c(void 0), O = c(!1), T = c(!1), z = (e) => {
|
|
7
|
+
if (!W.value?.headRef || !e) return;
|
|
8
|
+
[...W.value.headRef.querySelectorAll("th")].forEach((u) => {
|
|
9
|
+
const a = r(u), v = e[a];
|
|
10
|
+
u.style.width = v && v !== 0 ? e[a] + "px" : "";
|
|
10
11
|
});
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
12
|
+
}, _ = () => {
|
|
13
|
+
const e = s.value?.tableRef, t = W.value?.headRef;
|
|
14
|
+
if (!t || !e) return;
|
|
15
|
+
const u = [...t.querySelectorAll("th")];
|
|
16
|
+
n.value?.[C] === 0 && (n.value = {}, e.style.width = "");
|
|
17
|
+
const a = M();
|
|
18
|
+
e.style.width = "min-content";
|
|
19
|
+
const v = u.reduce((h, i) => {
|
|
20
|
+
const d = r(i), b = Math.floor(i.offsetWidth), p = d === "actions" ? k : i.offsetWidth < R ? R : i.offsetWidth;
|
|
21
|
+
return {
|
|
22
|
+
...h,
|
|
23
|
+
[d]: {
|
|
24
|
+
cell: i,
|
|
25
|
+
initialWidth: b,
|
|
26
|
+
baseWidth: b,
|
|
27
|
+
minWidth: p
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}, {});
|
|
31
|
+
return e.style.width = "", Object.values(v).forEach((h) => {
|
|
32
|
+
h.baseWidth = Math.floor(h.cell.offsetWidth);
|
|
33
|
+
}), z(n.value), e.style.width = (n.value?.[C] || a) + "px", Object.values(v).forEach((h) => {
|
|
34
|
+
h.initialWidth = Math.floor(h.cell.offsetWidth);
|
|
35
|
+
}), v;
|
|
36
|
+
}, D = (e, t) => {
|
|
37
|
+
t && (y.value = !0, w.value = e, m.value = F(document, "mousemove", B));
|
|
38
|
+
}, H = (e) => {
|
|
39
|
+
const t = e.target;
|
|
40
|
+
T.value = t.className?.includes?.("resize-handler") || !1, y.value && (q(), V());
|
|
41
|
+
}, q = () => {
|
|
42
|
+
y.value = !1, w.value = "", m.value && (m.value(), m.value = void 0);
|
|
43
|
+
}, V = () => {
|
|
44
|
+
if (!l.value || !s.value?.tableRef) return;
|
|
45
|
+
const e = {};
|
|
46
|
+
for (const t in l.value) {
|
|
47
|
+
const u = l.value[t], a = u.cell.hasAttribute("can-resize") ? Math.floor(u.cell.offsetWidth) <= u.minWidth ? u.minWidth : u.cell.offsetWidth : u.initialWidth;
|
|
48
|
+
u.cell.style.width = a + "px", e[t] = a;
|
|
35
49
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}, I = (e) => r(e) === "actions" ? j : 0, v = H(() => {
|
|
53
|
-
if (t.value)
|
|
54
|
-
return Object.values(t.value).find((e) => e.isLast);
|
|
55
|
-
}), r = (e) => e.id.split("_")[0], A = (e, a) => {
|
|
56
|
-
if (!e || !l.value?.tableRef || !v.value) {
|
|
57
|
-
W.value = "", C.value = "";
|
|
50
|
+
e[C] = s.value.tableRef.offsetWidth, n.value = e;
|
|
51
|
+
}, N = (e) => e === "actions" ? $ : 0, o = S(() => {
|
|
52
|
+
if (!l.value || !W.value?.headRef) return;
|
|
53
|
+
const e = [...W.value.headRef.querySelectorAll("th")];
|
|
54
|
+
if (e.length === 0) return;
|
|
55
|
+
const t = e[e.length - 1];
|
|
56
|
+
return l.value[r(t)];
|
|
57
|
+
}), x = S(() => {
|
|
58
|
+
if (!l.value || !W.value?.headRef) return;
|
|
59
|
+
const e = [...W.value.headRef.querySelectorAll("th")];
|
|
60
|
+
if (e.length < 2) return;
|
|
61
|
+
const t = e[e.length - 2];
|
|
62
|
+
return l.value[r(t)];
|
|
63
|
+
}), r = (e) => e.id.split("_")[0], j = (e, t) => {
|
|
64
|
+
if (!e || !s.value?.tableRef || !o.value) {
|
|
65
|
+
w.value = "";
|
|
58
66
|
return;
|
|
59
67
|
}
|
|
60
|
-
const u =
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
e.style.width =
|
|
68
|
+
const u = t.movementX, a = u < 0 ? "left" : "right", v = Math.floor(parseInt(e.style.width)) + u, h = Math.floor(parseInt(s.value.tableRef.style.width)) + u, i = Math.floor(parseInt(o.value.cell.style.width)) - u;
|
|
69
|
+
if (a === "left") {
|
|
70
|
+
const d = l.value && l.value[r(e)] ? l.value[r(e)].minWidth : R;
|
|
71
|
+
if (v >= d)
|
|
72
|
+
e.style.width = v + "px", h >= f.value ? s.value.tableRef.style.width = h + "px" : (s.value.tableRef.style.width = f.value + "px", o.value.cell.style.width = i + "px");
|
|
65
73
|
else
|
|
66
74
|
return;
|
|
67
75
|
} else {
|
|
68
|
-
const b =
|
|
69
|
-
|
|
76
|
+
const d = r(o.value.cell), b = l.value && l.value[d] ? l.value[d].minWidth + N(d) : R;
|
|
77
|
+
i >= b && s.value.tableRef.offsetWidth <= f.value ? o.value.cell.style.width = i + "px" : s.value.tableRef.style.width = h + "px", e.style.width = v + "px";
|
|
70
78
|
}
|
|
71
|
-
},
|
|
72
|
-
if (e.preventDefault(),
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
}, B = (e) => {
|
|
80
|
+
if (e.preventDefault(), !l.value) return;
|
|
81
|
+
const t = l.value[w.value]?.cell;
|
|
82
|
+
j(t, e);
|
|
83
|
+
}, L = () => {
|
|
84
|
+
!l.value || !s.value?.tableRef || (s.value.tableRef.style.width = "", n.value = {}, E());
|
|
85
|
+
}, X = (e) => {
|
|
86
|
+
if (!l.value || !n.value || !o.value || !s.value?.tableRef)
|
|
87
|
+
return;
|
|
88
|
+
const t = { ...n.value }, a = l.value[e].baseWidth, v = n.value[e], h = a - v;
|
|
89
|
+
let i = n.value[C] + h, d = r(o.value.cell);
|
|
90
|
+
if (i < f.value) {
|
|
91
|
+
const b = f.value - i;
|
|
92
|
+
let p;
|
|
93
|
+
if (e === d) {
|
|
94
|
+
if (!x.value) {
|
|
95
|
+
L();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
d = r(x.value.cell), p = n.value[d] + b, x.value.cell.style.width = p + "px";
|
|
99
|
+
} else
|
|
100
|
+
p = n.value[r(o.value.cell)] + b, o.value.cell.style.width = p + "px";
|
|
101
|
+
i = f.value, t[d] = p;
|
|
75
102
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
t.value[e].cell.style.width = a + "px", l.value.tableRef.style.width = i + "px", n.value[e] = a, n.value.table = i;
|
|
103
|
+
l.value[e].cell.style.width = a + "px", s.value.tableRef.style.width = i + "px", t[e] = a, t[C] = i, n.value = t;
|
|
104
|
+
}, g = () => s.value?.scrollAreaElementRef?.tableWrapperRef?.$el.offsetWidth - 3 || 0, M = () => s.value?.tableRef?.offsetWidth || 0, E = () => {
|
|
105
|
+
if (l.value = _(), !l.value) return;
|
|
106
|
+
const e = {};
|
|
107
|
+
for (const t in l.value)
|
|
108
|
+
l.value[t].cell.style.width || (l.value[t].cell.style.width = l.value[t].initialWidth + "px"), l.value[t].cell.style.minWidth = l.value[t].minWidth + "px", e[t] = l.value[t].cell.offsetWidth;
|
|
109
|
+
if (s.value?.tableRef) {
|
|
110
|
+
const t = M(), u = g();
|
|
111
|
+
f.value = u, s.value.tableRef.setAttribute("initialResize", "set"), n.value?.[C] && !s.value.tableRef.style.width ? s.value.tableRef.style.width = n.value[C] + "px" : t < f.value ? I() : (A.value = t, s.value.tableRef.style.width = t + "px", e[C] = t);
|
|
87
112
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
113
|
+
n.value = e;
|
|
114
|
+
}, P = () => {
|
|
115
|
+
if (!W.value?.headRef || !l.value) return;
|
|
116
|
+
const e = [...W.value.headRef.querySelectorAll("th")], t = {};
|
|
117
|
+
e.forEach((a, v, h) => {
|
|
118
|
+
const i = r(a);
|
|
119
|
+
if (l.value && (l.value[i].cell = a), v < h.length - 1) {
|
|
120
|
+
const d = n.value?.[i];
|
|
121
|
+
if (d)
|
|
122
|
+
a.style.width = d + "px", t[i] = d;
|
|
123
|
+
else {
|
|
124
|
+
a.style.width = "";
|
|
125
|
+
const b = l.value?.[i]?.baseWidth || a.offsetWidth, p = l.value?.[i]?.minWidth || R;
|
|
126
|
+
a.style.width = b + "px", a.style.minWidth = p + "px", t[i] = b;
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
const d = l.value?.[i]?.baseWidth || a.offsetWidth;
|
|
130
|
+
t[i] = d;
|
|
96
131
|
}
|
|
97
|
-
|
|
132
|
+
});
|
|
133
|
+
const u = Object.values(t).reduce(
|
|
134
|
+
(a, v) => a += v,
|
|
135
|
+
0
|
|
136
|
+
);
|
|
137
|
+
if (s.value?.tableRef) {
|
|
138
|
+
f.value = g();
|
|
139
|
+
const a = Math.max(u, f.value);
|
|
140
|
+
s.value.tableRef.style.width = a + "px", t[C] = a;
|
|
141
|
+
}
|
|
142
|
+
if (o.value) {
|
|
143
|
+
o.value.cell.style.width = "";
|
|
144
|
+
const a = Math.floor(o.value.cell.offsetWidth);
|
|
145
|
+
t[r(o.value.cell)] = a, o.value.cell.style.width = a + "px";
|
|
98
146
|
}
|
|
147
|
+
n.value = t;
|
|
148
|
+
}, U = () => {
|
|
149
|
+
const e = M();
|
|
150
|
+
f.value = g(), e < f.value && I();
|
|
151
|
+
}, I = () => {
|
|
152
|
+
if (!o.value || !n.value || !s.value?.tableRef) return;
|
|
153
|
+
const e = r(o.value.cell);
|
|
154
|
+
n.value[C] = f.value, s.value.tableRef.style.width = f.value + "px", o.value.cell.style.width = "";
|
|
155
|
+
const t = Math.floor(o.value.cell.offsetWidth);
|
|
156
|
+
n.value[e] = t, o.value.cell.style.width = t + "px";
|
|
99
157
|
};
|
|
100
158
|
return {
|
|
101
|
-
cells:
|
|
102
|
-
tableElement:
|
|
103
|
-
tableHeaderElement:
|
|
159
|
+
cells: l,
|
|
160
|
+
tableElement: s,
|
|
161
|
+
tableHeaderElement: W,
|
|
104
162
|
calculatedColumnSizing: n,
|
|
105
|
-
isResizing:
|
|
106
|
-
resizingCellId:
|
|
107
|
-
handleResizeControlMouseDown:
|
|
108
|
-
handleResizeControlMouseUp:
|
|
109
|
-
resetCell:
|
|
110
|
-
resetCells:
|
|
111
|
-
setInitialColumnWidths:
|
|
112
|
-
setProvidedCellWidths:
|
|
113
|
-
|
|
114
|
-
|
|
163
|
+
isResizing: y,
|
|
164
|
+
resizingCellId: w,
|
|
165
|
+
handleResizeControlMouseDown: D,
|
|
166
|
+
handleResizeControlMouseUp: H,
|
|
167
|
+
resetCell: X,
|
|
168
|
+
resetCells: L,
|
|
169
|
+
setInitialColumnWidths: E,
|
|
170
|
+
setProvidedCellWidths: z,
|
|
171
|
+
setColumnWidthsOnColumnVisibilityChange: P,
|
|
172
|
+
setColumnWidthsOnWindowResize: U,
|
|
173
|
+
isMouseDownOnHandler: O,
|
|
174
|
+
isMouseUpOnHandler: T
|
|
115
175
|
};
|
|
116
176
|
}
|
|
117
177
|
export {
|
|
118
|
-
|
|
178
|
+
Q as useResizeColumns
|
|
119
179
|
};
|