@soft-stech/bootsman-ui-shadcn 2.0.23 → 2.0.25

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,192 @@
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 $ } from "@vueuse/core";
4
+ const p = 90, k = 56, A = 10, C = "table";
5
+ function Q() {
6
+ const y = c(!1), R = c(""), l = c(void 0), n = c(void 0), W = c(null), i = c(null), O = c(0), f = c(0), m = c(void 0), _ = 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), h = e[a];
10
+ u.style.width = h && h !== 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
+ }, D = () => {
13
+ const e = i.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 h = u.reduce((v, s) => {
20
+ s.style.width = "";
21
+ const o = r(s), b = Math.floor(s.offsetWidth), w = o === "actions" ? A : s.offsetWidth < p ? p : s.offsetWidth;
22
+ return {
23
+ ...v,
24
+ [o]: {
25
+ cell: s,
26
+ initialWidth: b,
27
+ baseWidth: b,
28
+ minWidth: w
29
+ }
30
+ };
31
+ }, {});
32
+ return e.style.width = "", Object.values(h).forEach((v) => {
33
+ v.baseWidth = Math.floor(v.cell.offsetWidth);
34
+ }), z(n.value), e.style.width = (n.value?.[C] || a) + "px", Object.values(h).forEach((v) => {
35
+ v.initialWidth = Math.floor(v.cell.offsetWidth);
36
+ }), h;
37
+ }, H = (e, t) => {
38
+ t && (y.value = !0, R.value = e, m.value = $(document, "mousemove", X));
39
+ }, q = (e) => {
40
+ const t = e.target;
41
+ T.value = t.className?.includes?.("resize-handler") || !1, y.value && (V(), N());
42
+ }, V = () => {
43
+ y.value = !1, R.value = "", m.value && (m.value(), m.value = void 0);
44
+ }, N = () => {
45
+ if (!l.value || !i.value?.tableRef) return;
46
+ const e = {};
47
+ for (const t in l.value) {
48
+ 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;
49
+ u.cell.style.width = a + "px", e[t] = a;
35
50
  }
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 = "";
51
+ e[C] = i.value.tableRef.offsetWidth, n.value = e;
52
+ }, j = (e) => e === "actions" ? k : 0, d = S(() => {
53
+ if (!l.value || !W.value?.headRef) return;
54
+ const e = [...W.value.headRef.querySelectorAll("th")];
55
+ if (e.length === 0) return;
56
+ const t = e[e.length - 1];
57
+ return l.value[r(t)];
58
+ }), x = S(() => {
59
+ if (!l.value || !W.value?.headRef) return;
60
+ const e = [...W.value.headRef.querySelectorAll("th")];
61
+ if (e.length < 2) return;
62
+ const t = e[e.length - 2];
63
+ return l.value[r(t)];
64
+ }), r = (e) => e.id.split("_")[0], B = (e, t) => {
65
+ if (!e || !i.value?.tableRef || !d.value) {
66
+ R.value = "";
58
67
  return;
59
68
  }
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");
69
+ const u = t.movementX, a = u < 0 ? "left" : "right", h = Math.floor(parseInt(e.style.width)) + u, v = Math.floor(parseInt(i.value.tableRef.style.width)) + u, s = Math.floor(parseInt(d.value.cell.style.width)) - u;
70
+ if (a === "left") {
71
+ const o = l.value && l.value[r(e)] ? l.value[r(e)].minWidth : p;
72
+ if (h >= o)
73
+ e.style.width = h + "px", v >= f.value ? i.value.tableRef.style.width = v + "px" : (i.value.tableRef.style.width = f.value + "px", d.value.cell.style.width = s + "px");
65
74
  else
66
75
  return;
67
76
  } 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";
77
+ const o = r(d.value.cell), b = l.value && l.value[o] ? l.value[o].minWidth + j(o) : p;
78
+ s >= b && i.value.tableRef.offsetWidth <= f.value ? d.value.cell.style.width = s + "px" : i.value.tableRef.style.width = v + "px", e.style.width = h + "px";
70
79
  }
