bitboss-ui 2.1.127 → 2.1.128
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/ai/BbTable.md +635 -2
- package/dist/components/BbTable/types.d.ts +32 -0
- package/dist/composables/useTableWidthContext.d.ts +35 -0
- package/dist/index.css +1 -1
- package/dist/index.js +9 -9
- package/dist/index240.js +1 -1
- package/dist/index270.js +1 -1
- package/dist/index325.js +34 -41
- package/dist/index326.js +40 -447
- package/dist/index327.js +632 -0
- package/dist/index329.js +5 -154
- package/dist/index330.js +155 -0
- package/dist/index332.js +5 -141
- package/dist/index333.js +142 -0
- package/dist/index335.js +5 -154
- package/dist/index336.js +155 -0
- package/dist/index338.js +5 -57
- package/dist/index339.js +57 -4
- package/dist/index340.js +4 -19
- package/dist/index341.js +20 -0
- package/dist/index343.js +5 -141
- package/dist/index344.js +142 -0
- package/dist/index346.js +5 -3
- package/dist/index347.js +3 -108
- package/dist/index348.js +109 -0
- package/dist/index350.js +5 -54
- package/dist/index351.js +54 -23
- package/dist/index352.js +12 -11
- package/dist/index353.js +22 -838
- package/dist/index354.js +811 -446
- package/dist/index355.js +472 -50
- package/dist/index356.js +51 -6
- package/dist/index357.js +7 -0
- package/package.json +1 -1
- package/dist/index328.js +0 -6
- package/dist/index331.js +0 -6
- package/dist/index334.js +0 -6
- package/dist/index337.js +0 -6
- package/dist/index342.js +0 -6
- package/dist/index345.js +0 -6
- package/dist/index349.js +0 -6
package/dist/index327.js
ADDED
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
import { clamp as e } from "./index8.js";
|
|
2
|
+
import { useId as t } from "./index12.js";
|
|
3
|
+
import { useLogger as n } from "./index31.js";
|
|
4
|
+
import { useLocale as r } from "./index42.js";
|
|
5
|
+
import { hash as i } from "./index81.js";
|
|
6
|
+
import a from "./index85.js";
|
|
7
|
+
import { useItemsGetter as o } from "./index89.js";
|
|
8
|
+
import { useIndexById as s } from "./index90.js";
|
|
9
|
+
import { useItemValue as c } from "./index92.js";
|
|
10
|
+
import { useBaseOptions as l } from "./index93.js";
|
|
11
|
+
import { isNil as u } from "./index94.js";
|
|
12
|
+
import { useHashedWatcher as d } from "./index96.js";
|
|
13
|
+
import { usePrefill as ee } from "./index97.js";
|
|
14
|
+
import { when as te } from "./index151.js";
|
|
15
|
+
import f from "./index154.js";
|
|
16
|
+
import { useTableWidthContext as p } from "./index325.js";
|
|
17
|
+
import { applyFixedTableColumns as m, columnKeyToSlotName as ne, mergeCellClasses as re, mergeHeaderClasses as ie } from "./index326.js";
|
|
18
|
+
import { Fragment as h, computed as g, createBlock as ae, createCommentVNode as _, createElementBlock as v, createElementVNode as y, createTextVNode as oe, createVNode as se, defineComponent as b, mergeModels as ce, mergeProps as le, nextTick as ue, normalizeClass as x, normalizeStyle as S, onBeforeUnmount as de, onMounted as fe, openBlock as C, reactive as pe, ref as w, renderList as T, renderSlot as E, resolveDynamicComponent as me, toDisplayString as D, toRef as he, unref as O, useModel as ge, watch as k, withCtx as _e } from "vue";
|
|
19
|
+
//#region src/components/BbTable/BbTable.vue?vue&type=script&setup=true&lang.ts
|
|
20
|
+
var ve = {
|
|
21
|
+
key: 0,
|
|
22
|
+
class: "sr-only"
|
|
23
|
+
}, ye = ["aria-rowindex"], be = { class: "bb-table-header__content" }, xe = { class: "bb-table-check__label-text sr-only" }, Se = {
|
|
24
|
+
key: 1,
|
|
25
|
+
class: "bb-table-radio__label-text sr-only"
|
|
26
|
+
}, Ce = ["aria-sort"], we = { class: "bb-table-header__content" }, Te = { class: "bb-table-header__content sr-only" }, Ee = ["aria-rowindex"], De = {
|
|
27
|
+
key: 0,
|
|
28
|
+
class: "bb-table-skeleton__cell bb-table-skeleton__cell--select"
|
|
29
|
+
}, Oe = {
|
|
30
|
+
key: 0,
|
|
31
|
+
class: "bb-table-skeleton__cell-content"
|
|
32
|
+
}, ke = {
|
|
33
|
+
key: 1,
|
|
34
|
+
class: "bb-table-skeleton__avatar"
|
|
35
|
+
}, Ae = {
|
|
36
|
+
key: 2,
|
|
37
|
+
class: "bb-table-skeleton__avatar-text"
|
|
38
|
+
}, je = { class: "bb-table-skeleton__cell-content" }, Me = {
|
|
39
|
+
key: 3,
|
|
40
|
+
class: "bb-table-skeleton__image"
|
|
41
|
+
}, Ne = {
|
|
42
|
+
key: 4,
|
|
43
|
+
class: "bb-table-skeleton__badge"
|
|
44
|
+
}, Pe = {
|
|
45
|
+
key: 1,
|
|
46
|
+
class: "bb-table-skeleton__cell bb-table-skeleton__cell--actions"
|
|
47
|
+
}, Fe = ["aria-rowindex"], Ie = ["colspan"], Le = { class: "bb-table-loading__text sr-only" }, Re = ["aria-rowindex"], ze = ["colspan"], Be = { class: "bb-table-no-data__text" }, Ve = [
|
|
48
|
+
"aria-rowindex",
|
|
49
|
+
"onClick",
|
|
50
|
+
"onContextmenu",
|
|
51
|
+
"onDblclick"
|
|
52
|
+
], He = { class: "bb-table-check__label-text sr-only" }, Ue = { class: "bb-table-radio__label-text sr-only" }, We = ["aria-rowindex", "id"], Ge = ["colspan"], Ke = /* @__PURE__ */ b({
|
|
53
|
+
__name: "BbTable",
|
|
54
|
+
props: /* @__PURE__ */ ce({
|
|
55
|
+
accessibleLabel: {},
|
|
56
|
+
actions: { type: Boolean },
|
|
57
|
+
actionsText: { default: "Azioni" },
|
|
58
|
+
align: { default: "left" },
|
|
59
|
+
id: {},
|
|
60
|
+
inheritColumnWidths: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: !0
|
|
63
|
+
},
|
|
64
|
+
allowSelectAll: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: !0
|
|
67
|
+
},
|
|
68
|
+
caption: {},
|
|
69
|
+
compact: { type: Boolean },
|
|
70
|
+
dependencies: { default: () => [] },
|
|
71
|
+
depsDebounceTime: { default: 0 },
|
|
72
|
+
disabled: { type: Boolean },
|
|
73
|
+
displayCaption: { type: Boolean },
|
|
74
|
+
fixed: { type: Boolean },
|
|
75
|
+
fixedColumns: { default: () => [] },
|
|
76
|
+
fixedHeaders: { type: Boolean },
|
|
77
|
+
items: {
|
|
78
|
+
type: [Array, Function],
|
|
79
|
+
default: () => []
|
|
80
|
+
},
|
|
81
|
+
itemValue: {},
|
|
82
|
+
legend: {},
|
|
83
|
+
loading: { type: Boolean },
|
|
84
|
+
loadingText: {},
|
|
85
|
+
max: { default: Infinity },
|
|
86
|
+
modelValue: { default: () => [] },
|
|
87
|
+
multiple: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: !0
|
|
90
|
+
},
|
|
91
|
+
name: {},
|
|
92
|
+
noDataText: {},
|
|
93
|
+
page: {},
|
|
94
|
+
perPage: {},
|
|
95
|
+
readonly: { type: Boolean },
|
|
96
|
+
selectAll: { type: Boolean },
|
|
97
|
+
selectable: { type: [Boolean, Function] },
|
|
98
|
+
selectAllLabel: {},
|
|
99
|
+
selectText: {},
|
|
100
|
+
tdClass: {},
|
|
101
|
+
thClass: {},
|
|
102
|
+
totalItems: {},
|
|
103
|
+
unselectedItems: { default: () => [] },
|
|
104
|
+
columns: { default: () => [] }
|
|
105
|
+
}, {
|
|
106
|
+
selectAll: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
required: !1,
|
|
109
|
+
default: !1
|
|
110
|
+
},
|
|
111
|
+
selectAllModifiers: {},
|
|
112
|
+
expandedItems: {
|
|
113
|
+
required: !1,
|
|
114
|
+
default: () => []
|
|
115
|
+
},
|
|
116
|
+
expandedItemsModifiers: {}
|
|
117
|
+
}),
|
|
118
|
+
emits: /* @__PURE__ */ ce([
|
|
119
|
+
"click:row",
|
|
120
|
+
"contextmenu:row",
|
|
121
|
+
"dblclick:row",
|
|
122
|
+
"update:modelValue",
|
|
123
|
+
"update:selectAll",
|
|
124
|
+
"update:expandedItems",
|
|
125
|
+
"update:unselectedItems",
|
|
126
|
+
"item:selected",
|
|
127
|
+
"item:unselected"
|
|
128
|
+
], ["update:selectAll", "update:expandedItems"]),
|
|
129
|
+
setup(b, { emit: ce }) {
|
|
130
|
+
let { getItemValue: Ke } = c(), qe = t().id.value, A = b, j = ce;
|
|
131
|
+
A.multiple && !Array.isArray(A.modelValue) && n().throw("BbTable is set for multiple selection but modelValue is not an array.");
|
|
132
|
+
let { t: M } = r(), N = w(), P = w(), { id: Je, parentId: F, parentNode: I, cssVars: Ye, parentVar: Xe, setTracks: Ze } = p({
|
|
133
|
+
id: () => A.id,
|
|
134
|
+
container: () => P.value
|
|
135
|
+
}), L = g(() => A.inheritColumnWidths !== !1), R = g(() => A.fixed || A.columns.some((e) => e.width != null) || L.value && !!F.value), Qe = g(() => L.value && !!F.value), $e = (e) => {
|
|
136
|
+
if (typeof e == "number") return `${e}px`;
|
|
137
|
+
let t = e.trim();
|
|
138
|
+
return /^-?\d*\.?\d+$/.test(t) ? `${t}px` : t;
|
|
139
|
+
}, et = g(() => {
|
|
140
|
+
let e = I.value?.tracks;
|
|
141
|
+
return e ? Object.keys(e).filter((e) => /^\d+$/.test(e)).length : 0;
|
|
142
|
+
}), tt = g(() => {
|
|
143
|
+
let e = I.value?.tracks ?? {}, t = [];
|
|
144
|
+
"select" in e && t.push("select");
|
|
145
|
+
for (let e = 0; e < et.value; e++) t.push(String(e));
|
|
146
|
+
return "actions" in e && t.push("actions"), t;
|
|
147
|
+
}), z = g(() => +("select" in (I.value?.tracks ?? {}))), nt = g(() => z.value + et.value), rt = g(() => tt.value.length), it = (e) => {
|
|
148
|
+
let t = tt.value[e];
|
|
149
|
+
return t ? Xe(t, "0px") : "0px";
|
|
150
|
+
}, B = (e, t) => {
|
|
151
|
+
if (!F.value || t - e <= 1e-6) return null;
|
|
152
|
+
let n = [];
|
|
153
|
+
for (let r = Math.floor(e); r < Math.ceil(t - 1e-6); r++) {
|
|
154
|
+
let i = Math.min(t, r + 1) - Math.max(e, r);
|
|
155
|
+
if (i <= 1e-6) continue;
|
|
156
|
+
let a = it(r);
|
|
157
|
+
n.push(i >= .999999 ? a : `${Number(i.toFixed(4))} * ${a}`);
|
|
158
|
+
}
|
|
159
|
+
return n.length ? n.length === 1 && !n[0].includes("*") ? n[0] : `calc(${n.join(" + ")})` : null;
|
|
160
|
+
}, V = g(() => {
|
|
161
|
+
let e = A.columns, t = e.map((e) => typeof e.snap == "number" ? e.snap : Array.isArray(e.snap) ? e.snap[0] : null), n = z.value;
|
|
162
|
+
return e.map((e, r) => {
|
|
163
|
+
let i = t[r] ?? n, a;
|
|
164
|
+
if (Array.isArray(e.snap)) a = e.snap[1] === -1 ? nt.value : e.snap[1];
|
|
165
|
+
else {
|
|
166
|
+
let e = t[r + 1];
|
|
167
|
+
a = e != null && e > i ? e : Math.floor(i) + 1;
|
|
168
|
+
}
|
|
169
|
+
return n = a, {
|
|
170
|
+
start: i,
|
|
171
|
+
end: a
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}), H = g(() => {
|
|
175
|
+
let e = V.value[0];
|
|
176
|
+
return !L.value || !e ? null : B(A.selectable && z.value === 1 ? 1 : 0, e.start);
|
|
177
|
+
}), U = g(() => {
|
|
178
|
+
let e = V.value, t = e[e.length - 1];
|
|
179
|
+
if (!L.value || !t) return null;
|
|
180
|
+
let n = "actions" in (I.value?.tracks ?? {}), r = A.actions && n ? rt.value - 1 : rt.value;
|
|
181
|
+
return B(t.end, r);
|
|
182
|
+
}), at = g(() => H.value !== null), ot = g(() => U.value !== null), W = pe({
|
|
183
|
+
select: null,
|
|
184
|
+
actions: null
|
|
185
|
+
}), st = g(() => {
|
|
186
|
+
let e = (e) => L.value ? Xe(e) : "auto", t = (t) => R.value && W[t] ? W[t] : e(t), n = [];
|
|
187
|
+
A.selectable && n.push({
|
|
188
|
+
key: "select",
|
|
189
|
+
width: t("select")
|
|
190
|
+
});
|
|
191
|
+
let r = A.columns.length - 1;
|
|
192
|
+
return A.columns.forEach((e, t) => {
|
|
193
|
+
let i = String(t), a = e.width == null ? null : $e(e.width), o = a == null && R.value ? mt.value[t] ?? null : null, s = V.value[t], c = a ?? o ?? B(s.start, s.end), l = [];
|
|
194
|
+
t === 0 && at.value && l.push("var(--bb-table-offset-internal-start)"), t === r && ot.value && l.push("var(--bb-table-offset-internal-end)");
|
|
195
|
+
let u = l.length ? `calc(${[...l, c ?? "0px"].join(" + ")})` : c ?? "auto";
|
|
196
|
+
n.push({
|
|
197
|
+
key: i,
|
|
198
|
+
width: u
|
|
199
|
+
});
|
|
200
|
+
}), A.actions && n.push({
|
|
201
|
+
key: "actions",
|
|
202
|
+
width: t("actions")
|
|
203
|
+
}), n;
|
|
204
|
+
}), ct = g(() => {
|
|
205
|
+
let e = {};
|
|
206
|
+
return H.value && (e["--bb-table-offset-start"] = H.value), U.value && (e["--bb-table-offset-end"] = U.value), e;
|
|
207
|
+
}), lt = g(() => {
|
|
208
|
+
let e = {
|
|
209
|
+
...Ye.value,
|
|
210
|
+
...ct.value
|
|
211
|
+
};
|
|
212
|
+
return ht.value && (e["--bb-table-natural-width"] = ht.value), e;
|
|
213
|
+
}), ut = () => Array.from(N.value?.querySelectorAll(":scope > thead > tr.bb-table-header-row > th") ?? []), dt = () => {
|
|
214
|
+
let e = st.value.map((e) => e.key), t = {};
|
|
215
|
+
ut().forEach((n, r) => {
|
|
216
|
+
let i = e[r];
|
|
217
|
+
i != null && (t[i] = `${n.getBoundingClientRect().width}px`);
|
|
218
|
+
}), Ze(t);
|
|
219
|
+
}, ft = () => {
|
|
220
|
+
let e = N.value;
|
|
221
|
+
if (!e) return;
|
|
222
|
+
let t = (t) => {
|
|
223
|
+
let n = 0;
|
|
224
|
+
return e.querySelectorAll(t).forEach((e) => {
|
|
225
|
+
let t = 0;
|
|
226
|
+
e.querySelectorAll(":scope > *").forEach((e) => {
|
|
227
|
+
t = Math.max(t, e.getBoundingClientRect().width);
|
|
228
|
+
});
|
|
229
|
+
let r = getComputedStyle(e), i = parseFloat(r.paddingLeft) + parseFloat(r.paddingRight);
|
|
230
|
+
n = Math.max(n, t + i);
|
|
231
|
+
}), n > 0 ? `${Math.ceil(n)}px` : null;
|
|
232
|
+
};
|
|
233
|
+
W.select = A.selectable ? t(".bb-table-header--select, .bb-table-data__cell--select") : null, W.actions = A.actions ? t(".bb-table-header--actions, .bb-table__cell--actions") : null;
|
|
234
|
+
}, pt = () => {
|
|
235
|
+
ft(), dt();
|
|
236
|
+
}, mt = w([]), ht = w(null), gt = () => {
|
|
237
|
+
let e = P.value;
|
|
238
|
+
if (!e || !R.value || !A.columns.some((e) => e.width != null)) return;
|
|
239
|
+
let t = e.offsetWidth, n = +!!A.selectable, r = W.select ? parseFloat(W.select) : 0, i = W.actions ? parseFloat(W.actions) : 0, a = ut(), o = 0;
|
|
240
|
+
A.columns.forEach((e, t) => {
|
|
241
|
+
e.width != null && (o += a[n + t]?.getBoundingClientRect().width ?? 0);
|
|
242
|
+
});
|
|
243
|
+
let s = document.createElement("div");
|
|
244
|
+
s.style.cssText = [
|
|
245
|
+
"position:absolute",
|
|
246
|
+
"top:-9999px",
|
|
247
|
+
"left:-9999px",
|
|
248
|
+
"visibility:hidden",
|
|
249
|
+
"pointer-events:none",
|
|
250
|
+
`width:${t}px`,
|
|
251
|
+
`height:${e.offsetHeight}px`,
|
|
252
|
+
"overflow:visible"
|
|
253
|
+
].join(";");
|
|
254
|
+
let c = e.cloneNode(!0);
|
|
255
|
+
c.classList.remove("bb-table--fixed");
|
|
256
|
+
let l = Array.from(c.querySelectorAll("col"));
|
|
257
|
+
A.columns.forEach((e, t) => {
|
|
258
|
+
if (e.width == null) {
|
|
259
|
+
let e = l[n + t];
|
|
260
|
+
e && (e.style.width = "");
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
let u = c.querySelector("table");
|
|
264
|
+
u && (u.style.width = "max-content", u.style.minWidth = "0"), s.appendChild(c), document.body.appendChild(s);
|
|
265
|
+
let d = s.querySelector("table thead tr.bb-table-header-row"), ee = d ? Array.from(d.querySelectorAll(":scope > th")) : [], te = A.columns.map((e, t) => {
|
|
266
|
+
if (e.width != null) return 0;
|
|
267
|
+
let r = ee[n + t];
|
|
268
|
+
return r ? r.getBoundingClientRect().width : 0;
|
|
269
|
+
});
|
|
270
|
+
document.body.removeChild(s);
|
|
271
|
+
let f = te.reduce((e, t) => e + t, 0), p = t - o - r - i;
|
|
272
|
+
mt.value = A.columns.map((e, t) => {
|
|
273
|
+
if (e.width != null) return null;
|
|
274
|
+
let n = te[t];
|
|
275
|
+
if (f <= 0) return `${Math.ceil(n)}px`;
|
|
276
|
+
let r = p > 0 ? n / f * p : 0;
|
|
277
|
+
return `${Math.ceil(Math.max(n, r))}px`;
|
|
278
|
+
});
|
|
279
|
+
let m = o + f + r + i;
|
|
280
|
+
ht.value = m > 0 ? `${Math.ceil(m)}px` : null;
|
|
281
|
+
}, G = null, _t, vt = () => {
|
|
282
|
+
G !== null && clearTimeout(G), G = setTimeout(() => {
|
|
283
|
+
G = null, gt();
|
|
284
|
+
}, 200);
|
|
285
|
+
}, K, yt, bt = () => {
|
|
286
|
+
K && (K.disconnect(), ut().forEach((e) => K?.observe(e)), pt());
|
|
287
|
+
};
|
|
288
|
+
fe(() => {
|
|
289
|
+
K = new ResizeObserver(() => pt()), bt(), ue(gt), N.value && (_t = new MutationObserver(vt), _t.observe(N.value, {
|
|
290
|
+
childList: !0,
|
|
291
|
+
subtree: !0,
|
|
292
|
+
characterData: !0
|
|
293
|
+
})), P.value && (yt = new ResizeObserver(vt), yt.observe(P.value));
|
|
294
|
+
}), de(() => {
|
|
295
|
+
K?.disconnect(), yt?.disconnect(), _t?.disconnect(), G !== null && clearTimeout(G);
|
|
296
|
+
}), k(st, () => ue(bt), { flush: "post" });
|
|
297
|
+
let xt = (e) => [M("table.select").value, ...e.map((e) => e.content)].join(" "), St = g(() => A.selectable ? "fieldset" : "div"), Ct = g(() => A.loading || kt.value), q = g(() => !u(A.page) && !u(A.perPage) && !u(A.totalItems)), wt = g(() => ({
|
|
298
|
+
"bb-table": !0,
|
|
299
|
+
[`bb-table--align-${A.align}`]: !0,
|
|
300
|
+
"bb-table--compact": A.compact,
|
|
301
|
+
"bb-table--fixed": R.value,
|
|
302
|
+
"bb-table--inherit-widths": Qe.value,
|
|
303
|
+
"bb-table--fixed-header": A.fixedHeaders,
|
|
304
|
+
"bb-table--loading": Ct.value,
|
|
305
|
+
"bb-table--empty": !J.value.length,
|
|
306
|
+
"bb-table--selectable": !!A.selectable
|
|
307
|
+
})), Tt = g(() => A.columns.length + Number(!!A.selectable) + Number(!!A.actions)), Et = g(() => Object.fromEntries(A.columns.map((e) => [e.key, ne(e.key)]))), { getter: Dt, items: Ot, loading: kt } = o({ items: he(A, "items") }), { hasPrefilled: At } = ee({
|
|
308
|
+
trigger: !0,
|
|
309
|
+
fn: async (e) => {
|
|
310
|
+
await Dt(e, A.modelValue);
|
|
311
|
+
}
|
|
312
|
+
}), { data: jt } = s({ items: he(A, "modelValue") }), { options: J } = l({
|
|
313
|
+
disabled: he(A, "disabled"),
|
|
314
|
+
items: Ot,
|
|
315
|
+
itemText: void 0,
|
|
316
|
+
itemValue: A.itemValue,
|
|
317
|
+
max: A.max,
|
|
318
|
+
selectable: !0,
|
|
319
|
+
selectedIndexedByHash: jt
|
|
320
|
+
}), Mt = async (e) => {
|
|
321
|
+
A.multiple ? j("update:modelValue", A.modelValue.concat(e.value)) : j("update:modelValue", e.value);
|
|
322
|
+
}, Nt = async (e) => {
|
|
323
|
+
if (A.multiple) {
|
|
324
|
+
let t = { ...jt.value };
|
|
325
|
+
delete t[e.valueHash], j("update:modelValue", Object.values(t));
|
|
326
|
+
} else j("update:modelValue", null);
|
|
327
|
+
};
|
|
328
|
+
d(() => [A.dependencies, A.items], async () => {
|
|
329
|
+
At.value && await Dt(!1, A.modelValue);
|
|
330
|
+
}, { debounce: A.depsDebounceTime });
|
|
331
|
+
let Pt = (e, t) => {
|
|
332
|
+
let n = Et.value[e.key], r = e.align ?? "left", i = Ke(t.item, e.key);
|
|
333
|
+
return e.formatter && (!u(i) || e.formatOnNull !== !1) && (i = e.formatter(i, e.key, t.item)), e.placeholder && u(i) && (i = e.placeholder), {
|
|
334
|
+
align: r,
|
|
335
|
+
classes: re([`bb-table-data__cell--${r}`], A.tdClass, e.tdClass, i, e.key, t.item),
|
|
336
|
+
content: i,
|
|
337
|
+
key: e.key,
|
|
338
|
+
label: e.label,
|
|
339
|
+
slotName: n
|
|
340
|
+
};
|
|
341
|
+
}, Ft = g(() => A.columns.map((e) => {
|
|
342
|
+
let t = e.align ?? "left", n = `header:${Et.value[e.key]}`, r = e.sorted ? e.sorted === "asc" ? "ascending" : "descending" : void 0;
|
|
343
|
+
return {
|
|
344
|
+
align: t,
|
|
345
|
+
key: e.key,
|
|
346
|
+
label: e.label,
|
|
347
|
+
slotName: n,
|
|
348
|
+
classes: ie([`bb-table-header--${t}`], A.thClass, e.thClass),
|
|
349
|
+
sortDirection: r
|
|
350
|
+
};
|
|
351
|
+
})), It = g(() => {
|
|
352
|
+
let e = 0;
|
|
353
|
+
return J.value.map((t, n) => {
|
|
354
|
+
let r = !A.selectable || typeof A.selectable == "function" && !A.selectable(t.item) || !!t.disabled, i = (A.page ?? -1) * (A.perPage ?? 0), a = n + 1, o = i + 1 + a + e, s = A.columns.map((e) => Pt(e, t)), c = Lt.value[t.valueHash] ?? !1;
|
|
355
|
+
return c && e++, {
|
|
356
|
+
accessibleLabel: xt(s),
|
|
357
|
+
cols: s,
|
|
358
|
+
expanded: c,
|
|
359
|
+
onRowClick: (e) => j("click:row", e, t, !!t.selected),
|
|
360
|
+
onRowContextMenu: (e) => j("contextmenu:row", e, t, !!t.selected),
|
|
361
|
+
onRowDblClick: (e) => j("dblclick:row", e, t, !!t.selected),
|
|
362
|
+
item: t.item,
|
|
363
|
+
text: t.text,
|
|
364
|
+
rowIndex: o,
|
|
365
|
+
valueHash: t.valueHash,
|
|
366
|
+
value: t.value,
|
|
367
|
+
selected: t.selected,
|
|
368
|
+
disabled: r
|
|
369
|
+
};
|
|
370
|
+
});
|
|
371
|
+
}), Y = ge(b, "selectAll"), X = ge(b, "expandedItems"), { data: Lt } = s({ items: X }), Rt = (e, t) => {
|
|
372
|
+
e.target instanceof HTMLElement && (e.target instanceof HTMLButtonElement || e.key !== "Enter" && e.key !== " " || (e.preventDefault(), Z(t)));
|
|
373
|
+
}, zt = (e) => ({
|
|
374
|
+
"aria-controls": u(Lt.value[e.valueHash]) ? void 0 : `expanded_${e.valueHash}`,
|
|
375
|
+
"aria-expanded": e.expanded ? "true" : "false",
|
|
376
|
+
onClick: (t) => {
|
|
377
|
+
t.stopPropagation(), Z(e.valueHash);
|
|
378
|
+
},
|
|
379
|
+
onKeydown: (t) => Rt(t, e.valueHash)
|
|
380
|
+
}), Z = (e) => {
|
|
381
|
+
let t = J.value.find((t) => t.valueHash === e);
|
|
382
|
+
t && (e in Lt.value ? X.value = X.value.filter((t) => i(t) !== e) : X.value = [...X.value, t.value]);
|
|
383
|
+
};
|
|
384
|
+
k(Y, () => {
|
|
385
|
+
Q.clear(), j("update:unselectedItems", []), j("update:modelValue", []);
|
|
386
|
+
});
|
|
387
|
+
let Bt = g(() => !!(A.multiple && A.modelValue.length > 0 && !A.selectAll || Y.value && Q.size > 0)), Q = pe(/* @__PURE__ */ new Set());
|
|
388
|
+
k(() => A.unselectedItems, () => {
|
|
389
|
+
Q.clear(), A.unselectedItems.forEach((e) => {
|
|
390
|
+
Q.add(i(e));
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
let Vt = (e) => {
|
|
394
|
+
if (Ht(e)) {
|
|
395
|
+
Nt(e), j("item:unselected", e.value), Q.add(e.valueHash), j("update:unselectedItems", [...A.unselectedItems, e.value]);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
Y.value || Mt(e), j("item:selected", e.value), Q.delete(e.valueHash), j("update:unselectedItems", A.unselectedItems.filter((t) => i(t) !== i(e.value)));
|
|
399
|
+
}, Ht = (e) => Q.has(e.valueHash) ? !1 : e.selected || Y.value, Ut = te((e) => typeof e != "string", JSON.stringify), Wt = g(() => [].concat(A.modelValue ?? []).map((e) => ({
|
|
400
|
+
disabled: A.disabled,
|
|
401
|
+
name: A.name,
|
|
402
|
+
type: "hidden",
|
|
403
|
+
value: Ut(e)
|
|
404
|
+
}))), $ = [
|
|
405
|
+
70,
|
|
406
|
+
45,
|
|
407
|
+
85,
|
|
408
|
+
55
|
|
409
|
+
], Gt = g(() => e(J.value.length || A.columns.length || 1, 4, 10));
|
|
410
|
+
return k(() => [It.value, A.fixedColumns], () => {
|
|
411
|
+
N.value && A.fixedColumns?.length && m(N.value, A.fixedColumns);
|
|
412
|
+
}, { flush: "post" }), (e, t) => (C(), ae(me(St.value), {
|
|
413
|
+
ref_key: "containerRef",
|
|
414
|
+
ref: P,
|
|
415
|
+
"aria-busy": Ct.value,
|
|
416
|
+
"aria-rowcount": q.value ? A.totalItems : void 0,
|
|
417
|
+
class: x(wt.value),
|
|
418
|
+
"data-bb-table-id": O(Je),
|
|
419
|
+
inert: e.disabled,
|
|
420
|
+
style: S(lt.value)
|
|
421
|
+
}, {
|
|
422
|
+
default: _e(() => [
|
|
423
|
+
e.selectable ? (C(), v("legend", ve, D(e.legend), 1)) : _("", !0),
|
|
424
|
+
y("table", {
|
|
425
|
+
ref_key: "tableRef",
|
|
426
|
+
ref: N
|
|
427
|
+
}, [
|
|
428
|
+
e.caption ? (C(), v("caption", {
|
|
429
|
+
key: 0,
|
|
430
|
+
class: x({
|
|
431
|
+
"bb-table-caption": !0,
|
|
432
|
+
"sr-only": !e.displayCaption
|
|
433
|
+
})
|
|
434
|
+
}, D(e.caption), 3)) : _("", !0),
|
|
435
|
+
y("colgroup", null, [(C(!0), v(h, null, T(st.value, (e) => (C(), v("col", {
|
|
436
|
+
key: e.key,
|
|
437
|
+
style: S({ width: e.width })
|
|
438
|
+
}, null, 4))), 128))]),
|
|
439
|
+
y("thead", null, [E(e.$slots, "thead", {}, () => [y("tr", {
|
|
440
|
+
"aria-rowindex": q.value ? 1 : void 0,
|
|
441
|
+
class: "bb-table-header-row"
|
|
442
|
+
}, [
|
|
443
|
+
e.selectable ? (C(), v("th", {
|
|
444
|
+
key: 0,
|
|
445
|
+
class: x(["bb-table-header bb-table-header--select", e.thClass]),
|
|
446
|
+
scope: "col"
|
|
447
|
+
}, [E(e.$slots, "header:select", {
|
|
448
|
+
multiple: e.multiple,
|
|
449
|
+
selectAll: !!Y.value,
|
|
450
|
+
text: e.selectText || O(M)("table.selectText").value
|
|
451
|
+
}, () => [y("span", be, [e.allowSelectAll && e.multiple ? (C(), v("label", {
|
|
452
|
+
key: 0,
|
|
453
|
+
class: x(["bb-table-check__label", { "bb-table-check__label--disabled": e.disabled }])
|
|
454
|
+
}, [(C(), ae(a, {
|
|
455
|
+
key: Bt.value.toString(),
|
|
456
|
+
modelValue: Y.value,
|
|
457
|
+
"onUpdate:modelValue": t[0] ||= (e) => Y.value = e,
|
|
458
|
+
class: "bb-table-check",
|
|
459
|
+
disabled: e.disabled,
|
|
460
|
+
indeterminate: Bt.value,
|
|
461
|
+
name: `select_all_${e.name || ""}`,
|
|
462
|
+
readonly: e.readonly
|
|
463
|
+
}, null, 8, [
|
|
464
|
+
"modelValue",
|
|
465
|
+
"disabled",
|
|
466
|
+
"indeterminate",
|
|
467
|
+
"name",
|
|
468
|
+
"readonly"
|
|
469
|
+
])), y("span", xe, D(e.selectAllLabel || O(M)("table.selectAllLabel").value), 1)], 2)) : e.multiple ? _("", !0) : (C(), v("span", Se, D(e.selectText || O(M)("table.selectText").value), 1))])])], 2)) : _("", !0),
|
|
470
|
+
(C(!0), v(h, null, T(Ft.value, (t) => (C(), v("th", {
|
|
471
|
+
key: t.key,
|
|
472
|
+
"aria-sort": t.sortDirection,
|
|
473
|
+
class: x(["bb-table-header", t.classes]),
|
|
474
|
+
scope: "col"
|
|
475
|
+
}, [E(e.$slots, t.slotName, {
|
|
476
|
+
classes: t.classes,
|
|
477
|
+
items: O(Ot),
|
|
478
|
+
label: t.label
|
|
479
|
+
}, () => [y("span", we, D(t.label), 1)])], 10, Ce))), 128)),
|
|
480
|
+
e.actions ? (C(), v("th", {
|
|
481
|
+
key: 1,
|
|
482
|
+
class: x(["bb-table-header bb-table-header--actions", e.thClass]),
|
|
483
|
+
scope: "col"
|
|
484
|
+
}, [E(e.$slots, "header:actions", { text: e.actionsText }, () => [y("span", Te, D(e.actionsText), 1)])], 2)) : _("", !0)
|
|
485
|
+
], 8, ye)])]),
|
|
486
|
+
y("tbody", null, [Ct.value ? E(e.$slots, "loading", {
|
|
487
|
+
key: 0,
|
|
488
|
+
items: O(Ot)
|
|
489
|
+
}, () => [(C(!0), v(h, null, T(Gt.value, (n, r) => (C(), v("tr", {
|
|
490
|
+
key: r,
|
|
491
|
+
"aria-rowindex": q.value ? r + 2 : void 0,
|
|
492
|
+
class: "bb-table-skeleton__row"
|
|
493
|
+
}, [
|
|
494
|
+
e.selectable ? (C(), v("td", De, t[1] ||= [y("div", { class: "bb-table-skeleton__placeholder" }, null, -1)])) : _("", !0),
|
|
495
|
+
(C(!0), v(h, null, T(A.columns, (e, n) => (C(), v("td", {
|
|
496
|
+
key: e.key,
|
|
497
|
+
class: x(["bb-table-skeleton__cell", `bb-table-skeleton__cell--${e.skeleton ?? "text"}`])
|
|
498
|
+
}, [!e.skeleton || e.skeleton === "text" ? (C(), v("div", Oe, [y("div", {
|
|
499
|
+
class: "bb-table-skeleton__line",
|
|
500
|
+
style: S({ width: `${$[(r + n) % 4]}%` })
|
|
501
|
+
}, null, 4), y("div", {
|
|
502
|
+
class: "bb-table-skeleton__line",
|
|
503
|
+
style: S({ width: `${$[(r + n + 2) % 4]}%` })
|
|
504
|
+
}, null, 4)])) : e.skeleton === "avatar" ? (C(), v("div", ke)) : e.skeleton === "avatar-text" ? (C(), v("div", Ae, [t[2] ||= y("div", { class: "bb-table-skeleton__avatar" }, null, -1), y("div", je, [y("div", {
|
|
505
|
+
class: "bb-table-skeleton__line",
|
|
506
|
+
style: S({ width: `${$[(r + n) % 4]}%` })
|
|
507
|
+
}, null, 4), y("div", {
|
|
508
|
+
class: "bb-table-skeleton__line",
|
|
509
|
+
style: S({ width: `${$[(r + n + 2) % 4]}%` })
|
|
510
|
+
}, null, 4)])])) : e.skeleton === "image" ? (C(), v("div", Me)) : e.skeleton === "badge" ? (C(), v("div", Ne)) : _("", !0)], 2))), 128)),
|
|
511
|
+
e.actions ? (C(), v("td", Pe, t[3] ||= [y("div", { class: "bb-table-skeleton__placeholder" }, null, -1)])) : _("", !0)
|
|
512
|
+
], 8, Ee))), 128)), y("tr", {
|
|
513
|
+
"aria-rowindex": q.value ? Gt.value + 2 : void 0,
|
|
514
|
+
class: "bb-table-loading__row bb-table-loading__row--sr-only"
|
|
515
|
+
}, [y("td", {
|
|
516
|
+
colspan: Tt.value,
|
|
517
|
+
class: "bb-table-loading__cell",
|
|
518
|
+
"aria-live": "polite",
|
|
519
|
+
role: "status"
|
|
520
|
+
}, [y("span", Le, D(e.loadingText), 1)], 8, Ie)], 8, Fe)]) : O(J).length ? E(e.$slots, "tbody", { key: 2 }, () => [(C(!0), v(h, null, T(It.value, (t) => (C(), v(h, { key: t.valueHash }, [y("tr", {
|
|
521
|
+
"aria-rowindex": q.value && t.rowIndex ? t.rowIndex : void 0,
|
|
522
|
+
class: "bb-table-data__row",
|
|
523
|
+
onClick: t.onRowClick,
|
|
524
|
+
onContextmenu: t.onRowContextMenu,
|
|
525
|
+
onDblclick: t.onRowDblClick
|
|
526
|
+
}, [
|
|
527
|
+
e.selectable ? (C(), v("td", {
|
|
528
|
+
key: 0,
|
|
529
|
+
class: x(["bb-table-data__cell bb-table-data__cell--select", e.tdClass])
|
|
530
|
+
}, [E(e.$slots, "select", {
|
|
531
|
+
checked: Ht(t),
|
|
532
|
+
disabled: !!t.disabled,
|
|
533
|
+
inputName: O(qe),
|
|
534
|
+
item: t.item,
|
|
535
|
+
readonly: !!e.readonly,
|
|
536
|
+
value: t.value
|
|
537
|
+
}, () => [e.multiple ? (C(), v("label", {
|
|
538
|
+
key: 0,
|
|
539
|
+
class: x(["bb-table-check__label", { "bb-table-check__label--disabled": t.disabled }])
|
|
540
|
+
}, [se(a, {
|
|
541
|
+
checked: Ht(t),
|
|
542
|
+
class: "bb-table-check",
|
|
543
|
+
disabled: t.disabled,
|
|
544
|
+
readonly: e.readonly,
|
|
545
|
+
onChange: () => Vt(t)
|
|
546
|
+
}, null, 8, [
|
|
547
|
+
"checked",
|
|
548
|
+
"disabled",
|
|
549
|
+
"readonly",
|
|
550
|
+
"onChange"
|
|
551
|
+
]), y("span", He, D(t.accessibleLabel), 1)], 2)) : (C(), v("label", {
|
|
552
|
+
key: 1,
|
|
553
|
+
class: x(["bb-table-radio__label", { "bb-table-radio__label--disabled": t.disabled }])
|
|
554
|
+
}, [se(f, {
|
|
555
|
+
checked: t.selected,
|
|
556
|
+
class: "bb-table-radio",
|
|
557
|
+
disabled: t.disabled,
|
|
558
|
+
name: O(qe),
|
|
559
|
+
readonly: e.readonly,
|
|
560
|
+
value: t.value,
|
|
561
|
+
onChange: () => Vt(t)
|
|
562
|
+
}, null, 8, [
|
|
563
|
+
"checked",
|
|
564
|
+
"disabled",
|
|
565
|
+
"name",
|
|
566
|
+
"readonly",
|
|
567
|
+
"value",
|
|
568
|
+
"onChange"
|
|
569
|
+
]), y("span", Ue, D(t.accessibleLabel), 1)], 2))])], 2)) : _("", !0),
|
|
570
|
+
(C(!0), v(h, null, T(t.cols, (n) => (C(), v("td", {
|
|
571
|
+
key: n.key,
|
|
572
|
+
class: x(["bb-table-data__cell", n.classes])
|
|
573
|
+
}, [E(e.$slots, n.slotName, {
|
|
574
|
+
classes: n.classes,
|
|
575
|
+
content: n.content,
|
|
576
|
+
expanded: t.expanded,
|
|
577
|
+
item: t.item,
|
|
578
|
+
expandProps: zt(t),
|
|
579
|
+
toggleExpanded: () => Z(t.valueHash),
|
|
580
|
+
value: t.value
|
|
581
|
+
}, () => [oe(D(n.content), 1)])], 2))), 128)),
|
|
582
|
+
e.actions ? (C(), v("td", {
|
|
583
|
+
key: 1,
|
|
584
|
+
class: x(["bb-table__cell bb-table__cell--actions", e.tdClass])
|
|
585
|
+
}, [E(e.$slots, "actions", {
|
|
586
|
+
expanded: t.expanded,
|
|
587
|
+
item: t.item,
|
|
588
|
+
expandProps: zt(t),
|
|
589
|
+
toggleExpanded: () => Z(t.valueHash),
|
|
590
|
+
value: t.value
|
|
591
|
+
})], 2)) : _("", !0)
|
|
592
|
+
], 40, Ve), t.expanded ? (C(), v("tr", {
|
|
593
|
+
key: 0,
|
|
594
|
+
"aria-rowindex": q.value && t.rowIndex ? t.rowIndex + 1 : void 0,
|
|
595
|
+
id: `expanded_${t.valueHash}`,
|
|
596
|
+
class: "bb-table-expand__row"
|
|
597
|
+
}, [y("td", {
|
|
598
|
+
colspan: Tt.value,
|
|
599
|
+
class: "bb-table-expand__cell"
|
|
600
|
+
}, [E(e.$slots, "expand", {
|
|
601
|
+
expanded: t.expanded,
|
|
602
|
+
item: t.item,
|
|
603
|
+
expandProps: zt(t),
|
|
604
|
+
toggleExpanded: () => Z(t.valueHash),
|
|
605
|
+
value: t.value
|
|
606
|
+
})], 8, Ge)], 8, We)) : _("", !0)], 64))), 128))]) : E(e.$slots, "no-data", { key: 1 }, () => [y("tr", {
|
|
607
|
+
"aria-rowindex": q.value ? 2 : void 0,
|
|
608
|
+
class: "bb-table-no-data__row"
|
|
609
|
+
}, [y("td", {
|
|
610
|
+
class: "bb-table-no-data__cell",
|
|
611
|
+
colspan: Tt.value
|
|
612
|
+
}, [y("span", Be, D(e.noDataText || O(M)("table.noDataText").value), 1)], 8, ze)], 8, Re)])]),
|
|
613
|
+
y("tfoot", null, [E(e.$slots, "tfoot")])
|
|
614
|
+
], 512),
|
|
615
|
+
(C(!0), v(h, null, T(Wt.value, (e) => (C(), v("input", le({
|
|
616
|
+
key: e.value,
|
|
617
|
+
ref_for: !0
|
|
618
|
+
}, e), null, 16))), 128))
|
|
619
|
+
]),
|
|
620
|
+
_: 3
|
|
621
|
+
}, 8, [
|
|
622
|
+
"aria-busy",
|
|
623
|
+
"aria-rowcount",
|
|
624
|
+
"class",
|
|
625
|
+
"data-bb-table-id",
|
|
626
|
+
"inert",
|
|
627
|
+
"style"
|
|
628
|
+
]));
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
//#endregion
|
|
632
|
+
export { Ke as default };
|