@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/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-BQRl7YR1.js";
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 o, computed as H } from "vue";
1
+ import { ref as c, computed as S } from "vue";
2
2
  import "vee-validate";
3
- import { useEventListener as N } from "@vueuse/core";
4
- const R = 90, j = 56, X = 10;
5
- function V() {
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
- d.value && d.value.headRef && [...d.value.headRef.querySelectorAll("th")].forEach((u) => {
8
- const s = r(u);
9
- u.style.width = e && e[s] && e[s] !== 0 ? e[s] + "px" : "";
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
- }, E = () => {
12
- if (d.value && d.value.headRef && l.value && l.value?.tableRef) {
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();
16
- l.value.tableRef.style.width = "min-content";
17
- const u = e.reduce((s, i, f, c) => {
18
- const b = r(i);
19
- return {
20
- ...s,
21
- [b]: {
22
- cell: i,
23
- isLast: f === c.length - 1,
24
- initialWidth: Math.floor(i.offsetWidth),
25
- baseWidth: Math.floor(i.offsetWidth),
26
- minWidth: b === "actions" ? X : i.offsetWidth < R ? R : i.offsetWidth
27
- }
28
- };
29
- }, {});
30
- return l.value.tableRef.style.width = "", Object.values(u).forEach((s) => {
31
- s.baseWidth = Math.floor(s.cell.offsetWidth);
32
- }), w(n.value), l.value.tableRef.style.width = (n.value?.table || a) + "px", Object.values(u).forEach((s) => {
33
- s.initialWidth = Math.floor(s.cell.offsetWidth);
34
- }), u;
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
- }, L = o(!1), y = o(!1), T = (e, a) => {
37
- if (a && (p.value = !0, W.value = e, t.value)) {
38
- const u = t.value[e].cell;
39
- let s = u.nextElementSibling;
40
- s || (s = u.previousElementSibling), C.value = s ? s.id.split("_")[0] : "", m.value = N(document, "mousemove", _);
41
- }
42
- }, z = (e) => {
43
- const a = e.target;
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)) {
45
- const u = {};
46
- for (const s in t.value) {
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;
48
- i.cell.style.width = f + "px", u[s] = f;
49
- }
50
- l.value && l.value?.tableRef && (u.table = l.value.tableRef.offsetWidth), n.value = u;
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 = 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;
61
- if (s === "left") {
62
- const b = t.value && t.value[r(e)] ? t.value[r(e)].minWidth : R;
63
- if (i >= b)
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");
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 = t.value && t.value[r(v.value.cell)] ? t.value[r(v.value.cell)].minWidth + I(v.value.cell) : R;
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";
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
- }, _ = (e) => {
72
- if (e.preventDefault(), t.value) {
73
- const a = t.value[W.value]?.cell;
74
- A(a, e);
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
- }, O = () => {
77
- t.value && l.value && l.value?.tableRef && (l.value.tableRef.style.width = "", n.value = {}, g());
78
- }, S = (e) => {
79
- if (t.value && n.value && v.value && l.value && l.value?.tableRef) {
80
- const a = t.value[e].baseWidth, u = n.value[e], s = a - u;
81
- let i = n.value.table + s;
82
- if (i < h.value) {
83
- const f = h.value - i, c = n.value[r(v.value.cell)] + f;
84
- v.value.cell.style.width = c + "px", i = h.value;
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
- }, 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 = () => {
89
- if (t.value = E(), t.value) {
90
- const e = {};
91
- for (const a in t.value)
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;
93
- if (l.value && l.value?.tableRef) {
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);
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
- h.value = D(), n.value = e;
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: t,
102
- tableElement: l,
103
- tableHeaderElement: d,
159
+ cells: l,
160
+ tableElement: s,
161
+ tableHeaderElement: W,
104
162
  calculatedColumnSizing: n,
105
- isResizing: p,
106
- resizingCellId: W,
107
- handleResizeControlMouseDown: T,
108
- handleResizeControlMouseUp: z,
109
- resetCell: S,
110
- resetCells: O,
111
- setInitialColumnWidths: g,
112
- setProvidedCellWidths: w,
113
- isMouseDownOnHandler: L,
114
- isMouseUpOnHandler: y
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
- V as useResizeColumns
178
+ Q as useResizeColumns
119
179
  };