@leaflink/stash 53.4.6 → 53.4.7
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/AppSidebar.js +43 -41
- package/dist/AppSidebar.js.map +1 -1
- package/dist/AppTopbar.js +1 -1
- package/dist/Copy.js +1 -1
- package/dist/DataViewFilters.js +1 -1
- package/dist/DataViewFilters.js.map +1 -1
- package/dist/DataViewToolbar.js +139 -125
- package/dist/DataViewToolbar.js.map +1 -1
- package/dist/DatePicker.js +1114 -1113
- package/dist/DatePicker.js.map +1 -1
- package/dist/Modal.js +104 -90
- package/dist/Modal.js.map +1 -1
- package/dist/MoreActions.js +294 -288
- package/dist/MoreActions.js.map +1 -1
- package/dist/PageNavigation.js +1 -1
- package/dist/RadioGroup.js +69 -62
- package/dist/RadioGroup.js.map +1 -1
- package/dist/Select.js +90 -90
- package/dist/Select.js.map +1 -1
- package/dist/Stepper.js +1 -1
- package/dist/Tab.js +1 -1
- package/dist/Table.js +1 -1
- package/dist/Tabs.js +2 -2
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-DEopbeSY.js +131 -0
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-DEopbeSY.js.map +1 -0
- package/dist/Thumbnail.js +42 -42
- package/dist/Thumbnail.js.map +1 -1
- package/dist/Toast.vue.d.ts +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/{Tooltip.vue_vue_type_script_setup_true_lang-CFpM7Ldj.js → Tooltip.vue_vue_type_script_setup_true_lang-UUjw5O1x.js} +2 -2
- package/dist/{Tooltip.vue_vue_type_script_setup_true_lang-CFpM7Ldj.js.map → Tooltip.vue_vue_type_script_setup_true_lang-UUjw5O1x.js.map} +1 -1
- package/dist/components.css +1 -1
- package/dist/getContrastingTextColor.d.ts +8 -0
- package/dist/index-t9tXBnql.js +469 -0
- package/dist/{index-DA70nQCT.js.map → index-t9tXBnql.js.map} +1 -1
- package/dist/templateRefNarrowing-CeANDylX.js +22 -0
- package/dist/templateRefNarrowing-CeANDylX.js.map +1 -0
- package/dist/useMediaQuery.d.ts +12 -10
- package/dist/useMediaQuery.js +7 -29
- package/dist/useMediaQuery.js.map +1 -1
- package/dist/useSortable.js +1 -1
- package/dist/utils/getContrastingTextColor.js +36 -24
- package/dist/utils/getContrastingTextColor.js.map +1 -1
- package/package.json +1 -1
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-B3FBaVP5.js +0 -130
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-B3FBaVP5.js.map +0 -1
- package/dist/index-DA70nQCT.js +0 -424
package/dist/DataViewToolbar.js
CHANGED
|
@@ -1,71 +1,85 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { u as
|
|
3
|
-
import { t as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { ref as K, onMounted as Q, nextTick as w, onBeforeUnmount as X, watch as D, defineComponent as Y, useTemplateRef as O, inject as Z, useCssModule as ee, computed as te, onBeforeMount as oe, createElementBlock as g, openBlock as r, normalizeClass as L, unref as e, createElementVNode as ae, createCommentVNode as x, createBlock as F, withCtx as d, renderSlot as E, createVNode as h, createTextVNode as se, toDisplayString as U, Fragment as le } from "vue";
|
|
2
|
+
import { u as ne } from "./usePaginationStats-d_q39naC.js";
|
|
3
|
+
import { t as R } from "./locale.js";
|
|
4
|
+
import A from "./Button.js";
|
|
5
|
+
import ie from "./Checkbox.js";
|
|
6
6
|
import "lodash-es/cloneDeep";
|
|
7
7
|
import "./Module.keys-DcqBbvvT.js";
|
|
8
|
-
import
|
|
9
|
-
import { D as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
import j from "./Icon.js";
|
|
9
|
+
import { D as J } from "./DataView.keys-aSOnA4AD.js";
|
|
10
|
+
import re from "./IconLabel.js";
|
|
11
|
+
import de from "./MoreActions.js";
|
|
12
|
+
import { t as y, a as ce } from "./templateRefNarrowing-CeANDylX.js";
|
|
13
|
+
import { _ as ue } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
14
|
+
function pe(z) {
|
|
15
|
+
const { toolbarEl: C, paginationEl: t, checkboxEl: B, isPaginationEnabled: c, isSelectable: u, isEmpty: p } = z, m = K(null);
|
|
16
|
+
let i = null, o = null;
|
|
17
|
+
const s = () => {
|
|
18
|
+
const a = y(C.value);
|
|
19
|
+
if (!a) return;
|
|
20
|
+
const l = a.getBoundingClientRect().width;
|
|
21
|
+
let v = 0, S = 0;
|
|
22
|
+
if (c != null && c.value) {
|
|
23
|
+
const n = y(t.value);
|
|
24
|
+
n && (v = n.getBoundingClientRect().width);
|
|
25
|
+
}
|
|
26
|
+
if (u != null && u.value && !(p != null && p.value)) {
|
|
27
|
+
const n = ce(B.value);
|
|
28
|
+
n && (S = n.getBoundingClientRect().width);
|
|
29
|
+
}
|
|
30
|
+
const k = window.getComputedStyle(a), W = parseFloat(k.paddingLeft) || 0, $ = parseFloat(k.paddingRight) || 0, V = Math.max(0, l - v - S - W - $);
|
|
31
|
+
m.value = `${V}px`;
|
|
32
|
+
}, _ = () => {
|
|
33
|
+
const a = y(C.value);
|
|
34
|
+
if (!a) return;
|
|
35
|
+
i = new ResizeObserver(() => {
|
|
26
36
|
w(() => {
|
|
27
|
-
|
|
37
|
+
s();
|
|
28
38
|
});
|
|
29
|
-
}),
|
|
39
|
+
}), i.observe(a);
|
|
40
|
+
const l = y(t.value);
|
|
41
|
+
l && (o = new ResizeObserver(() => {
|
|
30
42
|
w(() => {
|
|
31
|
-
|
|
43
|
+
s();
|
|
32
44
|
});
|
|
33
|
-
}), o.observe(
|
|
34
|
-
},
|
|
35
|
-
|
|
45
|
+
}), o.observe(l));
|
|
46
|
+
}, T = () => {
|
|
47
|
+
i && (i.disconnect(), i = null), o && (o.disconnect(), o = null);
|
|
36
48
|
};
|
|
37
|
-
return
|
|
49
|
+
return Q(() => {
|
|
38
50
|
w(() => {
|
|
39
|
-
|
|
51
|
+
s(), _();
|
|
40
52
|
});
|
|
41
|
-
}),
|
|
42
|
-
|
|
43
|
-
}), D([
|
|
53
|
+
}), X(() => {
|
|
54
|
+
T();
|
|
55
|
+
}), D([c, u, p], () => {
|
|
44
56
|
w(() => {
|
|
45
|
-
|
|
57
|
+
s();
|
|
46
58
|
});
|
|
47
|
-
}), D(t, (
|
|
48
|
-
o && (o.disconnect(), o = null)
|
|
59
|
+
}), D(t, (a) => {
|
|
60
|
+
o && (o.disconnect(), o = null);
|
|
61
|
+
const l = y(a);
|
|
62
|
+
l && (o = new ResizeObserver(() => {
|
|
49
63
|
w(() => {
|
|
50
|
-
|
|
64
|
+
s();
|
|
51
65
|
});
|
|
52
|
-
}), o.observe(
|
|
66
|
+
}), o.observe(l));
|
|
53
67
|
}), {
|
|
54
|
-
actionsWidth:
|
|
55
|
-
updateActionsWidth:
|
|
68
|
+
actionsWidth: m,
|
|
69
|
+
updateActionsWidth: s
|
|
56
70
|
};
|
|
57
71
|
}
|
|
58
|
-
const
|
|
72
|
+
const me = { class: "flex place-items-center" }, fe = {
|
|
59
73
|
key: 0,
|
|
60
74
|
ref: "paginationEl",
|
|
61
75
|
class: "stash-data-view-toolbar__pagination flex shrink-0 items-center"
|
|
62
|
-
},
|
|
76
|
+
}, be = {
|
|
63
77
|
key: 0,
|
|
64
78
|
class: "mx-1.5"
|
|
65
|
-
},
|
|
79
|
+
}, ge = {
|
|
66
80
|
key: 0,
|
|
67
81
|
class: "mx-1.5 hidden md:block"
|
|
68
|
-
},
|
|
82
|
+
}, he = /* @__PURE__ */ Y({
|
|
69
83
|
__name: "DataViewToolbar",
|
|
70
84
|
props: {
|
|
71
85
|
allRowsSelected: { type: Boolean, default: !1 },
|
|
@@ -76,80 +90,80 @@ const ue = { class: "flex place-items-center" }, pe = {
|
|
|
76
90
|
hasTabsAbove: { type: Boolean, default: !1 }
|
|
77
91
|
},
|
|
78
92
|
emits: ["select"],
|
|
79
|
-
setup(z, { emit:
|
|
80
|
-
const t = z,
|
|
81
|
-
isWithinModule:
|
|
82
|
-
variant:
|
|
93
|
+
setup(z, { emit: C }) {
|
|
94
|
+
const t = z, B = C, c = O("toolbarEl"), u = O("paginationEl"), p = O("checkboxEl"), {
|
|
95
|
+
isWithinModule: m,
|
|
96
|
+
variant: i,
|
|
83
97
|
density: o,
|
|
84
|
-
currentPage:
|
|
85
|
-
hasToolbar:
|
|
86
|
-
isPaginateNextDisabled:
|
|
87
|
-
isPaginationEnabled:
|
|
88
|
-
isSelectable:
|
|
89
|
-
pageCount:
|
|
98
|
+
currentPage: s,
|
|
99
|
+
hasToolbar: _,
|
|
100
|
+
isPaginateNextDisabled: T,
|
|
101
|
+
isPaginationEnabled: a,
|
|
102
|
+
isSelectable: l,
|
|
103
|
+
pageCount: v,
|
|
90
104
|
pageSize: S,
|
|
91
|
-
totalDataCount:
|
|
92
|
-
goPrevPage:
|
|
93
|
-
goNextPage:
|
|
94
|
-
isEmpty:
|
|
95
|
-
isLoading:
|
|
96
|
-
} =
|
|
97
|
-
toolbarEl:
|
|
98
|
-
paginationEl:
|
|
99
|
-
checkboxEl:
|
|
100
|
-
isPaginationEnabled:
|
|
101
|
-
isSelectable:
|
|
102
|
-
isEmpty:
|
|
103
|
-
}),
|
|
104
|
-
function
|
|
105
|
-
|
|
105
|
+
totalDataCount: k,
|
|
106
|
+
goPrevPage: W,
|
|
107
|
+
goNextPage: $,
|
|
108
|
+
isEmpty: V,
|
|
109
|
+
isLoading: n
|
|
110
|
+
} = Z(J.key, J.defaults), N = K(0), q = ee(), { actionsWidth: G } = pe({
|
|
111
|
+
toolbarEl: c,
|
|
112
|
+
paginationEl: u,
|
|
113
|
+
checkboxEl: p,
|
|
114
|
+
isPaginationEnabled: a,
|
|
115
|
+
isSelectable: l,
|
|
116
|
+
isEmpty: V
|
|
117
|
+
}), I = te(() => t.radius ? t.radius : m.value ? "none" : i.value === "table" ? t.hasTabsAbove ? "rounded-top-right" : "rounded-top" : "rounded"), H = ne({ currentPage: s, pageSize: S, totalItems: k });
|
|
118
|
+
function P() {
|
|
119
|
+
B("select"), N.value++;
|
|
106
120
|
}
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
}), (
|
|
121
|
+
return oe(() => {
|
|
122
|
+
_ && (_.value = !0);
|
|
123
|
+
}), (f, b) => (r(), g("div", {
|
|
110
124
|
ref: "toolbarEl",
|
|
111
|
-
class:
|
|
112
|
-
"border-t border-ice-200": e(
|
|
113
|
-
"rounded-tr":
|
|
114
|
-
rounded:
|
|
115
|
-
"rounded-t":
|
|
116
|
-
"mb-3": e(
|
|
125
|
+
class: L(["stash-data-view-toolbar flex min-h-15 items-center justify-between bg-white py-1.5 shadow", {
|
|
126
|
+
"border-t border-ice-200": e(m),
|
|
127
|
+
"rounded-tr": I.value === "rounded-top-right",
|
|
128
|
+
rounded: I.value === "rounded",
|
|
129
|
+
"rounded-t": I.value === "rounded-top",
|
|
130
|
+
"mb-3": e(i) !== "table" && !e(m),
|
|
117
131
|
"px-3": e(o) === "compact",
|
|
118
132
|
"px-3 lg:px-6": e(o) === "comfortable"
|
|
119
133
|
}]),
|
|
120
134
|
"data-test": "stash-data-view-toolbar"
|
|
121
135
|
}, [
|
|
122
|
-
|
|
123
|
-
e(
|
|
136
|
+
ae("div", me, [
|
|
137
|
+
e(l) && !e(V) ? (r(), F(ie, {
|
|
124
138
|
ref: "checkboxEl",
|
|
125
|
-
key:
|
|
139
|
+
key: N.value,
|
|
126
140
|
checked: t.allRowsSelected,
|
|
127
141
|
indeterminate: t.someRowsSelected && !t.allRowsSelected,
|
|
128
|
-
title: e(
|
|
129
|
-
disabled: e(
|
|
130
|
-
"onUpdate:indeterminate":
|
|
131
|
-
"onUpdate:checked":
|
|
142
|
+
title: e(R)("ll.selectAll"),
|
|
143
|
+
disabled: e(n),
|
|
144
|
+
"onUpdate:indeterminate": P,
|
|
145
|
+
"onUpdate:checked": P
|
|
132
146
|
}, null, 8, ["checked", "indeterminate", "title", "disabled"])) : x("", !0),
|
|
133
|
-
|
|
147
|
+
f.$slots["more-actions"] ? (r(), F(de, {
|
|
134
148
|
key: 1,
|
|
135
149
|
"more-button-align": "together",
|
|
136
|
-
width: e(
|
|
150
|
+
width: e(G) || void 0,
|
|
137
151
|
"actions-container-class": "flex items-center gap-x-2 lg:mr-6 lg:gap-x-6"
|
|
138
152
|
}, {
|
|
139
|
-
toggle:
|
|
140
|
-
|
|
153
|
+
toggle: d(({ toggle: M }) => [
|
|
154
|
+
h(A, {
|
|
141
155
|
"icon-label": "",
|
|
142
156
|
class: "text-blue-500",
|
|
143
157
|
"data-test": "stash-data-view-sort-button|sort-menu-button",
|
|
144
|
-
onClick:
|
|
158
|
+
onClick: M
|
|
145
159
|
}, {
|
|
146
|
-
default:
|
|
147
|
-
|
|
160
|
+
default: d(() => [
|
|
161
|
+
h(re, {
|
|
148
162
|
icon: "ellipsis",
|
|
149
163
|
stacked: ""
|
|
150
164
|
}, {
|
|
151
|
-
default:
|
|
152
|
-
|
|
165
|
+
default: d(() => [...b[2] || (b[2] = [
|
|
166
|
+
se(" More ", -1)
|
|
153
167
|
])]),
|
|
154
168
|
_: 1
|
|
155
169
|
})
|
|
@@ -157,54 +171,54 @@ const ue = { class: "flex place-items-center" }, pe = {
|
|
|
157
171
|
_: 1
|
|
158
172
|
}, 8, ["onClick"])
|
|
159
173
|
]),
|
|
160
|
-
"more-actions":
|
|
161
|
-
|
|
174
|
+
"more-actions": d(() => [
|
|
175
|
+
E(f.$slots, "more-actions")
|
|
162
176
|
]),
|
|
163
|
-
default:
|
|
164
|
-
|
|
177
|
+
default: d(() => [
|
|
178
|
+
E(f.$slots, "default")
|
|
165
179
|
]),
|
|
166
180
|
_: 3
|
|
167
|
-
}, 8, ["width"])) : (
|
|
181
|
+
}, 8, ["width"])) : (r(), g("div", {
|
|
168
182
|
key: 2,
|
|
169
|
-
class:
|
|
183
|
+
class: L([e(q).actions, "stash-data-view-toolbar__actions flex items-center gap-x-2 lg:gap-x-4"])
|
|
170
184
|
}, [
|
|
171
|
-
|
|
185
|
+
E(f.$slots, "default")
|
|
172
186
|
], 2))
|
|
173
187
|
]),
|
|
174
|
-
e(
|
|
175
|
-
|
|
176
|
-
t.someRowsSelected && t.selectedItemsCount !== void 0 ? (
|
|
188
|
+
e(a) ? (r(), g("div", fe, [
|
|
189
|
+
E(f.$slots, "selected-stats", {}, () => [
|
|
190
|
+
t.someRowsSelected && t.selectedItemsCount !== void 0 ? (r(), g("span", be, U(e(R)("ll.listView.numberOfTotalSelected", { num: t.selectedItemsCount, total: e(k) })), 1)) : x("", !0)
|
|
177
191
|
]),
|
|
178
|
-
|
|
179
|
-
t.hidePageStats ? x("", !0) : (
|
|
192
|
+
E(f.$slots, "page-stats", {}, () => [
|
|
193
|
+
t.hidePageStats ? x("", !0) : (r(), g("span", ge, U(e(R)("ll.pageStats", e(H))), 1))
|
|
180
194
|
]),
|
|
181
|
-
e(
|
|
182
|
-
|
|
195
|
+
e(v) > 1 ? (r(), g(le, { key: 0 }, [
|
|
196
|
+
h(A, {
|
|
183
197
|
icon: "",
|
|
184
|
-
"aria-label": e(
|
|
198
|
+
"aria-label": e(R)("ll.previous"),
|
|
185
199
|
class: "size-9 p-1.5",
|
|
186
200
|
"data-test": "button|prev-page",
|
|
187
|
-
disabled: e(
|
|
188
|
-
onClick:
|
|
201
|
+
disabled: e(n) || e(s) === 1,
|
|
202
|
+
onClick: b[0] || (b[0] = (M) => e(W)({ shouldEmit: !0 }))
|
|
189
203
|
}, {
|
|
190
|
-
default:
|
|
191
|
-
|
|
204
|
+
default: d(() => [
|
|
205
|
+
h(j, {
|
|
192
206
|
name: "chevron-left",
|
|
193
207
|
size: "dense"
|
|
194
208
|
})
|
|
195
209
|
]),
|
|
196
210
|
_: 1
|
|
197
211
|
}, 8, ["aria-label", "disabled"]),
|
|
198
|
-
|
|
212
|
+
h(A, {
|
|
199
213
|
icon: "",
|
|
200
|
-
"aria-label": e(
|
|
214
|
+
"aria-label": e(R)("ll.next"),
|
|
201
215
|
class: "size-9 p-1.5",
|
|
202
216
|
"data-test": "button|next-page",
|
|
203
|
-
disabled: e(
|
|
204
|
-
onClick:
|
|
217
|
+
disabled: e(n) || e(T) || e(s) === e(v),
|
|
218
|
+
onClick: b[1] || (b[1] = (M) => e($)({ shouldEmit: !0 }))
|
|
205
219
|
}, {
|
|
206
|
-
default:
|
|
207
|
-
|
|
220
|
+
default: d(() => [
|
|
221
|
+
h(j, {
|
|
208
222
|
name: "chevron-right",
|
|
209
223
|
size: "dense"
|
|
210
224
|
})
|
|
@@ -215,12 +229,12 @@ const ue = { class: "flex place-items-center" }, pe = {
|
|
|
215
229
|
], 512)) : x("", !0)
|
|
216
230
|
], 2));
|
|
217
231
|
}
|
|
218
|
-
}), ve = "_actions_1i7a8_3",
|
|
232
|
+
}), ve = "_actions_1i7a8_3", ke = {
|
|
219
233
|
actions: ve
|
|
220
|
-
},
|
|
221
|
-
$style:
|
|
222
|
-
},
|
|
234
|
+
}, we = {
|
|
235
|
+
$style: ke
|
|
236
|
+
}, Ie = /* @__PURE__ */ ue(he, [["__cssModules", we]]);
|
|
223
237
|
export {
|
|
224
|
-
|
|
238
|
+
Ie as default
|
|
225
239
|
};
|
|
226
240
|
//# sourceMappingURL=DataViewToolbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataViewToolbar.js","sources":["../src/components/DataViewToolbar/useActionsWidth.ts","../src/components/DataViewToolbar/DataViewToolbar.vue"],"sourcesContent":["import { ComputedRef, nextTick, onBeforeUnmount, onMounted, Ref, ref, ShallowRef, watch } from 'vue';\n\nexport interface UseActionsWidthOptions {\n toolbarEl: ShallowRef<HTMLElement | null>;\n paginationEl: ShallowRef<HTMLElement | null>;\n checkboxEl: ShallowRef<{ $el: HTMLElement } | null>;\n isPaginationEnabled: ComputedRef<boolean> | undefined;\n isSelectable: Ref<boolean> | undefined;\n isEmpty: ComputedRef<boolean> | undefined;\n}\n\nexport function useActionsWidth(options: UseActionsWidthOptions) {\n const { toolbarEl, paginationEl, checkboxEl, isPaginationEnabled, isSelectable, isEmpty } = options;\n\n const actionsWidth = ref<string | null>(null);\n let toolbarResizeObserver: ResizeObserver | null = null;\n let paginationResizeObserver: ResizeObserver | null = null;\n\n const updateActionsWidth = () => {\n if (!toolbarEl.value) return;\n\n const toolbarWidth = toolbarEl.value.getBoundingClientRect().width;\n let paginationWidth = 0;\n let checkboxWidth = 0;\n\n // Calculate pagination width if pagination is enabled\n if (isPaginationEnabled?.value && paginationEl.value) {\n paginationWidth = paginationEl.value.getBoundingClientRect().width;\n }\n\n // Calculate checkbox width if selectable and not empty\n if (isSelectable?.value && !isEmpty?.value && checkboxEl.value?.$el) {\n checkboxWidth = checkboxEl.value.$el.getBoundingClientRect().width;\n }\n\n // Get computed styles to calculate padding\n const computedStyle = window.getComputedStyle(toolbarEl.value);\n const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;\n const paddingRight = parseFloat(computedStyle.paddingRight) || 0;\n\n const availableWidth = Math.max(0, toolbarWidth - paginationWidth - checkboxWidth - paddingLeft - paddingRight);\n actionsWidth.value = `${availableWidth}px`;\n };\n\n const setupResizeObserver = () => {\n if (!toolbarEl.value) return;\n\n // Observe toolbar element\n toolbarResizeObserver = new ResizeObserver(() => {\n nextTick(() => {\n updateActionsWidth();\n });\n });\n toolbarResizeObserver.observe(toolbarEl.value);\n\n // Observe pagination element if it exists\n if (paginationEl.value) {\n paginationResizeObserver = new ResizeObserver(() => {\n nextTick(() => {\n updateActionsWidth();\n });\n });\n paginationResizeObserver.observe(paginationEl.value);\n }\n };\n\n const cleanupResizeObserver = () => {\n if (toolbarResizeObserver) {\n toolbarResizeObserver.disconnect();\n toolbarResizeObserver = null;\n }\n if (paginationResizeObserver) {\n paginationResizeObserver.disconnect();\n paginationResizeObserver = null;\n }\n };\n\n onMounted(() => {\n nextTick(() => {\n updateActionsWidth();\n setupResizeObserver();\n });\n });\n\n onBeforeUnmount(() => {\n cleanupResizeObserver();\n });\n\n // Watch for changes in conditions that affect element visibility\n watch([isPaginationEnabled, isSelectable, isEmpty], () => {\n nextTick(() => {\n updateActionsWidth();\n });\n });\n\n // Watch for pagination element changes to setup/cleanup observer\n watch(paginationEl, (newPaginationEl) => {\n // Cleanup old observer if it exists\n if (paginationResizeObserver) {\n paginationResizeObserver.disconnect();\n paginationResizeObserver = null;\n }\n\n // Setup new observer if pagination element exists\n if (newPaginationEl) {\n paginationResizeObserver = new ResizeObserver(() => {\n nextTick(() => {\n updateActionsWidth();\n });\n });\n paginationResizeObserver.observe(newPaginationEl);\n }\n });\n\n return {\n actionsWidth,\n updateActionsWidth,\n };\n}\n","<script setup lang=\"ts\">\n import { computed, inject, onBeforeMount, ref, useCssModule, useTemplateRef } from 'vue';\n\n import usePaginationStats from '../../composables/usePaginationStats/usePaginationStats';\n import { t } from '../../locale';\n import Button from '../Button/Button.vue';\n import Checkbox from '../Checkbox/Checkbox.vue';\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import Icon from '../Icon/Icon.vue';\n import IconLabel from '../IconLabel/IconLabel.vue';\n import MoreActions from '../MoreActions/MoreActions.vue';\n import { ToolbarRadiuses } from './DataViewToolbar.types';\n import { useActionsWidth } from './useActionsWidth';\n\n export interface DataViewToolbarProps {\n /**\n * When DataView has `variant=\"table\"` and Table has `is-selectable` enabled, it provides a way to flag\n * a checkbox whenever all rows are selected, just like the standalone version on TableHeaderRow.\n */\n allRowsSelected?: boolean;\n\n /**\n * Hides the page statistics (ex: \"1 - 12 of 20\") in the toolbar\n */\n hidePageStats?: boolean;\n\n /**\n * Controls the corners of DataViewToolbar with the \"border-radius\" CSS property. The default value is \"rounded\".\n */\n radius?: ToolbarRadiuses;\n\n /**\n * When DataView has variant=\"table\" and Table has `is-selectable` enabled, it provides a way to flag\n * a checkbox whenever one or more, but not all rows are selected, just like the standalone\n * version on TableHeaderRow.\n */\n someRowsSelected?: boolean;\n\n /**\n * The number of selected items. Used to display selected items count in the toolbar.\n */\n selectedItemsCount?: number;\n\n /**\n * When DataView has tabs above it, we need to remove the top left rounded corner\n */\n hasTabsAbove?: boolean;\n }\n\n const props = withDefaults(defineProps<DataViewToolbarProps>(), {\n allRowsSelected: false,\n hidePageStats: false,\n radius: undefined,\n someRowsSelected: false,\n selectedItemsCount: undefined,\n hasTabsAbove: false,\n });\n\n const emit = defineEmits<{\n (e: 'select'): void;\n }>();\n\n // Refs for width calculation\n const toolbarRef = useTemplateRef('toolbarEl');\n const paginationRef = useTemplateRef('paginationEl');\n const checkboxRef = useTemplateRef('checkboxEl');\n\n const {\n isWithinModule,\n variant: dataViewVariant,\n density,\n currentPage,\n hasToolbar,\n isPaginateNextDisabled,\n isPaginationEnabled,\n isSelectable,\n pageCount,\n pageSize,\n totalDataCount,\n goPrevPage,\n goNextPage,\n isEmpty,\n isLoading,\n } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n const checkboxKey = ref(0);\n const classes = useCssModule();\n\n const { actionsWidth } = useActionsWidth({\n toolbarEl: toolbarRef,\n paginationEl: paginationRef,\n checkboxEl: checkboxRef,\n isPaginationEnabled,\n isSelectable,\n isEmpty,\n });\n\n const computedRadius = computed<ToolbarRadiuses>(() => {\n if (props.radius) {\n return props.radius;\n }\n\n if (isWithinModule.value) {\n return 'none';\n }\n\n if (dataViewVariant.value === 'table') {\n if (props.hasTabsAbove) {\n return 'rounded-top-right';\n }\n\n return 'rounded-top';\n }\n\n return 'rounded';\n });\n\n const pageStats = usePaginationStats({ currentPage, pageSize, totalItems: totalDataCount });\n\n function onSelect() {\n emit('select');\n\n /**\n * In Vue (as of this writing), if a user checks a native checkbox but the v-model is `false` and does not change from `false`, then the checkbox will display as checked even though the v-model is still `false`.\n * Forcing a re-render with a `key` change allows the checkbox to stay unchecked if its v-model is still `false` and its v-model not been changed.\n * To verify that this is necessary, test the \"select all\" checkbox in the SelectionWithSomeDisabled story in Table.story.ts with and without the `key` attribute.\n */\n checkboxKey.value++;\n }\n\n onBeforeMount(() => {\n if (hasToolbar) {\n hasToolbar.value = true;\n }\n });\n</script>\n\n<template>\n <div\n ref=\"toolbarEl\"\n class=\"stash-data-view-toolbar flex min-h-15 items-center justify-between bg-white py-1.5 shadow\"\n :class=\"{\n 'border-t border-ice-200': isWithinModule,\n 'rounded-tr': computedRadius === 'rounded-top-right',\n rounded: computedRadius === 'rounded',\n 'rounded-t': computedRadius === 'rounded-top',\n 'mb-3': dataViewVariant !== 'table' && !isWithinModule,\n 'px-3': density === 'compact',\n 'px-3 lg:px-6': density === 'comfortable',\n }\"\n data-test=\"stash-data-view-toolbar\"\n >\n <div class=\"flex place-items-center\">\n <Checkbox\n v-if=\"isSelectable && !isEmpty\"\n ref=\"checkboxEl\"\n :key=\"checkboxKey\"\n :checked=\"props.allRowsSelected\"\n :indeterminate=\"props.someRowsSelected && !props.allRowsSelected\"\n :title=\"t('ll.selectAll')\"\n :disabled=\"isLoading\"\n @update:indeterminate=\"onSelect\"\n @update:checked=\"onSelect\"\n />\n <template v-if=\"$slots['more-actions']\">\n <MoreActions\n more-button-align=\"together\"\n :width=\"actionsWidth || undefined\"\n actions-container-class=\"flex items-center gap-x-2 lg:mr-6 lg:gap-x-6\"\n >\n <template #toggle=\"{ toggle }\">\n <Button\n icon-label\n class=\"text-blue-500\"\n data-test=\"stash-data-view-sort-button|sort-menu-button\"\n @click=\"toggle\"\n >\n <IconLabel icon=\"ellipsis\" stacked> More </IconLabel>\n </Button>\n </template>\n <slot></slot>\n <template #more-actions>\n <slot name=\"more-actions\"></slot>\n </template>\n </MoreActions>\n </template>\n <template v-else>\n <div :class=\"classes.actions\" class=\"stash-data-view-toolbar__actions flex items-center gap-x-2 lg:gap-x-4\">\n <slot></slot>\n </div>\n </template>\n </div>\n\n <!-- Pagination -->\n <div\n v-if=\"isPaginationEnabled\"\n ref=\"paginationEl\"\n class=\"stash-data-view-toolbar__pagination flex shrink-0 items-center\"\n >\n <slot name=\"selected-stats\">\n <span v-if=\"props.someRowsSelected && props.selectedItemsCount !== undefined\" class=\"mx-1.5\">\n {{ t('ll.listView.numberOfTotalSelected', { num: props.selectedItemsCount, total: totalDataCount }) }}\n </span>\n </slot>\n <slot name=\"page-stats\">\n <span v-if=\"!props.hidePageStats\" class=\"mx-1.5 hidden md:block\">\n {{ t('ll.pageStats', pageStats) }}\n </span>\n </slot>\n <template v-if=\"pageCount > 1\">\n <Button\n icon\n :aria-label=\"t('ll.previous')\"\n class=\"size-9 p-1.5\"\n data-test=\"button|prev-page\"\n :disabled=\"isLoading || currentPage === 1\"\n @click=\"goPrevPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-left\" size=\"dense\" />\n </Button>\n <Button\n icon\n :aria-label=\"t('ll.next')\"\n class=\"size-9 p-1.5\"\n data-test=\"button|next-page\"\n :disabled=\"isLoading || isPaginateNextDisabled || currentPage === pageCount\"\n @click=\"goNextPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-right\" size=\"dense\" />\n </Button>\n </template>\n </div>\n </div>\n</template>\n\n<style module>\n @layer utilities {\n .actions :global(.stash-button) {\n min-width: auto;\n padding: 0 0.5rem;\n\n &:first-child {\n margin-left: -0.5rem;\n }\n }\n }\n</style>\n"],"names":["useActionsWidth","options","toolbarEl","paginationEl","checkboxEl","isPaginationEnabled","isSelectable","isEmpty","actionsWidth","ref","toolbarResizeObserver","paginationResizeObserver","updateActionsWidth","toolbarWidth","paginationWidth","checkboxWidth","_a","computedStyle","paddingLeft","paddingRight","availableWidth","setupResizeObserver","nextTick","cleanupResizeObserver","onMounted","onBeforeUnmount","watch","newPaginationEl","props","__props","emit","__emit","toolbarRef","useTemplateRef","paginationRef","checkboxRef","isWithinModule","dataViewVariant","density","currentPage","hasToolbar","isPaginateNextDisabled","pageCount","pageSize","totalDataCount","goPrevPage","goNextPage","isLoading","inject","DATA_VIEW_INJECTION","checkboxKey","classes","useCssModule","computedRadius","computed","pageStats","usePaginationStats","onSelect","onBeforeMount","_createElementBlock","_unref","_createElementVNode","_hoisted_1","_createBlock","Checkbox","t","$slots","MoreActions","_withCtx","toggle","_createVNode","Button","IconLabel","_cache","_renderSlot","_ctx","_normalizeClass","_openBlock","_hoisted_2","_hoisted_3","_toDisplayString","_hoisted_4","_Fragment","Icon"],"mappings":";;;;;;;;;;;;AAWO,SAASA,GAAgBC,GAAiC;AAC/D,QAAM,EAAE,WAAAC,GAAW,cAAAC,GAAc,YAAAC,GAAY,qBAAAC,GAAqB,cAAAC,GAAc,SAAAC,MAAYN,GAEtFO,IAAeC,EAAmB,IAAI;AAC5C,MAAIC,IAA+C,MAC/CC,IAAkD;AAEtD,QAAMC,IAAqB,MAAM;;AAC/B,QAAI,CAACV,EAAU,MAAO;AAEtB,UAAMW,IAAeX,EAAU,MAAM,sBAAA,EAAwB;AAC7D,QAAIY,IAAkB,GAClBC,IAAgB;AAGpB,IAAIV,KAAA,QAAAA,EAAqB,SAASF,EAAa,UAC7CW,IAAkBX,EAAa,MAAM,sBAAA,EAAwB,QAI3DG,KAAA,QAAAA,EAAc,SAAS,EAACC,KAAA,QAAAA,EAAS,YAASS,IAAAZ,EAAW,UAAX,QAAAY,EAAkB,SAC9DD,IAAgBX,EAAW,MAAM,IAAI,sBAAA,EAAwB;AAI/D,UAAMa,IAAgB,OAAO,iBAAiBf,EAAU,KAAK,GACvDgB,IAAc,WAAWD,EAAc,WAAW,KAAK,GACvDE,IAAe,WAAWF,EAAc,YAAY,KAAK,GAEzDG,IAAiB,KAAK,IAAI,GAAGP,IAAeC,IAAkBC,IAAgBG,IAAcC,CAAY;AAC9G,IAAAX,EAAa,QAAQ,GAAGY,CAAc;AAAA,EACxC,GAEMC,IAAsB,MAAM;AAChC,IAAKnB,EAAU,UAGfQ,IAAwB,IAAI,eAAe,MAAM;AAC/C,MAAAY,EAAS,MAAM;AACb,QAAAV,EAAA;AAAA,MACF,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EAAAK,CAAA,8CAA8CrC,EAAM,oBAAkB,OAASgC,EAAAhB,CAAA,EAAA,CAAc,CAAA,GAAA,CAAA;;QAGpG8B,EAIOC,4BAJP,MAIO;AAAA,UAHQ/C,EAAM,6BAAnBiD,EAAA,GAAAlB,EAEO,QAFPsB,IAEOD,EADFpB,EAAAK,CAAA,kBAAkBL,EAAAL,CAAA,CAAS,CAAA,GAAA,CAAA;AAAA;QAGlBK,EAAAlB,CAAA,IAAS,UAAzBiB,EAqBWuB,IAAA,EAAA,KAAA,KAAA;AAAA,UApBTZ,EASSC,GAAA;AAAA,YARP,MAAA;AAAA,YACC,cAAYX,EAAAK,CAAA,EAAC,aAAA;AAAA,YACd,OAAM;AAAA,YACN,aAAU;AAAA,YACT,UAAUL,EAAAb,CAAA,KAAaa,EAAArB,CAAA,MAAW;AAAA,YAClC,gCAAOqB,EAAAf,CAAA,EAAU,EAAA,YAAA,IAAA;AAAA,UAAA;uBAElB,MAAyC;AAAA,cAAzCyB,EAAyCa,GAAA;AAAA,gBAAnC,MAAK;AAAA,gBAAe,MAAK;AAAA,cAAA;;;;UAEjCb,EASSC,GAAA;AAAA,YARP,MAAA;AAAA,YACC,cAAYX,EAAAK,CAAA,EAAC,SAAA;AAAA,YACd,OAAM;AAAA,YACN,aAAU;AAAA,YACT,UAAUL,EAAAb,CAAA,KAAaa,QAA0BA,EAAArB,CAAA,MAAgBqB,EAAAlB,CAAA;AAAA,YACjE,gCAAOkB,EAAAd,CAAA,EAAU,EAAA,YAAA,IAAA;AAAA,UAAA;uBAElB,MAA0C;AAAA,cAA1CwB,EAA0Ca,GAAA;AAAA,gBAApC,MAAK;AAAA,gBAAgB,MAAK;AAAA,cAAA;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"DataViewToolbar.js","sources":["../src/components/DataViewToolbar/useActionsWidth.ts","../src/components/DataViewToolbar/DataViewToolbar.vue"],"sourcesContent":["import { ComputedRef, nextTick, onBeforeUnmount, onMounted, Ref, ref, ShallowRef, watch } from 'vue';\n\nimport { toComponentEl, toElement } from '../../utils/templateRefNarrowing';\n\nexport interface UseActionsWidthOptions {\n toolbarEl: ShallowRef<unknown>;\n paginationEl: ShallowRef<unknown>;\n checkboxEl: ShallowRef<unknown>;\n isPaginationEnabled: ComputedRef<boolean> | undefined;\n isSelectable: Ref<boolean> | undefined;\n isEmpty: ComputedRef<boolean> | undefined;\n}\n\nexport function useActionsWidth(options: UseActionsWidthOptions) {\n const { toolbarEl, paginationEl, checkboxEl, isPaginationEnabled, isSelectable, isEmpty } = options;\n\n const actionsWidth = ref<string | null>(null);\n let toolbarResizeObserver: ResizeObserver | null = null;\n let paginationResizeObserver: ResizeObserver | null = null;\n\n const updateActionsWidth = () => {\n const toolbarElVal = toElement(toolbarEl.value);\n if (!toolbarElVal) return;\n\n const toolbarWidth = toolbarElVal.getBoundingClientRect().width;\n let paginationWidth = 0;\n let checkboxWidth = 0;\n\n // Calculate pagination width if pagination is enabled\n if (isPaginationEnabled?.value) {\n const paginationElVal = toElement(paginationEl.value);\n if (paginationElVal) paginationWidth = paginationElVal.getBoundingClientRect().width;\n }\n\n // Calculate checkbox width if selectable and not empty\n if (isSelectable?.value && !isEmpty?.value) {\n const checkboxElVal = toComponentEl(checkboxEl.value);\n if (checkboxElVal) checkboxWidth = checkboxElVal.getBoundingClientRect().width;\n }\n\n // Get computed styles to calculate padding\n const computedStyle = window.getComputedStyle(toolbarElVal);\n const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;\n const paddingRight = parseFloat(computedStyle.paddingRight) || 0;\n\n const availableWidth = Math.max(0, toolbarWidth - paginationWidth - checkboxWidth - paddingLeft - paddingRight);\n actionsWidth.value = `${availableWidth}px`;\n };\n\n const setupResizeObserver = () => {\n const toolbarElVal = toElement(toolbarEl.value);\n if (!toolbarElVal) return;\n\n // Observe toolbar element\n toolbarResizeObserver = new ResizeObserver(() => {\n nextTick(() => {\n updateActionsWidth();\n });\n });\n toolbarResizeObserver.observe(toolbarElVal);\n\n // Observe pagination element if it exists\n const paginationElVal = toElement(paginationEl.value);\n if (paginationElVal) {\n paginationResizeObserver = new ResizeObserver(() => {\n nextTick(() => {\n updateActionsWidth();\n });\n });\n paginationResizeObserver.observe(paginationElVal);\n }\n };\n\n const cleanupResizeObserver = () => {\n if (toolbarResizeObserver) {\n toolbarResizeObserver.disconnect();\n toolbarResizeObserver = null;\n }\n if (paginationResizeObserver) {\n paginationResizeObserver.disconnect();\n paginationResizeObserver = null;\n }\n };\n\n onMounted(() => {\n nextTick(() => {\n updateActionsWidth();\n setupResizeObserver();\n });\n });\n\n onBeforeUnmount(() => {\n cleanupResizeObserver();\n });\n\n // Watch for changes in conditions that affect element visibility\n watch([isPaginationEnabled, isSelectable, isEmpty], () => {\n nextTick(() => {\n updateActionsWidth();\n });\n });\n\n // Watch for pagination element changes to setup/cleanup observer\n watch(paginationEl, (newPaginationEl) => {\n // Cleanup old observer if it exists\n if (paginationResizeObserver) {\n paginationResizeObserver.disconnect();\n paginationResizeObserver = null;\n }\n\n // Setup new observer if pagination element exists\n const el = toElement(newPaginationEl);\n if (el) {\n paginationResizeObserver = new ResizeObserver(() => {\n nextTick(() => {\n updateActionsWidth();\n });\n });\n paginationResizeObserver.observe(el);\n }\n });\n\n return {\n actionsWidth,\n updateActionsWidth,\n };\n}\n","<script setup lang=\"ts\">\n import { computed, inject, onBeforeMount, ref, useCssModule, useTemplateRef } from 'vue';\n\n import usePaginationStats from '../../composables/usePaginationStats/usePaginationStats';\n import { t } from '../../locale';\n import Button from '../Button/Button.vue';\n import Checkbox from '../Checkbox/Checkbox.vue';\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import Icon from '../Icon/Icon.vue';\n import IconLabel from '../IconLabel/IconLabel.vue';\n import MoreActions from '../MoreActions/MoreActions.vue';\n import { ToolbarRadiuses } from './DataViewToolbar.types';\n import { useActionsWidth } from './useActionsWidth';\n\n export interface DataViewToolbarProps {\n /**\n * When DataView has `variant=\"table\"` and Table has `is-selectable` enabled, it provides a way to flag\n * a checkbox whenever all rows are selected, just like the standalone version on TableHeaderRow.\n */\n allRowsSelected?: boolean;\n\n /**\n * Hides the page statistics (ex: \"1 - 12 of 20\") in the toolbar\n */\n hidePageStats?: boolean;\n\n /**\n * Controls the corners of DataViewToolbar with the \"border-radius\" CSS property. The default value is \"rounded\".\n */\n radius?: ToolbarRadiuses;\n\n /**\n * When DataView has variant=\"table\" and Table has `is-selectable` enabled, it provides a way to flag\n * a checkbox whenever one or more, but not all rows are selected, just like the standalone\n * version on TableHeaderRow.\n */\n someRowsSelected?: boolean;\n\n /**\n * The number of selected items. Used to display selected items count in the toolbar.\n */\n selectedItemsCount?: number;\n\n /**\n * When DataView has tabs above it, we need to remove the top left rounded corner\n */\n hasTabsAbove?: boolean;\n }\n\n const props = withDefaults(defineProps<DataViewToolbarProps>(), {\n allRowsSelected: false,\n hidePageStats: false,\n radius: undefined,\n someRowsSelected: false,\n selectedItemsCount: undefined,\n hasTabsAbove: false,\n });\n\n const emit = defineEmits<{\n (e: 'select'): void;\n }>();\n\n // Refs for width calculation\n const toolbarRef = useTemplateRef('toolbarEl');\n const paginationRef = useTemplateRef('paginationEl');\n const checkboxRef = useTemplateRef('checkboxEl');\n\n const {\n isWithinModule,\n variant: dataViewVariant,\n density,\n currentPage,\n hasToolbar,\n isPaginateNextDisabled,\n isPaginationEnabled,\n isSelectable,\n pageCount,\n pageSize,\n totalDataCount,\n goPrevPage,\n goNextPage,\n isEmpty,\n isLoading,\n } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n const checkboxKey = ref(0);\n const classes = useCssModule();\n\n const { actionsWidth } = useActionsWidth({\n toolbarEl: toolbarRef,\n paginationEl: paginationRef,\n checkboxEl: checkboxRef,\n isPaginationEnabled,\n isSelectable,\n isEmpty,\n });\n\n const computedRadius = computed<ToolbarRadiuses>(() => {\n if (props.radius) {\n return props.radius;\n }\n\n if (isWithinModule.value) {\n return 'none';\n }\n\n if (dataViewVariant.value === 'table') {\n if (props.hasTabsAbove) {\n return 'rounded-top-right';\n }\n\n return 'rounded-top';\n }\n\n return 'rounded';\n });\n\n const pageStats = usePaginationStats({ currentPage, pageSize, totalItems: totalDataCount });\n\n function onSelect() {\n emit('select');\n\n /**\n * In Vue (as of this writing), if a user checks a native checkbox but the v-model is `false` and does not change from `false`, then the checkbox will display as checked even though the v-model is still `false`.\n * Forcing a re-render with a `key` change allows the checkbox to stay unchecked if its v-model is still `false` and its v-model not been changed.\n * To verify that this is necessary, test the \"select all\" checkbox in the SelectionWithSomeDisabled story in Table.story.ts with and without the `key` attribute.\n */\n checkboxKey.value++;\n }\n\n onBeforeMount(() => {\n if (hasToolbar) {\n hasToolbar.value = true;\n }\n });\n</script>\n\n<template>\n <div\n ref=\"toolbarEl\"\n class=\"stash-data-view-toolbar flex min-h-15 items-center justify-between bg-white py-1.5 shadow\"\n :class=\"{\n 'border-t border-ice-200': isWithinModule,\n 'rounded-tr': computedRadius === 'rounded-top-right',\n rounded: computedRadius === 'rounded',\n 'rounded-t': computedRadius === 'rounded-top',\n 'mb-3': dataViewVariant !== 'table' && !isWithinModule,\n 'px-3': density === 'compact',\n 'px-3 lg:px-6': density === 'comfortable',\n }\"\n data-test=\"stash-data-view-toolbar\"\n >\n <div class=\"flex place-items-center\">\n <Checkbox\n v-if=\"isSelectable && !isEmpty\"\n ref=\"checkboxEl\"\n :key=\"checkboxKey\"\n :checked=\"props.allRowsSelected\"\n :indeterminate=\"props.someRowsSelected && !props.allRowsSelected\"\n :title=\"t('ll.selectAll')\"\n :disabled=\"isLoading\"\n @update:indeterminate=\"onSelect\"\n @update:checked=\"onSelect\"\n />\n <template v-if=\"$slots['more-actions']\">\n <MoreActions\n more-button-align=\"together\"\n :width=\"actionsWidth || undefined\"\n actions-container-class=\"flex items-center gap-x-2 lg:mr-6 lg:gap-x-6\"\n >\n <template #toggle=\"{ toggle }\">\n <Button\n icon-label\n class=\"text-blue-500\"\n data-test=\"stash-data-view-sort-button|sort-menu-button\"\n @click=\"toggle\"\n >\n <IconLabel icon=\"ellipsis\" stacked> More </IconLabel>\n </Button>\n </template>\n <slot></slot>\n <template #more-actions>\n <slot name=\"more-actions\"></slot>\n </template>\n </MoreActions>\n </template>\n <template v-else>\n <div :class=\"classes.actions\" class=\"stash-data-view-toolbar__actions flex items-center gap-x-2 lg:gap-x-4\">\n <slot></slot>\n </div>\n </template>\n </div>\n\n <!-- Pagination -->\n <div\n v-if=\"isPaginationEnabled\"\n ref=\"paginationEl\"\n class=\"stash-data-view-toolbar__pagination flex shrink-0 items-center\"\n >\n <slot name=\"selected-stats\">\n <span v-if=\"props.someRowsSelected && props.selectedItemsCount !== undefined\" class=\"mx-1.5\">\n {{ t('ll.listView.numberOfTotalSelected', { num: props.selectedItemsCount, total: totalDataCount }) }}\n </span>\n </slot>\n <slot name=\"page-stats\">\n <span v-if=\"!props.hidePageStats\" class=\"mx-1.5 hidden md:block\">\n {{ t('ll.pageStats', pageStats) }}\n </span>\n </slot>\n <template v-if=\"pageCount > 1\">\n <Button\n icon\n :aria-label=\"t('ll.previous')\"\n class=\"size-9 p-1.5\"\n data-test=\"button|prev-page\"\n :disabled=\"isLoading || currentPage === 1\"\n @click=\"goPrevPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-left\" size=\"dense\" />\n </Button>\n <Button\n icon\n :aria-label=\"t('ll.next')\"\n class=\"size-9 p-1.5\"\n data-test=\"button|next-page\"\n :disabled=\"isLoading || isPaginateNextDisabled || currentPage === pageCount\"\n @click=\"goNextPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-right\" size=\"dense\" />\n </Button>\n </template>\n </div>\n </div>\n</template>\n\n<style module>\n @layer utilities {\n .actions :global(.stash-button) {\n min-width: auto;\n padding: 0 0.5rem;\n\n &:first-child {\n margin-left: -0.5rem;\n }\n }\n }\n</style>\n"],"names":["useActionsWidth","options","toolbarEl","paginationEl","checkboxEl","isPaginationEnabled","isSelectable","isEmpty","actionsWidth","ref","toolbarResizeObserver","paginationResizeObserver","updateActionsWidth","toolbarElVal","toElement","toolbarWidth","paginationWidth","checkboxWidth","paginationElVal","checkboxElVal","toComponentEl","computedStyle","paddingLeft","paddingRight","availableWidth","setupResizeObserver","nextTick","cleanupResizeObserver","onMounted","onBeforeUnmount","watch","newPaginationEl","el","props","__props","emit","__emit","toolbarRef","useTemplateRef","paginationRef","checkboxRef","isWithinModule","dataViewVariant","density","currentPage","hasToolbar","isPaginateNextDisabled","pageCount","pageSize","totalDataCount","goPrevPage","goNextPage","isLoading","inject","DATA_VIEW_INJECTION","checkboxKey","classes","useCssModule","computedRadius","computed","pageStats","usePaginationStats","onSelect","onBeforeMount","_createElementBlock","_unref","_createElementVNode","_hoisted_1","_createBlock","Checkbox","t","$slots","MoreActions","_withCtx","toggle","_createVNode","Button","IconLabel","_cache","_renderSlot","_ctx","_normalizeClass","_openBlock","_hoisted_2","_hoisted_3","_toDisplayString","_hoisted_4","_Fragment","Icon"],"mappings":";;;;;;;;;;;;;AAaO,SAASA,GAAgBC,GAAiC;AAC/D,QAAM,EAAE,WAAAC,GAAW,cAAAC,GAAc,YAAAC,GAAY,qBAAAC,GAAqB,cAAAC,GAAc,SAAAC,MAAYN,GAEtFO,IAAeC,EAAmB,IAAI;AAC5C,MAAIC,IAA+C,MAC/CC,IAAkD;AAEtD,QAAMC,IAAqB,MAAM;AAC/B,UAAMC,IAAeC,EAAUZ,EAAU,KAAK;AAC9C,QAAI,CAACW,EAAc;AAEnB,UAAME,IAAeF,EAAa,sBAAA,EAAwB;AAC1D,QAAIG,IAAkB,GAClBC,IAAgB;AAGpB,QAAIZ,KAAA,QAAAA,EAAqB,OAAO;AAC9B,YAAMa,IAAkBJ,EAAUX,EAAa,KAAK;AACpD,MAAIe,MAAiBF,IAAkBE,EAAgB,sBAAA,EAAwB;AAAA,IACjF;AAGA,QAAIZ,KAAA,QAAAA,EAAc,SAAS,EAACC,KAAA,QAAAA,EAAS,QAAO;AAC1C,YAAMY,IAAgBC,GA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