@soft-stech/bootsman-ui-shadcn 2.0.13 → 2.0.14
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-C3hr0DBS.js → BuiTable.vue_vue_type_script_setup_true_lang-Dd_dkcy4.js} +5 -5
- package/dist/components/table/BuiTable.js +1 -1
- package/dist/components/table/index.js +365 -358
- package/dist/index.js +1 -1
- package/dist/lib/useResizeColumns.d.ts +4 -2
- package/dist/lib/useResizeColumns.js +57 -53
- package/package.json +1 -1
- package/src/components/table/BuiDataTable.vue +11 -3
- package/src/components/table/BuiTable.vue +1 -1
- package/src/lib/useResizeColumns.ts +20 -3
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-Dd_dkcy4.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";
|
|
@@ -130,9 +130,11 @@ export declare function useResizeColumns(): {
|
|
|
130
130
|
calculatedColumnSizing: import('vue').Ref<Record<string, number> | undefined, Record<string, number> | undefined>;
|
|
131
131
|
isResizing: import('vue').Ref<boolean, boolean>;
|
|
132
132
|
resizingCellId: import('vue').Ref<string, string>;
|
|
133
|
-
handleResizeControlMouseDown: (cellId: string, enableColumnResizing: boolean) => void;
|
|
134
|
-
handleResizeControlMouseUp: () => void;
|
|
133
|
+
handleResizeControlMouseDown: (e: Event, cellId: string, enableColumnResizing: boolean) => void;
|
|
134
|
+
handleResizeControlMouseUp: (e: Event) => void;
|
|
135
135
|
resetCells: () => void;
|
|
136
136
|
setInitialColumnWidths: () => void;
|
|
137
137
|
setProvidedCellWidths: (columnSizing: Record<string, number> | undefined) => void;
|
|
138
|
+
isMouseDownOnHandler: import('vue').Ref<boolean, boolean>;
|
|
139
|
+
isMouseUpOnHandler: import('vue').Ref<boolean, boolean>;
|
|
138
140
|
};
|
|
@@ -1,94 +1,98 @@
|
|
|
1
1
|
import { ref as o } from "vue";
|
|
2
2
|
import "vee-validate";
|
|
3
|
-
import { useEventListener as
|
|
3
|
+
import { useEventListener as _ } from "@vueuse/core";
|
|
4
4
|
function b() {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
e && e[
|
|
5
|
+
const c = o(!1), d = o(""), v = o(""), l = o(void 0), f = 90, E = 56, x = 10, h = o(void 0), u = o(null), m = o(void 0), M = (e) => {
|
|
6
|
+
u.value && u.value.headRef && [...u.value.headRef.querySelectorAll("th")].forEach((s) => {
|
|
7
|
+
const i = r(s);
|
|
8
|
+
e && e[i] && (s.style.width = e[i] + "px");
|
|
9
9
|
});
|
|
10
|
-
},
|
|
11
|
-
if (
|
|
12
|
-
return [...
|
|
13
|
-
const
|
|
10
|
+
}, y = () => {
|
|
11
|
+
if (u.value && u.value.headRef)
|
|
12
|
+
return [...u.value.headRef.querySelectorAll("th")].reduce((s, i) => {
|
|
13
|
+
const n = r(i);
|
|
14
14
|
return {
|
|
15
|
-
...
|
|
16
|
-
[
|
|
17
|
-
cell:
|
|
18
|
-
initialWidth:
|
|
19
|
-
minWidth:
|
|
15
|
+
...s,
|
|
16
|
+
[n]: {
|
|
17
|
+
cell: i,
|
|
18
|
+
initialWidth: i.offsetWidth,
|
|
19
|
+
minWidth: n === "actions" ? x : Math.min(i.offsetWidth, f)
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
}, {});
|
|
23
|
-
}, I = (e, t) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
}, w = o(!1), z = o(!1), I = (e, t, s) => {
|
|
24
|
+
const i = e.target;
|
|
25
|
+
if (w.value = i.className.includes && i.className.includes("resize-handler"), !!s && (c.value = !0, d.value = t, l.value)) {
|
|
26
|
+
const n = l.value[t].cell;
|
|
27
|
+
let a = n.nextElementSibling;
|
|
28
|
+
a || (a = n.previousElementSibling), v.value = a ? a.id.split("_")[0] : "", m.value = _(document, "mousemove", R);
|
|
28
29
|
}
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
i.cell.
|
|
30
|
+
}, S = (e) => {
|
|
31
|
+
const t = e.target;
|
|
32
|
+
if (z.value = t.className.includes && t.className.includes("resize-handler"), !!c.value && (c.value = !1, d.value = "", v.value = "", m.value && m.value(), l.value)) {
|
|
33
|
+
const s = {};
|
|
34
|
+
for (const i in l.value) {
|
|
35
|
+
const n = l.value[i], a = n.cell.hasAttribute("can-resize") ? Math.floor(n.cell.offsetWidth) <= n.minWidth ? n.minWidth : n.cell.offsetWidth : n.initialWidth;
|
|
36
|
+
n.cell.style.width = a + "px", s[i] = a;
|
|
35
37
|
}
|
|
36
|
-
|
|
38
|
+
h.value = s;
|
|
37
39
|
}
|
|
38
|
-
},
|
|
40
|
+
}, L = (e) => r(e) === "actions" ? E : 0, r = (e) => e.id.split("_")[0], C = (e, t, s) => {
|
|
39
41
|
if (!e || !t) {
|
|
40
|
-
|
|
42
|
+
d.value = "", v.value = "";
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
48
|
-
|
|
45
|
+
const i = s.movementX, n = i < 0 ? "left" : "right", a = Math.floor(parseInt(e.style.width)) + i, p = Math.floor(parseInt(t.style.width)) - i;
|
|
46
|
+
if (n === "left") {
|
|
47
|
+
const W = l.value && l.value[r(e)] ? l.value[r(e)].minWidth : f;
|
|
48
|
+
if (a <= W || !e.hasAttribute("can-resize")) {
|
|
49
|
+
const g = e.previousElementSibling;
|
|
50
|
+
C(g, t, s);
|
|
49
51
|
} else
|
|
50
|
-
e.style.width =
|
|
52
|
+
e.style.width = a + "px", t.style.width = p + "px";
|
|
51
53
|
} else {
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const W = l.value && l.value[r(t)] ? l.value[r(t)].minWidth + L(t) : f;
|
|
55
|
+
if (p <= W || !t.hasAttribute("can-resize")) {
|
|
56
|
+
const g = t.nextElementSibling;
|
|
57
|
+
C(e, g, s);
|
|
56
58
|
} else
|
|
57
|
-
e.style.width =
|
|
59
|
+
e.style.width = a + "px", t.style.width = p + "px";
|
|
58
60
|
}
|
|
59
61
|
}, R = (e) => {
|
|
60
62
|
if (e.preventDefault(), l.value) {
|
|
61
|
-
const t = l.value[
|
|
62
|
-
|
|
63
|
+
const t = l.value[d.value]?.cell, s = l.value[v.value]?.cell;
|
|
64
|
+
C(t, s, e);
|
|
63
65
|
}
|
|
64
66
|
};
|
|
65
67
|
return {
|
|
66
68
|
cells: l,
|
|
67
|
-
tableHeaderElement:
|
|
68
|
-
calculatedColumnSizing:
|
|
69
|
-
isResizing:
|
|
70
|
-
resizingCellId:
|
|
69
|
+
tableHeaderElement: u,
|
|
70
|
+
calculatedColumnSizing: h,
|
|
71
|
+
isResizing: c,
|
|
72
|
+
resizingCellId: d,
|
|
71
73
|
handleResizeControlMouseDown: I,
|
|
72
|
-
handleResizeControlMouseUp:
|
|
74
|
+
handleResizeControlMouseUp: S,
|
|
73
75
|
resetCells: () => {
|
|
74
76
|
if (l.value) {
|
|
75
77
|
const e = {};
|
|
76
78
|
for (const t in l.value) {
|
|
77
|
-
const
|
|
78
|
-
l.value[t].cell.style.width =
|
|
79
|
+
const s = l.value[t].initialWidth;
|
|
80
|
+
l.value[t].cell.style.width = s + "px", e[t] = s;
|
|
79
81
|
}
|
|
80
|
-
|
|
82
|
+
h.value = e;
|
|
81
83
|
}
|
|
82
84
|
},
|
|
83
85
|
setInitialColumnWidths: () => {
|
|
84
|
-
if (l.value =
|
|
86
|
+
if (l.value = y(), l.value) {
|
|
85
87
|
const e = {};
|
|
86
88
|
for (const t in l.value)
|
|
87
89
|
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
|
-
|
|
90
|
+
h.value = e;
|
|
89
91
|
}
|
|
90
92
|
},
|
|
91
|
-
setProvidedCellWidths:
|
|
93
|
+
setProvidedCellWidths: M,
|
|
94
|
+
isMouseDownOnHandler: w,
|
|
95
|
+
isMouseUpOnHandler: z
|
|
92
96
|
};
|
|
93
97
|
}
|
|
94
98
|
export {
|
package/package.json
CHANGED
|
@@ -268,7 +268,9 @@ const {
|
|
|
268
268
|
handleResizeControlMouseDown,
|
|
269
269
|
handleResizeControlMouseUp,
|
|
270
270
|
setInitialColumnWidths,
|
|
271
|
-
setProvidedCellWidths
|
|
271
|
+
setProvidedCellWidths,
|
|
272
|
+
isMouseDownOnHandler,
|
|
273
|
+
isMouseUpOnHandler
|
|
272
274
|
} = useResizeColumns()
|
|
273
275
|
|
|
274
276
|
onBeforeMount(() => {
|
|
@@ -383,6 +385,10 @@ watch(
|
|
|
383
385
|
)
|
|
384
386
|
|
|
385
387
|
const handleHeaderCellSorting = (header: Header<TData, unknown>) => {
|
|
388
|
+
if (isMouseDownOnHandler.value && !isMouseUpOnHandler.value) {
|
|
389
|
+
return false
|
|
390
|
+
}
|
|
391
|
+
|
|
386
392
|
if (getHeaderCellSortingButton(header)) {
|
|
387
393
|
header.column.toggleSorting(header.column.getIsSorted() === 'asc')
|
|
388
394
|
}
|
|
@@ -466,11 +472,13 @@ const handleHeaderCellSorting = (header: Header<TData, unknown>) => {
|
|
|
466
472
|
enableColumnResizing && index < tableHeaders.length - 1 && header.column.getCanResize()
|
|
467
473
|
"
|
|
468
474
|
@dblclick="resetCells"
|
|
469
|
-
@mousedown="
|
|
475
|
+
@mousedown.self="
|
|
476
|
+
(e: Event) => handleResizeControlMouseDown(e, header.id, props.enableColumnResizing)
|
|
477
|
+
"
|
|
470
478
|
@click.stop
|
|
471
479
|
:className="
|
|
472
480
|
cn(
|
|
473
|
-
'absolute top-0 right-0 h-full w-1 bg-muted-foreground opacity-0 cursor-col-resize select-none touch-none hover:opacity-50',
|
|
481
|
+
'resize-handler absolute top-0 right-0 h-full w-1 bg-muted-foreground opacity-0 cursor-col-resize select-none touch-none hover:opacity-50',
|
|
474
482
|
isResizing && resizingCellId === header.id ? 'bg-primary opacity-50' : ''
|
|
475
483
|
)
|
|
476
484
|
"
|
|
@@ -8,7 +8,7 @@ const props = defineProps<{ class?: string }>()
|
|
|
8
8
|
<template>
|
|
9
9
|
<BuiScrollArea class="border-border/16 w-full grow overflow-auto rounded-sm border">
|
|
10
10
|
<slot name="columnVisibility" />
|
|
11
|
-
<div class="min-h-[90px]">
|
|
11
|
+
<div class="flex min-h-[90px] grow flex-col">
|
|
12
12
|
<table :class="cn('h-full w-full caption-top text-sm', props.class)">
|
|
13
13
|
<slot />
|
|
14
14
|
</table>
|
|
@@ -56,7 +56,18 @@ export function useResizeColumns() {
|
|
|
56
56
|
return undefined
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const
|
|
59
|
+
const isMouseDownOnHandler = ref<boolean>(false)
|
|
60
|
+
const isMouseUpOnHandler = ref<boolean>(false)
|
|
61
|
+
|
|
62
|
+
const handleResizeControlMouseDown = (
|
|
63
|
+
e: Event,
|
|
64
|
+
cellId: string,
|
|
65
|
+
enableColumnResizing: boolean
|
|
66
|
+
) => {
|
|
67
|
+
const targetHTMLElement = e.target as HTMLElement
|
|
68
|
+
isMouseDownOnHandler.value =
|
|
69
|
+
targetHTMLElement.className.includes && targetHTMLElement.className.includes('resize-handler')
|
|
70
|
+
|
|
60
71
|
if (!enableColumnResizing) return
|
|
61
72
|
|
|
62
73
|
isResizing.value = true
|
|
@@ -76,7 +87,11 @@ export function useResizeColumns() {
|
|
|
76
87
|
}
|
|
77
88
|
}
|
|
78
89
|
|
|
79
|
-
const handleResizeControlMouseUp = () => {
|
|
90
|
+
const handleResizeControlMouseUp = (e: Event) => {
|
|
91
|
+
const targetHTMLElement = e.target as HTMLElement
|
|
92
|
+
isMouseUpOnHandler.value =
|
|
93
|
+
targetHTMLElement.className.includes && targetHTMLElement.className.includes('resize-handler')
|
|
94
|
+
|
|
80
95
|
if (!isResizing.value) return
|
|
81
96
|
|
|
82
97
|
isResizing.value = false
|
|
@@ -221,6 +236,8 @@ export function useResizeColumns() {
|
|
|
221
236
|
handleResizeControlMouseUp,
|
|
222
237
|
resetCells,
|
|
223
238
|
setInitialColumnWidths,
|
|
224
|
-
setProvidedCellWidths
|
|
239
|
+
setProvidedCellWidths,
|
|
240
|
+
isMouseDownOnHandler,
|
|
241
|
+
isMouseUpOnHandler
|
|
225
242
|
}
|
|
226
243
|
}
|