@soft-stech/bootsman-ui-shadcn 1.5.0 → 1.5.2
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/components/ui/table/index.js +314 -314
- package/dist/lib/useResizeColumns.d.ts +13 -0
- package/dist/lib/useResizeColumns.js +70 -63
- package/dist/style.css +1 -1
- package/dist/tailwind-preset.js +1 -0
- package/package.json +1 -1
- package/src/assets/variables.css +4 -0
- package/src/components/stories/BuiDataTable.story.vue +8 -4
- package/src/components/stories/data/tasks.json +26 -13
- package/src/components/ui/table/BuiDataTable.vue +15 -2
- package/src/lib/useResizeColumns.ts +52 -28
- package/src/tailwind-preset.ts +1 -0
@@ -1,4 +1,17 @@
|
|
1
1
|
export declare function useResizeColumns(): {
|
2
|
+
cells: import('vue').Ref<{
|
3
|
+
[key: string]: {
|
4
|
+
cell: HTMLTableCellElement;
|
5
|
+
initialWidth: number;
|
6
|
+
minWidth: number;
|
7
|
+
};
|
8
|
+
} | undefined, {
|
9
|
+
[key: string]: {
|
10
|
+
cell: HTMLTableCellElement;
|
11
|
+
initialWidth: number;
|
12
|
+
minWidth: number;
|
13
|
+
};
|
14
|
+
} | undefined>;
|
2
15
|
tableHeaderElement: import('vue').Ref<({
|
3
16
|
$: import('vue').ComponentInternalInstance;
|
4
17
|
$data: {};
|
@@ -1,89 +1,96 @@
|
|
1
|
-
import { ref as
|
1
|
+
import { ref as o } from "vue";
|
2
2
|
import "vee-validate";
|
3
|
-
import { useEventListener as
|
4
|
-
function
|
5
|
-
const
|
6
|
-
|
7
|
-
const s =
|
8
|
-
e && e[s] && (
|
3
|
+
import { useEventListener as M } from "@vueuse/core";
|
4
|
+
function b() {
|
5
|
+
const r = o(!1), u = o(""), d = o(""), l = o(void 0), h = 90, x = 56, z = 10, v = o(void 0), n = o(null), f = o(void 0), y = (e) => {
|
6
|
+
n.value && n.value.headRef && [...n.value.headRef.querySelectorAll("th")].forEach((i) => {
|
7
|
+
const s = a(i);
|
8
|
+
e && e[s] && (i.style.width = e[s] + "px");
|
9
9
|
});
|
10
|
-
},
|
11
|
-
if (
|
12
|
-
return [...
|
13
|
-
const
|
10
|
+
}, E = () => {
|
11
|
+
if (n.value && n.value.headRef)
|
12
|
+
return [...n.value.headRef.querySelectorAll("th")].reduce((i, s) => {
|
13
|
+
const c = a(s);
|
14
14
|
return {
|
15
|
-
...
|
16
|
-
[
|
15
|
+
...i,
|
16
|
+
[c]: {
|
17
17
|
cell: s,
|
18
|
-
initialWidth: s.offsetWidth
|
18
|
+
initialWidth: s.offsetWidth,
|
19
|
+
minWidth: c === "actions" ? z : Math.min(s.offsetWidth, h)
|
19
20
|
}
|
20
21
|
};
|
21
22
|
}, {});
|
22
|
-
},
|
23
|
-
if (t && (
|
24
|
-
const
|
25
|
-
let s =
|
26
|
-
s || (s =
|
23
|
+
}, I = (e, t) => {
|
24
|
+
if (t && (r.value = !0, u.value = e, l.value)) {
|
25
|
+
const i = l.value[e].cell;
|
26
|
+
let s = i.nextElementSibling;
|
27
|
+
s || (s = i.previousElementSibling), d.value = s ? s.id.split("_")[0] : "", f.value = M(document, "mousemove", R);
|
27
28
|
}
|
28
|
-
},
|
29
|
-
if (
|
29
|
+
}, g = () => {
|
30
|
+
if (r.value && (r.value = !1, u.value = "", d.value = "", f.value && f.value(), l.value)) {
|
30
31
|
const e = {};
|
31
|
-
for (let t in
|
32
|
-
const
|
33
|
-
|
32
|
+
for (let t in l.value) {
|
33
|
+
const i = l.value[t], s = i.cell.hasAttribute("can-resize") ? Math.floor(i.cell.offsetWidth) <= i.minWidth ? i.minWidth : i.cell.offsetWidth : i.initialWidth;
|
34
|
+
i.cell.style.width = s + "px", e[t] = s;
|
34
35
|
}
|
35
|
-
|
36
|
+
v.value = e;
|
36
37
|
}
|
37
|
-
},
|
38
|
-
if (!e.nextElementSibling) {
|
39
|
-
const t = e.querySelector(".header-cell_wrapper");
|
40
|
-
if (t)
|
41
|
-
return parseInt(window.getComputedStyle(t).paddingRight);
|
42
|
-
}
|
43
|
-
return 0;
|
44
|
-
}, c = (e, t, l) => {
|
38
|
+
}, S = (e) => a(e) === "actions" ? x : 0, a = (e) => e.id.split("_")[0], m = (e, t, i) => {
|
45
39
|
if (!e || !t) {
|
46
|
-
|
40
|
+
u.value = "", d.value = "";
|
47
41
|
return;
|
48
42
|
}
|
49
|
-
const s =
|
50
|
-
if (
|
51
|
-
|
52
|
-
|
53
|
-
|
43
|
+
const s = i.movementX, c = s < 0 ? "left" : "right", C = Math.floor(parseInt(e.style.width)) + s, W = Math.floor(parseInt(t.style.width)) - s;
|
44
|
+
if (c === "left") {
|
45
|
+
const p = l.value && l.value[a(e)] ? l.value[a(e)].minWidth : h;
|
46
|
+
if (C <= p || !e.hasAttribute("can-resize")) {
|
47
|
+
const w = e.previousElementSibling;
|
48
|
+
m(w, t, i);
|
49
|
+
} else
|
50
|
+
e.style.width = C + "px", t.style.width = W + "px";
|
51
|
+
} else {
|
52
|
+
const p = l.value && l.value[a(t)] ? l.value[a(t)].minWidth + S(t) : h;
|
53
|
+
if (W <= p || !t.hasAttribute("can-resize")) {
|
54
|
+
const w = t.nextElementSibling;
|
55
|
+
m(e, w, i);
|
54
56
|
} else
|
55
|
-
e.style.width =
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}, z = (e) => {
|
62
|
-
if (e.preventDefault(), i.value) {
|
63
|
-
const t = i.value[o.value]?.cell, l = i.value[r.value]?.cell;
|
64
|
-
c(t, l, e);
|
57
|
+
e.style.width = C + "px", t.style.width = W + "px";
|
58
|
+
}
|
59
|
+
}, R = (e) => {
|
60
|
+
if (e.preventDefault(), l.value) {
|
61
|
+
const t = l.value[u.value]?.cell, i = l.value[d.value]?.cell;
|
62
|
+
m(t, i, e);
|
65
63
|
}
|
66
64
|
};
|
67
65
|
return {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
66
|
+
cells: l,
|
67
|
+
tableHeaderElement: n,
|
68
|
+
calculatedColumnSizing: v,
|
69
|
+
isResizing: r,
|
70
|
+
resizingCellId: u,
|
71
|
+
handleResizeControlMouseDown: I,
|
72
|
+
handleResizeControlMouseUp: g,
|
74
73
|
resetCells: () => {
|
75
|
-
if (
|
76
|
-
|
77
|
-
|
74
|
+
if (l.value) {
|
75
|
+
const e = {};
|
76
|
+
for (let t in l.value) {
|
77
|
+
const i = l.value[t].initialWidth;
|
78
|
+
l.value[t].cell.style.width = i + "px", e[t] = i;
|
79
|
+
}
|
80
|
+
v.value = e;
|
81
|
+
}
|
78
82
|
},
|
79
83
|
setInitialColumnWidths: () => {
|
80
|
-
if (
|
81
|
-
|
82
|
-
|
84
|
+
if (l.value = E(), l.value) {
|
85
|
+
const e = {};
|
86
|
+
for (let t in l.value)
|
87
|
+
l.value[t].cell.style.width || (l.value[t].cell.style.width = l.value[t].initialWidth + "px"), e[t] = l.value[t].cell.offsetWidth;
|
88
|
+
v.value = e;
|
89
|
+
}
|
83
90
|
},
|
84
|
-
setProvidedCellWidths:
|
91
|
+
setProvidedCellWidths: y
|
85
92
|
};
|
86
93
|
}
|
87
94
|
export {
|
88
|
-
|
95
|
+
b as useResizeColumns
|
89
96
|
};
|