71
- }, _ = (e) => {
72
- if (e.preventDefault(), t.value) {
73
- const a = t.value[W.value]?.cell;
74
- A(a, e);
80
+ }, X = (e) => {
81
+ if (e.preventDefault(), !l.value) return;
82
+ const t = l.value[R.value]?.cell;
83
+ B(t, e);
84
+ }, L = () => {
85
+ !l.value || !i.value?.tableRef || (i.value.tableRef.style.width = "", n.value = {}, E());
86
+ }, P = (e) => {
87
+ if (!l.value || !n.value || !d.value || !i.value?.tableRef)
88
+ return;
89
+ const t = { ...n.value }, a = l.value[e].baseWidth, h = n.value[e], v = a - h;
90
+ let s = n.value[C] + v, o = r(d.value.cell);
91
+ if (s < f.value) {
92
+ const b = f.value - s;
93
+ let w;
94
+ if (e === o) {
95
+ if (!x.value) {
96
+ L();
97
+ return;
98
+ }
99
+ o = r(x.value.cell), w = n.value[o] + b, x.value.cell.style.width = w + "px";
100
+ } else
101
+ w = n.value[r(d.value.cell)] + b, d.value.cell.style.width = w + "px";
102
+ s = f.value, t[o] = w;
75
103
  }
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;
104
+ l.value[e].cell.style.width = a + "px", i.value.tableRef.style.width = s + "px", t[e] = a, t[C] = s, n.value = t;
105
+ }, g = () => i.value?.scrollAreaElementRef?.tableWrapperRef?.$el.offsetWidth - 3 || 0, M = () => i.value?.tableRef?.offsetWidth || 0, E = () => {
106
+ if (l.value = D(), !l.value) return;
107
+ const e = {};
108
+ for (const t in l.value)
109
+ 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;
110
+ if (i.value?.tableRef) {
111
+ const t = M(), u = g();
112
+ f.value = u, i.value.tableRef.setAttribute("initialResize", "set"), n.value?.[C] && !i.value.tableRef.style.width ? i.value.tableRef.style.width = n.value[C] + "px" : t < f.value ? I() : (O.value = t, i.value.tableRef.style.width = t + "px", e[C] = t);
87
113
  }
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);
114
+ n.value = e;
115
+ }, U = () => {
116
+ if (!W.value?.headRef || !l.value) return;
117
+ const e = [...W.value.headRef.querySelectorAll("th")], t = {};
118
+ e.forEach((a, h, v) => {
119
+ const s = r(a);
120
+ if (l.value)
121
+ if (l.value[s])
122
+ l.value[s].cell = a;
123
+ else {
124
+ const o = s === "actions" ? A : a.offsetWidth < p ? p : a.offsetWidth;
125
+ l.value[s] = {
126
+ cell: a,
127
+ baseWidth: a.offsetWidth,
128
+ minWidth: o,
129
+ initialWidth: a.offsetWidth
130
+ };
131
+ }
132
+ if (h < v.length - 1) {
133
+ const o = n.value?.[s];
134
+ if (o)
135
+ a.style.width = o + "px", t[s] = o;
136
+ else {
137
+ a.style.width = "";
138
+ const b = l.value?.[s]?.baseWidth || a.offsetWidth, w = l.value?.[s]?.minWidth || p;
139
+ a.style.width = b + "px", a.style.minWidth = w + "px", t[s] = b;
140
+ }
141
+ } else {
142
+ const o = l.value?.[s]?.baseWidth || a.offsetWidth;
143
+ t[s] = o;
96
144
  }
97
- h.value = D(), n.value = e;
145
+ });
146
+ const u = Object.values(t).reduce(
147
+ (a, h) => a += h,
148
+ 0
149
+ );
150
+ if (i.value?.tableRef) {
151
+ f.value = g();
152
+ const a = Math.max(u, f.value);
153
+ i.value.tableRef.style.width = a + "px", t[C] = a;
154
+ }
155
+ if (d.value) {
156
+ d.value.cell.style.width = "";
157
+ const a = Math.floor(d.value.cell.offsetWidth);
158
+ t[r(d.value.cell)] = a, d.value.cell.style.width = a + "px";
98
159
  }
160
+ n.value = t;
161
+ }, F = () => {
162
+ const e = M();
163
+ f.value = g(), e < f.value && I();
164
+ }, I = () => {
165
+ if (!d.value || !n.value || !i.value?.tableRef) return;
166
+ const e = r(d.value.cell);
167
+ n.value[C] = f.value, i.value.tableRef.style.width = f.value + "px", d.value.cell.style.width = "";
168
+ const t = Math.floor(d.value.cell.offsetWidth);
169
+ n.value[e] = t, d.value.cell.style.width = t + "px";
99
170
  };
100
171
  return {
101
- cells: t,
102
- tableElement: l,
103
- tableHeaderElement: d,
172
+ cells: l,
173
+ tableElement: i,
174
+ tableHeaderElement: W,
104
175
  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
176
+ isResizing: y,
177
+ resizingCellId: R,
178
+ handleResizeControlMouseDown: H,
179
+ handleResizeControlMouseUp: q,
180
+ resetCell: P,
181
+ resetCells: L,
182
+ setInitialColumnWidths: E,
183
+ setProvidedCellWidths: z,
184
+ setColumnWidthsOnColumnVisibilityChange: U,
185
+ setColumnWidthsOnWindowResize: F,
186
+ isMouseDownOnHandler: _,
187
+ isMouseUpOnHandler: T
115
188
  };
116
189
  }
117
190
  export {
118
- V as useResizeColumns
191
+ Q as useResizeColumns
119
192
  };