@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/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-C3hr0DBS.js";
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 M } from "@vueuse/core";
3
+ import { useEventListener as _ } from "@vueuse/core";
4
4
  function b() {
5
- const r = o(!1), u = o(""), d = o(""), l = o(void 0), h = 90, x = 56, z = 10, c = 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");
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
- }, E = () => {
11
- if (n.value && n.value.headRef)
12
- return [...n.value.headRef.querySelectorAll("th")].reduce((i, s) => {
13
- const v = a(s);
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
- ...i,
16
- [v]: {
17
- cell: s,
18
- initialWidth: s.offsetWidth,
19
- minWidth: v === "actions" ? z : Math.min(s.offsetWidth, h)
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
- 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);
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
- }, g = () => {
30
- if (r.value && (r.value = !1, u.value = "", d.value = "", f.value && f.value(), l.value)) {
31
- const e = {};
32
- for (const 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;
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
- c.value = e;
38
+ h.value = s;
37
39
  }
38
- }, S = (e) => a(e) === "actions" ? x : 0, a = (e) => e.id.split("_")[0], m = (e, t, i) => {
40
+ }, L = (e) => r(e) === "actions" ? E : 0, r = (e) => e.id.split("_")[0], C = (e, t, s) => {
39
41
  if (!e || !t) {
40
- u.value = "", d.value = "";
42
+ d.value = "", v.value = "";
41
43
  return;
42
44
  }
43
- const s = i.movementX, v = s < 0 ? "left" : "right", C = Math.floor(parseInt(e.style.width)) + s, W = Math.floor(parseInt(t.style.width)) - s;
44
- if (v === "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);
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 = C + "px", t.style.width = W + "px";
52
+ e.style.width = a + "px", t.style.width = p + "px";
51
53
  } 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
+ 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 = C + "px", t.style.width = W + "px";
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[u.value]?.cell, i = l.value[d.value]?.cell;
62
- m(t, i, e);
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: n,
68
- calculatedColumnSizing: c,
69
- isResizing: r,
70
- resizingCellId: u,
69
+ tableHeaderElement: u,
70
+ calculatedColumnSizing: h,
71
+ isResizing: c,
72
+ resizingCellId: d,
71
73
  handleResizeControlMouseDown: I,
72
- handleResizeControlMouseUp: g,
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 i = l.value[t].initialWidth;
78
- l.value[t].cell.style.width = i + "px", e[t] = i;
79
+ const s = l.value[t].initialWidth;
80
+ l.value[t].cell.style.width = s + "px", e[t] = s;
79
81
  }
80
- c.value = e;
82
+ h.value = e;
81
83
  }
82
84
  },
83
85
  setInitialColumnWidths: () => {
84
- if (l.value = E(), 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
- c.value = e;
90
+ h.value = e;
89
91
  }
90
92
  },
91
- setProvidedCellWidths: y
93
+ setProvidedCellWidths: M,
94
+ isMouseDownOnHandler: w,
95
+ isMouseUpOnHandler: z
92
96
  };
93
97
  }
94
98
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soft-stech/bootsman-ui-shadcn",
3
- "version": "2.0.13",
3
+ "version": "2.0.14",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -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="() => handleResizeControlMouseDown(header.id, props.enableColumnResizing)"
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 handleResizeControlMouseDown = (cellId: string, enableColumnResizing: boolean) => {
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
  }