@leaflink/stash 53.4.0 → 53.4.2
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/Accordion.js +1 -1
- package/dist/Accordion.js.map +1 -1
- package/dist/ActionsDropdown.js +2 -2
- package/dist/ActionsDropdown.js.map +1 -1
- package/dist/AddressSelect.js.map +1 -1
- package/dist/AddressSelect.vue.d.ts +1 -1
- package/dist/Alert.js.map +1 -1
- package/dist/AppNavigationItem.js +1 -1
- package/dist/AppNavigationItem.js.map +1 -1
- package/dist/AppSidebar.js.map +1 -1
- package/dist/AppTopbar.js +1 -1
- package/dist/AppTopbar.js.map +1 -1
- package/dist/Avatar.js.map +1 -1
- package/dist/Badge.js.map +1 -1
- package/dist/Box.vue_vue_type_script_setup_true_lang-dFFZN40_.js.map +1 -1
- package/dist/Button.js.map +1 -1
- package/dist/ButtonGroup.js.map +1 -1
- package/dist/Card.js.map +1 -1
- package/dist/CardHeader.js.map +1 -1
- package/dist/CardMedia.js.map +1 -1
- package/dist/Carousel.js +169 -169
- package/dist/Carousel.js.map +1 -1
- package/dist/Checkbox.js +31 -31
- package/dist/Checkbox.js.map +1 -1
- package/dist/ChevronToggle.vue_vue_type_script_setup_true_lang-Ce_qOXfR.js.map +1 -1
- package/dist/Chip.js +21 -21
- package/dist/Chip.js.map +1 -1
- package/dist/Chip.vue.d.ts +1 -1
- package/dist/ConfirmationCodeInput.js +1 -1
- package/dist/ConfirmationCodeInput.js.map +1 -1
- package/dist/ContextSwitcher.js +28 -28
- package/dist/ContextSwitcher.js.map +1 -1
- package/dist/Copy.js +1 -1
- package/dist/Copy.js.map +1 -1
- package/dist/CurrencyInput.js +1 -1
- package/dist/CurrencyInput.js.map +1 -1
- package/dist/DataView.js +51 -51
- package/dist/DataView.js.map +1 -1
- package/dist/DataViewFilters.js.map +1 -1
- package/dist/DataViewSortButton.js +2 -2
- package/dist/DataViewSortButton.js.map +1 -1
- package/dist/DataViewToolbar.js +5 -5
- package/dist/DataViewToolbar.js.map +1 -1
- package/dist/DatePicker.js +237 -237
- package/dist/DatePicker.js.map +1 -1
- package/dist/DatePicker.vue.d.ts +1 -1
- package/dist/DescriptionList.js.map +1 -1
- package/dist/DescriptionListDetail.js.map +1 -1
- package/dist/DescriptionListGroup.js.map +1 -1
- package/dist/DescriptionListTerm.js.map +1 -1
- package/dist/Dialog.js.map +1 -1
- package/dist/Divider.js.map +1 -1
- package/dist/Dropdown.js +45 -45
- package/dist/Dropdown.js.map +1 -1
- package/dist/EmptyState.js.map +1 -1
- package/dist/Expand.js +1 -1
- package/dist/Expand.vue_vue_type_script_setup_true_lang-BmNJA0Xy.js +74 -0
- package/dist/{Expand.vue_vue_type_script_setup_true_lang-CiONJfAp.js.map → Expand.vue_vue_type_script_setup_true_lang-BmNJA0Xy.js.map} +1 -1
- package/dist/Field.js +1 -1
- package/dist/{Field.vue_vue_type_script_setup_true_lang-dAGKfjf5.js → Field.vue_vue_type_script_setup_true_lang-D2I8xDEW.js} +29 -29
- package/dist/{Field.vue_vue_type_script_setup_true_lang-dAGKfjf5.js.map → Field.vue_vue_type_script_setup_true_lang-D2I8xDEW.js.map} +1 -1
- package/dist/FileUpload.js +54 -54
- package/dist/FileUpload.js.map +1 -1
- package/dist/FilterChip.js.map +1 -1
- package/dist/FilterChip.vue.d.ts +1 -1
- package/dist/FilterDrawerItem.js.map +1 -1
- package/dist/FilterDropdown.js.map +1 -1
- package/dist/FilterSelect.js +1 -1
- package/dist/FilterSelect.js.map +1 -1
- package/dist/Filters.js +4 -6
- package/dist/Filters.js.map +1 -1
- package/dist/Filters.vue.d.ts +57 -57
- package/dist/HttpError.js +6 -6
- package/dist/HttpError.js.map +1 -1
- package/dist/Icon.js.map +1 -1
- package/dist/IconLabel.js +13 -13
- package/dist/IconLabel.js.map +1 -1
- package/dist/Illustration.vue_vue_type_script_setup_true_lang-C1bPkWZZ.js.map +1 -1
- package/dist/Image.vue_vue_type_script_setup_true_lang-CAj0FH9h.js.map +1 -1
- package/dist/InlineEdit.js.map +1 -1
- package/dist/InlineEdit.vue.d.ts +1 -1
- package/dist/Input.js +35 -35
- package/dist/Input.js.map +1 -1
- package/dist/InputOptions.js +35 -35
- package/dist/InputOptions.js.map +1 -1
- package/dist/InputOptions.vue.d.ts +1 -1
- package/dist/IntegrationIcon.js.map +1 -1
- package/dist/Label.vue_vue_type_script_setup_true_lang-xwY3X-iV.js.map +1 -1
- package/dist/LicenseChip.js +9 -9
- package/dist/LicenseChip.js.map +1 -1
- package/dist/ListItem.js.map +1 -1
- package/dist/ListItemCell.js.map +1 -1
- package/dist/ListView.js +1 -1
- package/dist/ListView.js.map +1 -1
- package/dist/ListView.vue.d.ts +69 -69
- package/dist/Loading.js +2 -2
- package/dist/Loading.js.map +1 -1
- package/dist/Logo.js +1 -1
- package/dist/{Logo.vue_vue_type_script_setup_true_lang-DghNC_k6.js → Logo.vue_vue_type_script_setup_true_lang-qiNaaWWV.js} +17 -17
- package/dist/Logo.vue_vue_type_script_setup_true_lang-qiNaaWWV.js.map +1 -0
- package/dist/MenuItem.js.map +1 -1
- package/dist/Metric.js +12 -12
- package/dist/Metric.js.map +1 -1
- package/dist/Modal.js.map +1 -1
- package/dist/Modals.js.map +1 -1
- package/dist/Module.js.map +1 -1
- package/dist/ModuleContent.js.map +1 -1
- package/dist/ModuleFooter.js.map +1 -1
- package/dist/ModuleHeader.js.map +1 -1
- package/dist/MoreActions.js +2 -2
- package/dist/MoreActions.js.map +1 -1
- package/dist/ObfuscateText.js.map +1 -1
- package/dist/PageContent.js.map +1 -1
- package/dist/PageHeader.js.map +1 -1
- package/dist/PageNavigation.js +1 -1
- package/dist/PageNavigation.js.map +1 -1
- package/dist/Paginate.js.map +1 -1
- package/dist/PlaidLink.js.map +1 -1
- package/dist/QuickAction.js.map +1 -1
- package/dist/Radio.js.map +1 -1
- package/dist/RadioGroup.js +1 -1
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioNew.js.map +1 -1
- package/dist/RangeInput.js.map +1 -1
- package/dist/SearchBar.js.map +1 -1
- package/dist/SearchBar.vue.d.ts +1 -1
- package/dist/SectionHeader.js.map +1 -1
- package/dist/Select.js +2 -2
- package/dist/Select.js.map +1 -1
- package/dist/Select.vue.d.ts +1 -1
- package/dist/SelectStatus.js.map +1 -1
- package/dist/SelectStatus.vue.d.ts +1 -1
- package/dist/Skeleton.js.map +1 -1
- package/dist/Step.js +8 -8
- package/dist/Step.js.map +1 -1
- package/dist/Stepper.js.map +1 -1
- package/dist/Switch.js +15 -15
- package/dist/Switch.js.map +1 -1
- package/dist/Tab.js +1 -1
- package/dist/Tab.js.map +1 -1
- package/dist/TabPanel.js.map +1 -1
- package/dist/Table.js.map +1 -1
- package/dist/TableCell.js.map +1 -1
- package/dist/TableHeaderCell.js.map +1 -1
- package/dist/TableHeaderRow.js.map +1 -1
- package/dist/TableRow.js +18 -18
- package/dist/TableRow.js.map +1 -1
- package/dist/Tabs.js +2 -2
- package/dist/{Tabs.vue_vue_type_script_setup_true_lang-BFURXY_-.js → Tabs.vue_vue_type_script_setup_true_lang-B3FBaVP5.js} +48 -48
- package/dist/{Tabs.vue_vue_type_script_setup_true_lang-BFURXY_-.js.map → Tabs.vue_vue_type_script_setup_true_lang-B3FBaVP5.js.map} +1 -1
- package/dist/TextEditor.js +1 -1
- package/dist/TextEditor.js.map +1 -1
- package/dist/TextEditor.vue.d.ts +1 -1
- package/dist/Textarea.js +1 -1
- package/dist/Textarea.js.map +1 -1
- package/dist/Thumbnail.js +33 -33
- package/dist/Thumbnail.js.map +1 -1
- package/dist/Thumbnail.vue.d.ts +3 -3
- package/dist/ThumbnailEmpty.js.map +1 -1
- package/dist/ThumbnailGroup.js.map +1 -1
- package/dist/Timeline.js.map +1 -1
- package/dist/TimelineItem.js.map +1 -1
- package/dist/Toast.js +27 -27
- package/dist/Toast.js.map +1 -1
- package/dist/Toasts.js.map +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/{Tooltip.vue_vue_type_script_setup_true_lang-CF6sw2VC.js → Tooltip.vue_vue_type_script_setup_true_lang-WMPMxzO-.js} +13 -16
- package/dist/Tooltip.vue_vue_type_script_setup_true_lang-WMPMxzO-.js.map +1 -0
- package/dist/components.css +1 -1
- package/dist/directives/tooltip.js.map +1 -1
- package/dist/floating-ui.vue-CuGrC-z8.js.map +1 -1
- package/dist/index-B1Gkwuxd.js.map +1 -1
- package/dist/index-D6bxWkZ1.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/Expand.vue_vue_type_script_setup_true_lang-CiONJfAp.js +0 -74
- package/dist/Logo.vue_vue_type_script_setup_true_lang-DghNC_k6.js.map +0 -1
- package/dist/Tooltip.vue_vue_type_script_setup_true_lang-CF6sw2VC.js.map +0 -1
package/dist/DataView.js
CHANGED
|
@@ -4,36 +4,36 @@ import { M as V } from "./Module.keys-DcqBbvvT.js";
|
|
|
4
4
|
import O from "./Paginate.js";
|
|
5
5
|
import { a as w, D as tt } from "./DataView.keys-aSOnA4AD.js";
|
|
6
6
|
import { _ as et } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
7
|
-
function
|
|
8
|
-
const o =
|
|
9
|
-
return { id: o === "asc" ?
|
|
7
|
+
function x(e) {
|
|
8
|
+
const o = e[0] === "-" ? "desc" : "asc";
|
|
9
|
+
return { id: o === "asc" ? e : e.slice(1), order: o };
|
|
10
10
|
}
|
|
11
|
-
function at({ id:
|
|
12
|
-
return `${o === "desc" ? "-" : ""}${
|
|
11
|
+
function at({ id: e, order: o }) {
|
|
12
|
+
return `${o === "desc" ? "-" : ""}${e}`;
|
|
13
13
|
}
|
|
14
|
-
function nt({ newId:
|
|
15
|
-
if (
|
|
16
|
-
if (
|
|
17
|
-
return at({ id:
|
|
14
|
+
function nt({ newId: e, newOrder: o, oldId: f, oldOrder: t }) {
|
|
15
|
+
if (e) {
|
|
16
|
+
if (e !== f)
|
|
17
|
+
return at({ id: e, order: o || "asc" });
|
|
18
18
|
if (!o && !t)
|
|
19
|
-
return
|
|
19
|
+
return e;
|
|
20
20
|
if (!(!o && t === "desc")) {
|
|
21
21
|
if (!o && t === "asc")
|
|
22
|
-
return `-${
|
|
22
|
+
return `-${e}`;
|
|
23
23
|
if (o === "asc" && !t)
|
|
24
|
-
return
|
|
24
|
+
return e;
|
|
25
25
|
if (!(o === "asc" && t === "asc")) {
|
|
26
26
|
if (o === "asc" && t === "desc")
|
|
27
|
-
return
|
|
27
|
+
return e;
|
|
28
28
|
if (o === "desc" && !t)
|
|
29
|
-
return `-${
|
|
29
|
+
return `-${e}`;
|
|
30
30
|
if (!(o === "desc" && t === "desc") && o === "desc" && t === "asc")
|
|
31
|
-
return `-${
|
|
31
|
+
return `-${e}`;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
var ot = /* @__PURE__ */ ((
|
|
36
|
+
var ot = /* @__PURE__ */ ((e) => (e.Table = "table", e))(ot || {});
|
|
37
37
|
const it = /* @__PURE__ */ U({
|
|
38
38
|
__name: "DataView",
|
|
39
39
|
props: {
|
|
@@ -51,25 +51,25 @@ const it = /* @__PURE__ */ U({
|
|
|
51
51
|
isLoading: { type: Boolean }
|
|
52
52
|
},
|
|
53
53
|
emits: ["update", "update:currentFilters", "update:currentPage", "update:currentSearch", "update:currentSort"],
|
|
54
|
-
setup(
|
|
55
|
-
const t =
|
|
56
|
-
var
|
|
54
|
+
setup(e, { expose: o, emit: f }) {
|
|
55
|
+
const t = e, d = f, $ = J(), P = l(null), C = W(V.key, V.defaults), L = n(() => {
|
|
56
|
+
var a;
|
|
57
57
|
if (t.variant)
|
|
58
58
|
return t.variant;
|
|
59
|
-
if (((
|
|
59
|
+
if (((a = C.variant) == null ? void 0 : a.value) === "table")
|
|
60
60
|
return "table";
|
|
61
|
-
}),
|
|
62
|
-
var
|
|
63
|
-
return (
|
|
64
|
-
}), u = l(1), B = n(() => !t.disablePagination && t.totalDataCount > 0), E = n(() => t.totalDataCount === 1 / 0 && !t.hasNextPage), v = n(() => Math.ceil(t.totalDataCount / t.pageSize)), r = function(
|
|
61
|
+
}), _ = n(() => C.variant !== void 0), T = n(() => {
|
|
62
|
+
var a;
|
|
63
|
+
return (a = C.includeDataviewPagination) == null ? void 0 : a.value;
|
|
64
|
+
}), u = l(1), B = n(() => !t.disablePagination && t.totalDataCount > 0), E = n(() => t.totalDataCount === 1 / 0 && !t.hasNextPage), v = n(() => Math.ceil(t.totalDataCount / t.pageSize)), r = function(a, { shouldEmit: i } = {}) {
|
|
65
65
|
var c, h;
|
|
66
|
-
u.value =
|
|
67
|
-
}, D = function({ shouldEmit:
|
|
66
|
+
u.value = a, i && (S(), d("update:currentPage", a, t.pageSize)), Number((c = P.value) == null ? void 0 : c.getBoundingClientRect().top) < 0 && ((h = P.value) == null || h.scrollIntoView({ behavior: "smooth", block: "start" }));
|
|
67
|
+
}, D = function({ shouldEmit: a } = {}) {
|
|
68
68
|
const i = Math.max(u.value - 1, 1);
|
|
69
|
-
r(i, { shouldEmit:
|
|
70
|
-
}, b = function({ shouldEmit:
|
|
69
|
+
r(i, { shouldEmit: a });
|
|
70
|
+
}, b = function({ shouldEmit: a } = {}) {
|
|
71
71
|
const i = Math.min(u.value + 1, v.value);
|
|
72
|
-
r(i, { shouldEmit:
|
|
72
|
+
r(i, { shouldEmit: a });
|
|
73
73
|
};
|
|
74
74
|
y(
|
|
75
75
|
() => t.currentPage,
|
|
@@ -79,22 +79,22 @@ const it = /* @__PURE__ */ U({
|
|
|
79
79
|
{ immediate: !0 }
|
|
80
80
|
);
|
|
81
81
|
const s = l(void 0), N = n(
|
|
82
|
-
() => s.value ?
|
|
82
|
+
() => s.value ? x(s.value).id : void 0
|
|
83
83
|
), M = n(
|
|
84
|
-
() => s.value ?
|
|
85
|
-
),
|
|
86
|
-
const { id: h, order: R } =
|
|
84
|
+
() => s.value ? x(s.value).order : void 0
|
|
85
|
+
), g = function(a, { sortOrder: i, shouldEmit: c } = {}) {
|
|
86
|
+
const { id: h, order: R } = x(s.value || ""), k = nt({ newId: a, newOrder: i, oldId: h, oldOrder: R });
|
|
87
87
|
s.value = k, r(1), c && (S(), d("update:currentSort", k));
|
|
88
88
|
};
|
|
89
89
|
y(
|
|
90
90
|
() => t.currentSort,
|
|
91
91
|
() => {
|
|
92
|
-
|
|
92
|
+
g(t.currentSort);
|
|
93
93
|
},
|
|
94
94
|
{ immediate: !0 }
|
|
95
95
|
);
|
|
96
|
-
const
|
|
97
|
-
|
|
96
|
+
const p = l(""), j = l(!1), A = l(!1), m = function(a, { shouldEmit: i } = {}) {
|
|
97
|
+
p.value = a || "", r(1), i && (S(), d("update:currentSearch", a));
|
|
98
98
|
};
|
|
99
99
|
y(
|
|
100
100
|
() => t.currentSearch,
|
|
@@ -103,15 +103,15 @@ const it = /* @__PURE__ */ U({
|
|
|
103
103
|
},
|
|
104
104
|
{ immediate: !0 }
|
|
105
105
|
);
|
|
106
|
-
const z = l({}), F = function(
|
|
107
|
-
z.value =
|
|
106
|
+
const z = l({}), F = function(a, { shouldEmit: i } = {}) {
|
|
107
|
+
z.value = a, r(1), i && (S(), d("update:currentFilters", a));
|
|
108
108
|
};
|
|
109
109
|
function S() {
|
|
110
110
|
d("update", {
|
|
111
111
|
page: u.value,
|
|
112
112
|
pageSize: t.pageSize,
|
|
113
113
|
ordering: s.value,
|
|
114
|
-
search:
|
|
114
|
+
search: p.value,
|
|
115
115
|
filters: Y(z.value)
|
|
116
116
|
});
|
|
117
117
|
}
|
|
@@ -131,9 +131,9 @@ const it = /* @__PURE__ */ U({
|
|
|
131
131
|
// Sorting
|
|
132
132
|
currentSortId: N,
|
|
133
133
|
currentSortOrder: M,
|
|
134
|
-
updateCurrentSort:
|
|
134
|
+
updateCurrentSort: g,
|
|
135
135
|
// Search
|
|
136
|
-
currentSearch: n(() =>
|
|
136
|
+
currentSearch: n(() => p.value),
|
|
137
137
|
updateCurrentSearch: m,
|
|
138
138
|
// Miscellaneous
|
|
139
139
|
density: n(() => t.density),
|
|
@@ -141,7 +141,7 @@ const it = /* @__PURE__ */ U({
|
|
|
141
141
|
isEmpty: n(() => t.data.length === 0),
|
|
142
142
|
isSelectable: A,
|
|
143
143
|
isLoading: n(() => t.isLoading),
|
|
144
|
-
isWithinModule:
|
|
144
|
+
isWithinModule: _,
|
|
145
145
|
variant: L
|
|
146
146
|
})
|
|
147
147
|
), o({
|
|
@@ -151,18 +151,18 @@ const it = /* @__PURE__ */ U({
|
|
|
151
151
|
goPrevPage: D,
|
|
152
152
|
goNextPage: b,
|
|
153
153
|
ordering: n(() => s.value),
|
|
154
|
-
updateCurrentSort:
|
|
155
|
-
search: n(() =>
|
|
154
|
+
updateCurrentSort: g,
|
|
155
|
+
search: n(() => p.value),
|
|
156
156
|
updateCurrentSearch: m,
|
|
157
157
|
filters: n(() => z.value),
|
|
158
158
|
updateCurrentFilters: F
|
|
159
|
-
}), (
|
|
159
|
+
}), (a, i) => (I(), Z("div", {
|
|
160
160
|
ref_key: "rootRef",
|
|
161
161
|
ref: P,
|
|
162
162
|
class: "stash-data-view relative",
|
|
163
163
|
"data-test": "stash-data-view"
|
|
164
164
|
}, [
|
|
165
|
-
q(
|
|
165
|
+
q(a.$slots, "default", {
|
|
166
166
|
currentPage: u.value,
|
|
167
167
|
currentSortId: N.value,
|
|
168
168
|
currentSortOrder: M.value,
|
|
@@ -172,10 +172,10 @@ const it = /* @__PURE__ */ U({
|
|
|
172
172
|
pageCount: v.value,
|
|
173
173
|
setPage: r,
|
|
174
174
|
totalDataCount: t.totalDataCount,
|
|
175
|
-
updateCurrentSort:
|
|
175
|
+
updateCurrentSort: g,
|
|
176
176
|
updateCurrentSearch: m
|
|
177
177
|
}),
|
|
178
|
-
B.value && (!
|
|
178
|
+
B.value && (!_.value || T.value) && v.value > 1 && !t.hideBottomPagination ? (I(), H(O, {
|
|
179
179
|
key: 0,
|
|
180
180
|
class: Q(["mt-6", X($).paginate]),
|
|
181
181
|
"current-page": u.value,
|
|
@@ -191,13 +191,13 @@ const it = /* @__PURE__ */ U({
|
|
|
191
191
|
paginate: rt
|
|
192
192
|
}, st = {
|
|
193
193
|
$style: ut
|
|
194
|
-
},
|
|
194
|
+
}, pt = /* @__PURE__ */ et(it, [["__cssModules", st]]);
|
|
195
195
|
export {
|
|
196
196
|
tt as DATA_VIEW_INJECTION,
|
|
197
197
|
w as DEFAULT_PAGE_SIZE,
|
|
198
198
|
ot as DataViewVariant,
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
pt as default,
|
|
200
|
+
x as deserializeSortValue,
|
|
201
201
|
nt as getNextSort,
|
|
202
202
|
at as serializeSortValue
|
|
203
203
|
};
|
package/dist/DataView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataView.js","sources":["../src/components/DataView/DataView.utils.ts","../src/components/DataView/DataView.types.ts","../src/components/DataView/DataView.vue"],"sourcesContent":["import { SortId, SortOrder, SortValue, SortValueDeserialized } from './DataView.types';\n\n/**\n * Receives a SortValue (ex: `'-product_name'`) and returns an object with a `id` and an `order`.\n */\nexport function deserializeSortValue(sort: SortValue): SortValueDeserialized {\n const order = sort[0] === '-' ? 'desc' : 'asc';\n const id = order === 'asc' ? sort : sort.slice(1);\n\n return { id, order };\n}\n\n/**\n * Receives an object with a `id` and an `order` and returns a SortValue (ex: `'-product_name'`).\n */\nexport function serializeSortValue({ id, order }: SortValueDeserialized): SortValue {\n return `${order === 'desc' ? '-' : ''}${id}`;\n}\n\ninterface GetNextSortArgs {\n newId: SortId | undefined;\n newOrder?: SortOrder;\n oldId?: SortId;\n oldOrder?: SortOrder;\n}\n\n/**\n * Given new and old sorting data, it returns the next sorting value using the following sorting cycle:\n *\n * \"unsorted --> ascending --> descending --> unsorted\"\n */\nexport function getNextSort({ newId, newOrder, oldId, oldOrder }: GetNextSortArgs): SortValue | undefined {\n if (!newId) {\n return undefined;\n }\n\n if (newId !== oldId) {\n // if sorting by a new field, sort ascending\n return serializeSortValue({ id: newId, order: newOrder || 'asc' });\n }\n\n /**\n * `newOrder` and `oldOrder` can each have 3 different values: undefined, 'asc', or 'desc'.\n * Therefore, there are 9 possible combinations (3 times 3). See below:\n */\n\n // #region newOrder: undefined\n if (!newOrder && !oldOrder) {\n return newId; // ascending\n }\n\n if (!newOrder && oldOrder === 'desc') {\n return undefined; // unsorted\n }\n\n if (!newOrder && oldOrder === 'asc') {\n return `-${newId}`; // descending\n }\n // #endregion\n\n // #region newOrder: asc\n if (newOrder === 'asc' && !oldOrder) {\n return newId;\n }\n\n if (newOrder === 'asc' && oldOrder === 'asc') {\n return undefined;\n }\n\n if (newOrder === 'asc' && oldOrder === 'desc') {\n return newId;\n }\n // #endregion\n\n // #region newOrder: desc\n if (newOrder === 'desc' && !oldOrder) {\n return `-${newId}`;\n }\n\n if (newOrder === 'desc' && oldOrder === 'desc') {\n return undefined;\n }\n\n if (newOrder === 'desc' && oldOrder === 'asc') {\n return `-${newId}`;\n }\n // #endregion\n}\n","import { ComputedRef, Ref } from 'vue';\n\nimport { SpacingDensities } from '../../../types/misc';\n\nexport enum DataViewVariant {\n Table = 'table',\n}\n\nexport type DataViewVariants = `${DataViewVariant}`;\n\n/**\n * A unique id for a sorting strategy. If the order is descending, it must begin with \"-\" (a hyphen/dash).\n *\n * Ex: `'product_name'` if ascending or `'-product_name'` if descending\n */\nexport type SortValue = string;\n\n/**\n * The SortValue with its leading hyphen/dash removed\n */\nexport type SortId = string;\n\n/**\n * Determined by whether or not there is a leading hyphen/dash in the SortValue\n */\nexport type SortOrder = 'asc' | 'desc';\n\n/**\n * A deserialized instance of a `SortValue`.\n */\nexport type SortValueDeserialized = {\n id: SortId;\n order: SortOrder;\n};\n\n/** Updates the DataView internal state with the given sortId */\nexport type UpdateCurrentSort = (\n sortId: SortId | undefined,\n options?: {\n sortOrder?: SortOrder;\n /** If true, emits the `update:currentSort` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the given page */\nexport type SetPage = (\n page: number,\n options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the previous page */\nexport type GoPrevPage = (options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n}) => void;\n\n/** Updates the DataView internal state with the next page */\nexport type GoNextPage = (options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n}) => void;\n\n/** Updates the DataView internal state with the given searchTerm */\nexport type UpdateCurrentSearch = (\n searchTerm?: string,\n options?: {\n /** If true, emits the `update:currentSearch` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the given filter values */\nexport type UpdateCurrentFilters<FilterValues = object> = (\n newFilters: FilterValues,\n options?: {\n /** If true, emits the `update:currentSearch` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\nexport interface UpdateEvent<FilterValues = object> {\n page?: number;\n pageSize?: number;\n ordering?: string;\n search?: string;\n filters?: FilterValues;\n}\n\nexport interface DataViewInjection {\n currentPage: ComputedRef<number>;\n\n /** Optional override for the next button disabled state */\n isPaginateNextDisabled: ComputedRef<boolean>;\n\n isPaginationEnabled: ComputedRef<boolean>;\n\n pageCount: ComputedRef<number>;\n\n pageSize: ComputedRef<number>;\n\n totalDataCount: ComputedRef<number>;\n\n /** Updates the DataView internal state with the given page */\n setPage: SetPage;\n\n /** Updates the DataView internal state with the previous page */\n goPrevPage: GoPrevPage;\n\n /** Updates the DataView internal state with the next page */\n goNextPage: GoNextPage;\n\n currentSortId: ComputedRef<SortId | undefined>;\n\n currentSortOrder: ComputedRef<SortOrder | undefined>;\n\n /** Updates the DataView internal state with the given sortId */\n updateCurrentSort: UpdateCurrentSort;\n\n currentSearch: ComputedRef<string>;\n\n /** Updates the DataView internal state with the given searchTerm */\n updateCurrentSearch: UpdateCurrentSearch;\n\n /**\n * The DataView's padding; the default value is \"comfortable\". On small screens, the density will always be \"compact\".\n */\n density: ComputedRef<SpacingDensities | undefined>;\n\n /**\n * Defines if a DataView has a Toolbar rendered. This prop is updated when DataViewToolbar exists and is mounted.\n */\n hasToolbar?: Ref<boolean>;\n\n /**\n * Enables certain loading indicators to be displayed within the DataView.\n */\n isLoading?: ComputedRef<boolean>;\n\n /**\n * Enables certain empty states to be displayed within the DataView.\n */\n isEmpty?: ComputedRef<boolean>;\n\n /**\n * Allows Table to control whether or not a DataViewToolbar should show a checkmark\n */\n isSelectable?: Ref<boolean>;\n\n /**\n * Whether or not the DataView is rendered within a Module; the value is inferred based on being\n * able to inject details from Module.\n *\n * Note: This is sent to DataView child components so they only need to worry about interfacing\n * with the DataViewInjection API.\n */\n isWithinModule: ComputedRef<boolean>;\n\n /**\n * The DataView's variant; the default value is undefined.\n */\n variant: ComputedRef<DataViewVariants | undefined>;\n}\n","<script lang=\"ts\">\n export * from './DataView.constants';\n export * from './DataView.keys';\n export * from './DataView.types';\n export * from './DataView.utils';\n</script>\n\n<script setup lang=\"ts\">\n import cloneDeep from 'lodash-es/cloneDeep';\n import { computed, inject, provide, ref, useCssModule, watch } from 'vue';\n\n import { SpacingDensities } from '../../../types/misc';\n import { MODULE_INJECTION } from '../Module/Module.keys';\n import Paginate from '../Paginate/Paginate.vue';\n import { DEFAULT_PAGE_SIZE } from './DataView.constants';\n import { DATA_VIEW_INJECTION } from './DataView.keys';\n import {\n DataViewVariants,\n GoNextPage,\n GoPrevPage,\n SetPage,\n SortId,\n SortOrder,\n SortValue,\n UpdateCurrentFilters,\n UpdateCurrentSearch,\n UpdateCurrentSort,\n UpdateEvent,\n } from './DataView.types';\n import { deserializeSortValue, getNextSort } from './DataView.utils';\n\n export interface DataViewProps {\n /**\n * Can be used to provide the initial page.\n * Also, it can be used to control the active page with `v-model:current-page=\"myPage\"`.\n */\n currentPage?: number;\n\n /**\n * Can be used to set the initial search term.\n * Also, it can be used to control the active search term with `v-model:current-search=\"mySearchTerm\"`.\n */\n currentSearch?: string;\n\n /**\n * Can be used to provide the initial sort order.\n * Also, it can be used to control the active sort order with `v-model:current-sort=\"mySortOrder\"`.\n */\n currentSort?: SortValue;\n\n /**\n * A list of records. If pagination is enabled, `data` must be only the current page of records.\n */\n data?: object[];\n\n /**\n * Controls the DataView's padding; the default value is \"comfortable\". On small screens, \"compact\" density is applied regardless of this prop's value.\n */\n density?: SpacingDensities;\n\n /**\n * The number of records to display per page.\n */\n pageSize?: number;\n\n /**\n * Opt-out of displaying pagination. Hides the pagination buttons and page stats.\n */\n disablePagination?: boolean;\n\n /**\n * Hides the bottom pagination without disabling the pagination from the toolbar\n */\n hideBottomPagination?: boolean;\n\n /**\n * The total number of records available.\n * Used to auto-enable pagination when results exist.\n * Use `Infinity` for activating 'n of many' pagination\n * DataView does not paginate data for you; instead, `props.data` should always show\n * the current page of results.\n */\n totalDataCount?: number;\n\n /**\n * Whether there is a next page of data or not as informed by the server.\n * This only applies when`totalDataCount=\"Infinity\"` to determine if the \"Next\" pagination button should be disabled.\n */\n hasNextPage?: boolean;\n\n /**\n * DataView variant. The default value is `undefined`. Will default to `table` when used within\n * a `<Module variant=\"table\">`.\n */\n variant?: DataViewVariants;\n\n isLoading?: boolean;\n }\n\n const props = withDefaults(defineProps<DataViewProps>(), {\n currentPage: 1,\n currentSearch: undefined,\n currentSort: undefined,\n data: () => [],\n density: 'comfortable',\n pageSize: DEFAULT_PAGE_SIZE,\n disablePagination: false,\n totalDataCount: 0,\n hasNextPage: undefined,\n hideBottomPagination: false,\n variant: undefined,\n });\n\n const emit = defineEmits<{\n (e: 'update', state: UpdateEvent): void;\n (e: 'update:currentFilters', newFilters: object): void;\n (e: 'update:currentPage', page: number, pageSize: number): void;\n (e: 'update:currentSearch', searchTerm?: string): void;\n (e: 'update:currentSort', payload?: SortValue): void;\n }>();\n\n const classes = useCssModule();\n const rootRef = ref<HTMLElement | null>(null);\n const moduleInjection = inject(MODULE_INJECTION.key, MODULE_INJECTION.defaults);\n const computedVariant = computed<DataViewVariants | undefined>(() => {\n if (props.variant) {\n return props.variant;\n }\n\n if (moduleInjection.variant?.value === 'table') {\n return 'table';\n }\n\n return undefined;\n });\n const isWithinModule = computed(() => moduleInjection.variant !== undefined);\n\n const includeBottomPaginationInModule = computed(() => moduleInjection.includeDataviewPagination?.value);\n\n // #region pagination\n const internalPage = ref(1);\n const isPaginationEnabled = computed(() => !props.disablePagination && props.totalDataCount > 0);\n const isPaginateNextDisabled = computed(() => props.totalDataCount === Infinity && !props.hasNextPage);\n const pageCount = computed(() => Math.ceil(props.totalDataCount / props.pageSize));\n\n const setPage: SetPage = function (page: number, { shouldEmit } = {}) {\n internalPage.value = page;\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentPage', page, props.pageSize);\n }\n\n if (Number(rootRef.value?.getBoundingClientRect().top) < 0) {\n rootRef.value?.scrollIntoView({ behavior: 'smooth', block: 'start' });\n }\n };\n\n const goPrevPage: GoPrevPage = function ({ shouldEmit } = {}) {\n const page = Math.max(internalPage.value - 1, 1);\n\n setPage(page, { shouldEmit });\n };\n\n /** Updates the DataView internal state with the previous page */\n const goNextPage: GoNextPage = function ({ shouldEmit } = {}) {\n const page = Math.min(internalPage.value + 1, pageCount.value);\n\n setPage(page, { shouldEmit });\n };\n\n watch(\n () => props.currentPage,\n () => {\n setPage(props.currentPage);\n },\n { immediate: true },\n );\n // #endregion pagination\n\n // #region sorting\n const internalSort = ref<SortValue | undefined>(undefined);\n\n const internalSortId = computed<SortId | undefined>(() =>\n internalSort.value ? deserializeSortValue(internalSort.value).id : undefined,\n );\n const internalSortOrder = computed<SortOrder | undefined>(() =>\n internalSort.value ? deserializeSortValue(internalSort.value).order : undefined,\n );\n\n const updateCurrentSort: UpdateCurrentSort = function (sortId, { sortOrder, shouldEmit } = {}) {\n const { id: oldId, order: oldOrder } = deserializeSortValue(internalSort.value || '');\n const nextSort = getNextSort({ newId: sortId, newOrder: sortOrder, oldId, oldOrder });\n\n internalSort.value = nextSort;\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentSort', nextSort);\n }\n };\n\n watch(\n () => props.currentSort,\n () => {\n updateCurrentSort(props.currentSort);\n },\n { immediate: true },\n );\n // #endregion sorting\n\n // #region search\n const internalSearch = ref('');\n\n const hasToolbar = ref(false);\n const isSelectable = ref(false);\n\n const updateCurrentSearch: UpdateCurrentSearch = function (searchTerm, { shouldEmit } = {}) {\n internalSearch.value = searchTerm || '';\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentSearch', searchTerm);\n }\n };\n\n watch(\n () => props.currentSearch,\n () => {\n updateCurrentSearch(props.currentSearch);\n },\n { immediate: true },\n );\n // #endregion search\n\n // #region filters\n const internalFilters = ref<object>({});\n\n const updateCurrentFilters: UpdateCurrentFilters = function (newFilters: object, { shouldEmit } = {}) {\n internalFilters.value = newFilters;\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentFilters', newFilters);\n }\n };\n // #endregion filters\n\n function emitUpdate() {\n emit('update', {\n page: internalPage.value,\n pageSize: props.pageSize,\n ordering: internalSort.value,\n search: internalSearch.value,\n filters: cloneDeep(internalFilters.value),\n });\n }\n\n provide(\n DATA_VIEW_INJECTION.key,\n Object.freeze({\n // Pagination\n currentPage: computed(() => internalPage.value),\n isPaginationEnabled,\n isPaginateNextDisabled,\n pageCount,\n pageSize: computed(() => props.pageSize),\n totalDataCount: computed(() => props.totalDataCount),\n setPage,\n goPrevPage,\n goNextPage,\n\n // Sorting\n currentSortId: internalSortId,\n currentSortOrder: internalSortOrder,\n updateCurrentSort,\n\n // Search\n currentSearch: computed(() => internalSearch.value),\n updateCurrentSearch,\n\n // Miscellaneous\n density: computed(() => props.density),\n hasToolbar,\n isEmpty: computed(() => props.data.length === 0),\n isSelectable,\n isLoading: computed(() => props.isLoading),\n isWithinModule,\n variant: computedVariant,\n }),\n );\n\n defineExpose({\n page: computed(() => internalPage.value),\n pageSize: computed(() => props.pageSize),\n setPage,\n goPrevPage,\n goNextPage,\n ordering: computed(() => internalSort.value),\n updateCurrentSort,\n search: computed(() => internalSearch.value),\n updateCurrentSearch,\n filters: computed(() => internalFilters.value),\n updateCurrentFilters,\n });\n</script>\n\n<template>\n <div ref=\"rootRef\" class=\"stash-data-view relative\" data-test=\"stash-data-view\">\n <!-- @slot default -->\n <slot\n :current-page=\"internalPage\"\n :current-sort-id=\"internalSortId\"\n :current-sort-order=\"internalSortOrder\"\n :data=\"data\"\n :go-prev-page=\"goPrevPage\"\n :go-next-page=\"goNextPage\"\n :page-count=\"pageCount\"\n :set-page=\"setPage\"\n :total-data-count=\"props.totalDataCount\"\n :update-current-sort=\"updateCurrentSort\"\n :update-current-search=\"updateCurrentSearch\"\n ></slot>\n\n <Paginate\n v-if=\"\n isPaginationEnabled &&\n (!isWithinModule || includeBottomPaginationInModule) &&\n pageCount > 1 &&\n !props.hideBottomPagination\n \"\n class=\"mt-6\"\n :class=\"classes.paginate\"\n :current-page=\"internalPage\"\n :is-next-disabled=\"isLoading || isPaginateNextDisabled\"\n :list-length=\"props.totalDataCount\"\n :page-size=\"props.pageSize\"\n :variant=\"props.totalDataCount === Infinity ? 'stats' : 'standard'\"\n @set-page=\"(page: number) => setPage(page, { shouldEmit: true })\"\n />\n </div>\n</template>\n\n<style module>\n @layer utilities {\n .paginate ul {\n margin: 0;\n }\n }\n</style>\n"],"names":["deserializeSortValue","sort","order","serializeSortValue","id","getNextSort","newId","newOrder","oldId","oldOrder","DataViewVariant","props","__props","emit","__emit","classes","useCssModule","rootRef","ref","moduleInjection","inject","MODULE_INJECTION","computedVariant","computed","_a","isWithinModule","includeBottomPaginationInModule","internalPage","isPaginationEnabled","isPaginateNextDisabled","pageCount","setPage","page","shouldEmit","emitUpdate","_b","goPrevPage","goNextPage","watch","internalSort","internalSortId","internalSortOrder","updateCurrentSort","sortId","sortOrder","nextSort","internalSearch","hasToolbar","isSelectable","updateCurrentSearch","searchTerm","internalFilters","updateCurrentFilters","newFilters","cloneDeep","provide","DATA_VIEW_INJECTION","__expose"],"mappings":";;;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AA,MACvC,SAAAoB;AAAA,MACA,YAAAK;AAAA,MACA,YAAAC;AAAA,MACA,UAAUd,EAAS,MAAMgB,EAAa,KAAK;AAAA,MAC3C,mBAAAG;AAAA,MACA,QAAQnB,EAAS,MAAMuB,EAAe,KAAK;AAAA,MAC3C,qBAAAG;AAAA,MACA,SAAS1B,EAAS,MAAM4B,EAAgB,KAAK;AAAA,MAC7C,sBAAAC;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"DataView.js","sources":["../src/components/DataView/DataView.utils.ts","../src/components/DataView/DataView.types.ts","../src/components/DataView/DataView.vue"],"sourcesContent":["import { SortId, SortOrder, SortValue, SortValueDeserialized } from './DataView.types';\n\n/**\n * Receives a SortValue (ex: `'-product_name'`) and returns an object with a `id` and an `order`.\n */\nexport function deserializeSortValue(sort: SortValue): SortValueDeserialized {\n const order = sort[0] === '-' ? 'desc' : 'asc';\n const id = order === 'asc' ? sort : sort.slice(1);\n\n return { id, order };\n}\n\n/**\n * Receives an object with a `id` and an `order` and returns a SortValue (ex: `'-product_name'`).\n */\nexport function serializeSortValue({ id, order }: SortValueDeserialized): SortValue {\n return `${order === 'desc' ? '-' : ''}${id}`;\n}\n\ninterface GetNextSortArgs {\n newId: SortId | undefined;\n newOrder?: SortOrder;\n oldId?: SortId;\n oldOrder?: SortOrder;\n}\n\n/**\n * Given new and old sorting data, it returns the next sorting value using the following sorting cycle:\n *\n * \"unsorted --> ascending --> descending --> unsorted\"\n */\nexport function getNextSort({ newId, newOrder, oldId, oldOrder }: GetNextSortArgs): SortValue | undefined {\n if (!newId) {\n return undefined;\n }\n\n if (newId !== oldId) {\n // if sorting by a new field, sort ascending\n return serializeSortValue({ id: newId, order: newOrder || 'asc' });\n }\n\n /**\n * `newOrder` and `oldOrder` can each have 3 different values: undefined, 'asc', or 'desc'.\n * Therefore, there are 9 possible combinations (3 times 3). See below:\n */\n\n // #region newOrder: undefined\n if (!newOrder && !oldOrder) {\n return newId; // ascending\n }\n\n if (!newOrder && oldOrder === 'desc') {\n return undefined; // unsorted\n }\n\n if (!newOrder && oldOrder === 'asc') {\n return `-${newId}`; // descending\n }\n // #endregion\n\n // #region newOrder: asc\n if (newOrder === 'asc' && !oldOrder) {\n return newId;\n }\n\n if (newOrder === 'asc' && oldOrder === 'asc') {\n return undefined;\n }\n\n if (newOrder === 'asc' && oldOrder === 'desc') {\n return newId;\n }\n // #endregion\n\n // #region newOrder: desc\n if (newOrder === 'desc' && !oldOrder) {\n return `-${newId}`;\n }\n\n if (newOrder === 'desc' && oldOrder === 'desc') {\n return undefined;\n }\n\n if (newOrder === 'desc' && oldOrder === 'asc') {\n return `-${newId}`;\n }\n // #endregion\n}\n","import { ComputedRef, Ref } from 'vue';\n\nimport { SpacingDensities } from '../../../types/misc';\n\nexport enum DataViewVariant {\n Table = 'table',\n}\n\nexport type DataViewVariants = `${DataViewVariant}`;\n\n/**\n * A unique id for a sorting strategy. If the order is descending, it must begin with \"-\" (a hyphen/dash).\n *\n * Ex: `'product_name'` if ascending or `'-product_name'` if descending\n */\nexport type SortValue = string;\n\n/**\n * The SortValue with its leading hyphen/dash removed\n */\nexport type SortId = string;\n\n/**\n * Determined by whether or not there is a leading hyphen/dash in the SortValue\n */\nexport type SortOrder = 'asc' | 'desc';\n\n/**\n * A deserialized instance of a `SortValue`.\n */\nexport type SortValueDeserialized = {\n id: SortId;\n order: SortOrder;\n};\n\n/** Updates the DataView internal state with the given sortId */\nexport type UpdateCurrentSort = (\n sortId: SortId | undefined,\n options?: {\n sortOrder?: SortOrder;\n /** If true, emits the `update:currentSort` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the given page */\nexport type SetPage = (\n page: number,\n options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the previous page */\nexport type GoPrevPage = (options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n}) => void;\n\n/** Updates the DataView internal state with the next page */\nexport type GoNextPage = (options?: {\n /** If true, emits the `update:currentPage` and `update` events from DataView */\n shouldEmit?: boolean;\n}) => void;\n\n/** Updates the DataView internal state with the given searchTerm */\nexport type UpdateCurrentSearch = (\n searchTerm?: string,\n options?: {\n /** If true, emits the `update:currentSearch` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\n/** Updates the DataView internal state with the given filter values */\nexport type UpdateCurrentFilters<FilterValues = object> = (\n newFilters: FilterValues,\n options?: {\n /** If true, emits the `update:currentSearch` and `update` events from DataView */\n shouldEmit?: boolean;\n },\n) => void;\n\nexport interface UpdateEvent<FilterValues = object> {\n page?: number;\n pageSize?: number;\n ordering?: string;\n search?: string;\n filters?: FilterValues;\n}\n\nexport interface DataViewInjection {\n currentPage: ComputedRef<number>;\n\n /** Optional override for the next button disabled state */\n isPaginateNextDisabled: ComputedRef<boolean>;\n\n isPaginationEnabled: ComputedRef<boolean>;\n\n pageCount: ComputedRef<number>;\n\n pageSize: ComputedRef<number>;\n\n totalDataCount: ComputedRef<number>;\n\n /** Updates the DataView internal state with the given page */\n setPage: SetPage;\n\n /** Updates the DataView internal state with the previous page */\n goPrevPage: GoPrevPage;\n\n /** Updates the DataView internal state with the next page */\n goNextPage: GoNextPage;\n\n currentSortId: ComputedRef<SortId | undefined>;\n\n currentSortOrder: ComputedRef<SortOrder | undefined>;\n\n /** Updates the DataView internal state with the given sortId */\n updateCurrentSort: UpdateCurrentSort;\n\n currentSearch: ComputedRef<string>;\n\n /** Updates the DataView internal state with the given searchTerm */\n updateCurrentSearch: UpdateCurrentSearch;\n\n /**\n * The DataView's padding; the default value is \"comfortable\". On small screens, the density will always be \"compact\".\n */\n density: ComputedRef<SpacingDensities | undefined>;\n\n /**\n * Defines if a DataView has a Toolbar rendered. This prop is updated when DataViewToolbar exists and is mounted.\n */\n hasToolbar?: Ref<boolean>;\n\n /**\n * Enables certain loading indicators to be displayed within the DataView.\n */\n isLoading?: ComputedRef<boolean>;\n\n /**\n * Enables certain empty states to be displayed within the DataView.\n */\n isEmpty?: ComputedRef<boolean>;\n\n /**\n * Allows Table to control whether or not a DataViewToolbar should show a checkmark\n */\n isSelectable?: Ref<boolean>;\n\n /**\n * Whether or not the DataView is rendered within a Module; the value is inferred based on being\n * able to inject details from Module.\n *\n * Note: This is sent to DataView child components so they only need to worry about interfacing\n * with the DataViewInjection API.\n */\n isWithinModule: ComputedRef<boolean>;\n\n /**\n * The DataView's variant; the default value is undefined.\n */\n variant: ComputedRef<DataViewVariants | undefined>;\n}\n","<script lang=\"ts\">\n export * from './DataView.constants';\n export * from './DataView.keys';\n export * from './DataView.types';\n export * from './DataView.utils';\n</script>\n\n<script setup lang=\"ts\">\n import cloneDeep from 'lodash-es/cloneDeep';\n import { computed, inject, provide, ref, useCssModule, watch } from 'vue';\n\n import { SpacingDensities } from '../../../types/misc';\n import { MODULE_INJECTION } from '../Module/Module.keys';\n import Paginate from '../Paginate/Paginate.vue';\n import { DEFAULT_PAGE_SIZE } from './DataView.constants';\n import { DATA_VIEW_INJECTION } from './DataView.keys';\n import {\n DataViewVariants,\n GoNextPage,\n GoPrevPage,\n SetPage,\n SortId,\n SortOrder,\n SortValue,\n UpdateCurrentFilters,\n UpdateCurrentSearch,\n UpdateCurrentSort,\n UpdateEvent,\n } from './DataView.types';\n import { deserializeSortValue, getNextSort } from './DataView.utils';\n\n export interface DataViewProps {\n /**\n * Can be used to provide the initial page.\n * Also, it can be used to control the active page with `v-model:current-page=\"myPage\"`.\n */\n currentPage?: number;\n\n /**\n * Can be used to set the initial search term.\n * Also, it can be used to control the active search term with `v-model:current-search=\"mySearchTerm\"`.\n */\n currentSearch?: string;\n\n /**\n * Can be used to provide the initial sort order.\n * Also, it can be used to control the active sort order with `v-model:current-sort=\"mySortOrder\"`.\n */\n currentSort?: SortValue;\n\n /**\n * A list of records. If pagination is enabled, `data` must be only the current page of records.\n */\n data?: object[];\n\n /**\n * Controls the DataView's padding; the default value is \"comfortable\". On small screens, \"compact\" density is applied regardless of this prop's value.\n */\n density?: SpacingDensities;\n\n /**\n * The number of records to display per page.\n */\n pageSize?: number;\n\n /**\n * Opt-out of displaying pagination. Hides the pagination buttons and page stats.\n */\n disablePagination?: boolean;\n\n /**\n * Hides the bottom pagination without disabling the pagination from the toolbar\n */\n hideBottomPagination?: boolean;\n\n /**\n * The total number of records available.\n * Used to auto-enable pagination when results exist.\n * Use `Infinity` for activating 'n of many' pagination\n * DataView does not paginate data for you; instead, `props.data` should always show\n * the current page of results.\n */\n totalDataCount?: number;\n\n /**\n * Whether there is a next page of data or not as informed by the server.\n * This only applies when`totalDataCount=\"Infinity\"` to determine if the \"Next\" pagination button should be disabled.\n */\n hasNextPage?: boolean;\n\n /**\n * DataView variant. The default value is `undefined`. Will default to `table` when used within\n * a `<Module variant=\"table\">`.\n */\n variant?: DataViewVariants;\n\n isLoading?: boolean;\n }\n\n const props = withDefaults(defineProps<DataViewProps>(), {\n currentPage: 1,\n currentSearch: undefined,\n currentSort: undefined,\n data: () => [],\n density: 'comfortable',\n pageSize: DEFAULT_PAGE_SIZE,\n disablePagination: false,\n totalDataCount: 0,\n hasNextPage: undefined,\n hideBottomPagination: false,\n variant: undefined,\n });\n\n const emit = defineEmits<{\n (e: 'update', state: UpdateEvent): void;\n (e: 'update:currentFilters', newFilters: object): void;\n (e: 'update:currentPage', page: number, pageSize: number): void;\n (e: 'update:currentSearch', searchTerm?: string): void;\n (e: 'update:currentSort', payload?: SortValue): void;\n }>();\n\n const classes = useCssModule();\n const rootRef = ref<HTMLElement | null>(null);\n const moduleInjection = inject(MODULE_INJECTION.key, MODULE_INJECTION.defaults);\n const computedVariant = computed<DataViewVariants | undefined>(() => {\n if (props.variant) {\n return props.variant;\n }\n\n if (moduleInjection.variant?.value === 'table') {\n return 'table';\n }\n\n return undefined;\n });\n const isWithinModule = computed(() => moduleInjection.variant !== undefined);\n\n const includeBottomPaginationInModule = computed(() => moduleInjection.includeDataviewPagination?.value);\n\n // #region pagination\n const internalPage = ref(1);\n const isPaginationEnabled = computed(() => !props.disablePagination && props.totalDataCount > 0);\n const isPaginateNextDisabled = computed(() => props.totalDataCount === Infinity && !props.hasNextPage);\n const pageCount = computed(() => Math.ceil(props.totalDataCount / props.pageSize));\n\n const setPage: SetPage = function (page: number, { shouldEmit } = {}) {\n internalPage.value = page;\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentPage', page, props.pageSize);\n }\n\n if (Number(rootRef.value?.getBoundingClientRect().top) < 0) {\n rootRef.value?.scrollIntoView({ behavior: 'smooth', block: 'start' });\n }\n };\n\n const goPrevPage: GoPrevPage = function ({ shouldEmit } = {}) {\n const page = Math.max(internalPage.value - 1, 1);\n\n setPage(page, { shouldEmit });\n };\n\n /** Updates the DataView internal state with the previous page */\n const goNextPage: GoNextPage = function ({ shouldEmit } = {}) {\n const page = Math.min(internalPage.value + 1, pageCount.value);\n\n setPage(page, { shouldEmit });\n };\n\n watch(\n () => props.currentPage,\n () => {\n setPage(props.currentPage);\n },\n { immediate: true },\n );\n // #endregion pagination\n\n // #region sorting\n const internalSort = ref<SortValue | undefined>(undefined);\n\n const internalSortId = computed<SortId | undefined>(() =>\n internalSort.value ? deserializeSortValue(internalSort.value).id : undefined,\n );\n const internalSortOrder = computed<SortOrder | undefined>(() =>\n internalSort.value ? deserializeSortValue(internalSort.value).order : undefined,\n );\n\n const updateCurrentSort: UpdateCurrentSort = function (sortId, { sortOrder, shouldEmit } = {}) {\n const { id: oldId, order: oldOrder } = deserializeSortValue(internalSort.value || '');\n const nextSort = getNextSort({ newId: sortId, newOrder: sortOrder, oldId, oldOrder });\n\n internalSort.value = nextSort;\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentSort', nextSort);\n }\n };\n\n watch(\n () => props.currentSort,\n () => {\n updateCurrentSort(props.currentSort);\n },\n { immediate: true },\n );\n // #endregion sorting\n\n // #region search\n const internalSearch = ref('');\n\n const hasToolbar = ref(false);\n const isSelectable = ref(false);\n\n const updateCurrentSearch: UpdateCurrentSearch = function (searchTerm, { shouldEmit } = {}) {\n internalSearch.value = searchTerm || '';\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentSearch', searchTerm);\n }\n };\n\n watch(\n () => props.currentSearch,\n () => {\n updateCurrentSearch(props.currentSearch);\n },\n { immediate: true },\n );\n // #endregion search\n\n // #region filters\n const internalFilters = ref<object>({});\n\n const updateCurrentFilters: UpdateCurrentFilters = function (newFilters: object, { shouldEmit } = {}) {\n internalFilters.value = newFilters;\n setPage(1);\n\n if (shouldEmit) {\n emitUpdate();\n emit('update:currentFilters', newFilters);\n }\n };\n // #endregion filters\n\n function emitUpdate() {\n emit('update', {\n page: internalPage.value,\n pageSize: props.pageSize,\n ordering: internalSort.value,\n search: internalSearch.value,\n filters: cloneDeep(internalFilters.value),\n });\n }\n\n provide(\n DATA_VIEW_INJECTION.key,\n Object.freeze({\n // Pagination\n currentPage: computed(() => internalPage.value),\n isPaginationEnabled,\n isPaginateNextDisabled,\n pageCount,\n pageSize: computed(() => props.pageSize),\n totalDataCount: computed(() => props.totalDataCount),\n setPage,\n goPrevPage,\n goNextPage,\n\n // Sorting\n currentSortId: internalSortId,\n currentSortOrder: internalSortOrder,\n updateCurrentSort,\n\n // Search\n currentSearch: computed(() => internalSearch.value),\n updateCurrentSearch,\n\n // Miscellaneous\n density: computed(() => props.density),\n hasToolbar,\n isEmpty: computed(() => props.data.length === 0),\n isSelectable,\n isLoading: computed(() => props.isLoading),\n isWithinModule,\n variant: computedVariant,\n }),\n );\n\n defineExpose({\n page: computed(() => internalPage.value),\n pageSize: computed(() => props.pageSize),\n setPage,\n goPrevPage,\n goNextPage,\n ordering: computed(() => internalSort.value),\n updateCurrentSort,\n search: computed(() => internalSearch.value),\n updateCurrentSearch,\n filters: computed(() => internalFilters.value),\n updateCurrentFilters,\n });\n</script>\n\n<template>\n <div ref=\"rootRef\" class=\"stash-data-view relative\" data-test=\"stash-data-view\">\n <!-- @slot default -->\n <slot\n :current-page=\"internalPage\"\n :current-sort-id=\"internalSortId\"\n :current-sort-order=\"internalSortOrder\"\n :data=\"data\"\n :go-prev-page=\"goPrevPage\"\n :go-next-page=\"goNextPage\"\n :page-count=\"pageCount\"\n :set-page=\"setPage\"\n :total-data-count=\"props.totalDataCount\"\n :update-current-sort=\"updateCurrentSort\"\n :update-current-search=\"updateCurrentSearch\"\n ></slot>\n\n <Paginate\n v-if=\"\n isPaginationEnabled &&\n (!isWithinModule || includeBottomPaginationInModule) &&\n pageCount > 1 &&\n !props.hideBottomPagination\n \"\n class=\"mt-6\"\n :class=\"classes.paginate\"\n :current-page=\"internalPage\"\n :is-next-disabled=\"isLoading || isPaginateNextDisabled\"\n :list-length=\"props.totalDataCount\"\n :page-size=\"props.pageSize\"\n :variant=\"props.totalDataCount === Infinity ? 'stats' : 'standard'\"\n @set-page=\"(page: number) => setPage(page, { shouldEmit: true })\"\n />\n </div>\n</template>\n\n<style module>\n @layer utilities {\n .paginate ul {\n margin: 0;\n }\n }\n</style>\n"],"names":["deserializeSortValue","sort","order","serializeSortValue","id","getNextSort","newId","newOrder","oldId","oldOrder","DataViewVariant","props","__props","emit","__emit","classes","useCssModule","rootRef","ref","moduleInjection","inject","MODULE_INJECTION","computedVariant","computed","_a","isWithinModule","includeBottomPaginationInModule","internalPage","isPaginationEnabled","isPaginateNextDisabled","pageCount","setPage","page","shouldEmit","emitUpdate","_b","goPrevPage","goNextPage","watch","internalSort","internalSortId","internalSortOrder","updateCurrentSort","sortId","sortOrder","nextSort","internalSearch","hasToolbar","isSelectable","updateCurrentSearch","searchTerm","internalFilters","updateCurrentFilters","newFilters","cloneDeep","provide","DATA_VIEW_INJECTION","__expose","_createElementBlock","_renderSlot","_ctx","_createBlock","Paginate","_normalizeClass","_unref","_cache"],"mappings":";;;;;;AAKO,SAASA,EAAqBC,GAAwC;AAC3E,QAAMC,IAAQD,EAAK,CAAC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,UAAUd,EAAS,MAAMgB,EAAa,KAAK;AAAA,MAC3C,mBAAAG;AAAA,MACA,QAAQnB,EAAS,MAAMuB,EAAe,KAAK;AAAA,MAC3C,qBAAAG;AAAA,MACA,SAAS1B,EAAS,MAAM4B,EAAgB,KAAK;AAAA,MAC7C,sBAAAC;AAAA,IAAA,CACD,mBAIDM,EAgCM,OAAA;AAAA,eAhCG;AAAA,MAAJ,KAAIzC;AAAA,MAAU,OAAM;AAAA,MAA2B,aAAU;AAAA,IAAA;MAE5D0C,EAYQC,EAAA,QAAA,WAAA;AAAA,QAXL,aAAcjC,EAAA;AAAA,QACd,eAAiBa,EAAA;AAAA,QACjB,kBAAoBC,EAAA;AAAA,QACpB,MAAM7B,EAAA;AAAA,QACN,YAAAwB;AAAA,QACA,YAAAC;AAAA,QACA,WAAYP,EAAA;AAAA,QACZ,SAAAC;AAAA,QACA,gBAAkBpB,EAAM;AAAA,QACxB,mBAAA+B;AAAA,QACA,qBAAAO;AAAA,MAAA;MAIcrB,EAAA,UAAiC,CAAAH,EAAA,SAAkBC,EAAA,UAA4CI,EAAA,QAAS,KAAiB,CAAAnB,EAAM,6BADhJkD,EAeEC,GAAA;AAAA;QARA,OAAKC,EAAA,CAAC,QACEC,EAAAjD,CAAA,EAAQ,QAAQ,CAAA;AAAA,QACvB,gBAAcY,EAAA;AAAA,QACd,oBAAkBf,EAAA,aAAaiB,EAAA;AAAA,QAC/B,eAAalB,EAAM;AAAA,QACnB,aAAWA,EAAM;AAAA,QACjB,SAASA,EAAM,mBAAmB,QAAQ,UAAA;AAAA,QAC1C,WAAQsD,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAA,CAAGjC,MAAiBD,EAAQC,GAAI,EAAA,YAAA,IAAA;AAAA,MAAA;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataViewFilters.js","sources":["../src/components/DataViewFilters/DataViewFilters.types.ts","../src/components/DataViewFilters/useFilters.ts","../src/components/DataViewFilters/DataViewFilters.vue"],"sourcesContent":["import { UseFiltersReturnType } from './useFilters';\n\n/**\n * A function that is called when the user clicks one of the \"Apply\" buttons in DataViewFilters.\n *\n * A return value of `{ preventDismiss: true }` can be used to prevent the DataViewFilters drawer or a FilterDropdown from closing, such as when some filters have invalid values.\n */\nexport type OnApplyFilters = () => Promise<{ preventDismiss?: boolean } | void> | { preventDismiss?: boolean } | void;\n\nexport enum DrawerStyle {\n /** Displays all groups and their fields without the need for navigating submenus. */\n Cascade = 'cascade',\n /** Displays only group names or fields; navigation between the group names and a submenu of fields is required. */\n Nested = 'nested',\n}\n\nexport type DrawerStyles = `${DrawerStyle}`;\n\nexport interface DataViewFiltersUtilsInjection {\n useFiltersInstance?: UseFiltersReturnType;\n drawerStyle?: DrawerStyles;\n}\n","import cloneDeep from 'lodash-es/cloneDeep';\nimport { computed, ComputedRef, Ref, ref } from 'vue';\n\nimport isDefined from '../../composables/useValidation/utils/isDefined';\nimport DataView from '../DataView/DataView.vue';\n\ntype DataViewInstance = InstanceType<typeof DataView>;\n\n/**\n * Contains metadata and configuration for the filters.\n * @see https://www.typescriptlang.org/docs/handbook/2/mapped-types.html\n */\nexport type UseFiltersSchema<Values extends object, Groups extends string> = {\n [Property in keyof Values]: {\n defaultValue?: Values[Property];\n group?: Groups;\n isActive?: (value: Values[Property]) => boolean;\n };\n};\n\nexport interface UseFiltersArgs<Values extends object, Groups extends string> {\n schema: UseFiltersSchema<Values, Groups>;\n /** A ref for an instance of DataView */\n dataViewRef: Ref<unknown>; // Note: using `Ref<InstanceType<typeof DataView>>` here causes type errors when providing a value for this argument\n}\n\nexport interface UseFiltersReturnType<Values = object, Groups extends string = string> {\n applyFilters: () => void;\n resetAllFilters: () => void;\n resetFilterGroup: (group: string) => void; // Note: group is intentionally not typed as `Groups` since there is no way to pass in a Groups type to UseFiltersReturnType within DataViewFilters.vue\n undoWorkingFilters: () => void;\n activeFiltersCounts: ComputedRef<Record<Groups, number>>;\n totalActiveFiltersCount: ComputedRef<number>;\n appliedFilters: Ref<Values>;\n workingFilters: Ref<Values>;\n}\n\n/**\n * Provides utility functions for working with `DataViewFilters`.\n */\nexport function useFilters<Values extends object, Groups extends string>({\n schema,\n dataViewRef,\n}: UseFiltersArgs<Values, Groups>): UseFiltersReturnType<Values, Groups> {\n const appliedFilters = ref({}) as Ref<Values>;\n const workingFilters = ref({}) as Ref<Values>;\n\n for (const filterName in schema) {\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n appliedFilters.value[filterName] = schema[filterName].defaultValue;\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n workingFilters.value[filterName] = schema[filterName].defaultValue;\n }\n\n const dvRef = dataViewRef as Ref<DataViewInstance>;\n\n /**\n * For when an \"Apply\" button is clicked. It does the following:\n * 1) applies the working filter state\n * 2) sets the current page to 1\n * 3) emits the \"update\" event from DataView\n */\n function applyFilters() {\n appliedFilters.value = cloneDeep(workingFilters.value);\n dvRef.value.updateCurrentFilters(appliedFilters.value, { shouldEmit: true });\n }\n\n /**\n * For when a \"Reset all\" button is clicked. It does the following:\n * 1) applies the defaultValue filter values to all filters\n * 2) sets the current page to 1\n * 3) emits the \"update\" event from DataView\n */\n function resetAllFilters() {\n for (const filterName in schema) {\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n appliedFilters.value[filterName] = schema[filterName].defaultValue;\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n workingFilters.value[filterName] = schema[filterName].defaultValue;\n }\n\n dvRef.value.updateCurrentFilters(appliedFilters.value, { shouldEmit: true });\n }\n\n /**\n * For when a \"Reset\" button is clicked. It does the following:\n * 1) applies the defaultValue filter values to the given filter group\n * 2) sets the current page to 1\n * 3) emits the \"update\" event from DataView\n */\n function resetFilterGroup(group: Groups) {\n for (const filterName in schema) {\n if (schema[filterName].group === group) {\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n appliedFilters.value[filterName] = schema[filterName].defaultValue;\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n workingFilters.value[filterName] = schema[filterName].defaultValue;\n }\n }\n\n dvRef.value.updateCurrentFilters(appliedFilters.value, { shouldEmit: true });\n }\n\n /**\n * Resets the `workingFilters` to match the `appliedFilters`. This can be used when the FilterDrawer or a FilterDropdown is dismissed without clicking \"Reset\" or \"Apply\".\n */\n function undoWorkingFilters() {\n workingFilters.value = cloneDeep(appliedFilters.value);\n }\n\n const activeFiltersCounts = computed(() => {\n const counts = {} as Record<Groups, number>;\n\n for (const filterName in schema) {\n const config = schema[filterName];\n const value = appliedFilters.value[filterName];\n const isActive = config.isActive?.(value) || isDefined(value);\n\n if (isActive && config.group) {\n counts[config.group] = (counts[config.group] ?? 0) + 1;\n }\n }\n\n return counts;\n });\n\n const totalActiveFiltersCount = computed(() => {\n let count = 0;\n\n for (const filterName in schema) {\n const config = schema[filterName];\n const value = appliedFilters.value[filterName];\n const isActive = config.isActive?.(value) || isDefined(value);\n\n if (isActive) {\n count += 1;\n }\n }\n\n return count;\n });\n\n return {\n applyFilters,\n resetAllFilters,\n // @ts-expect-error \"could be instantiated with a different subtype\": TODO: figure out how to resolve the types\n resetFilterGroup,\n undoWorkingFilters,\n activeFiltersCounts,\n totalActiveFiltersCount,\n appliedFilters,\n workingFilters,\n };\n}\n\nexport default useFilters;\n","<script lang=\"ts\">\n export * from './DataViewFilters.keys';\n export * from './DataViewFilters.types';\n export * from './useFilters';\n</script>\n\n<script setup lang=\"ts\">\n import { computed, inject, provide, ref, watch } from 'vue';\n\n import useMediaQuery from '../../composables/useMediaQuery/useMediaQuery';\n import { SCREEN_SIZES } from '../../constants';\n import { t } from '../../locale';\n import Box from '../Box/Box.vue';\n import Button from '../Button/Button.vue';\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import FilterChip from '../FilterChip/FilterChip.vue';\n import Icon from '../Icon/Icon.vue';\n import Label from '../Label/Label.vue';\n import Modal, { type ModalProps } from '../Modal/Modal.vue';\n import SearchBar, { SearchBarProps } from '../SearchBar/SearchBar.vue';\n import { DATA_VIEW_FILTERS_UTILS_INJECTION } from './DataViewFilters.keys';\n import type { DrawerStyles, OnApplyFilters } from './DataViewFilters.types';\n import type { UseFiltersReturnType } from './useFilters';\n\n export interface DataViewFiltersProps {\n filtersLabelText?: string;\n /**\n * Props to pass to the `SearchBar` component.\n */\n searchBarProps?: SearchBarProps;\n showSearch?: boolean;\n /** 'cascade' displays all fields within every filter group; 'nested' displays only the group names and requires clicking a group to view its fields. */\n drawerStyle?: DrawerStyles;\n drawerProps?: ModalProps;\n /**\n * @deprecated The `activeGroup` prop is a sufficient replacement for this prop. A falsy `activeGroup` will hide the button and a truthy `activeGroup` will show it (when the `drawerStyle` is 'nested').\n *\n * **Note:** This prop has no effect when using a \"cascade\" `drawerStyle`.\n */\n showDrawerPreviousButton?: boolean;\n /**\n * Required when using filters. This prop should contain the return value of the `useFilters()` composable.\n */\n useFiltersInstance?: UseFiltersReturnType;\n onApply?: OnApplyFilters;\n /**\n * The name of the active filter group. The active filter group is determined by which instance of FilterDropdown or FilterDrawerItem is open.\n *\n * **Note:** This prop is required when using a \"nested\" `drawerStyle`, but has no effect when using a \"cascade\" `drawerStyle`.\n */\n activeGroup?: string;\n }\n\n export interface DataViewFiltersSlots {\n default?: () => unknown;\n drawer?: () => unknown;\n 'filters-label'?: () => unknown;\n }\n\n const props = withDefaults(defineProps<DataViewFiltersProps>(), {\n filtersLabelText: t('ll.filterBy'),\n isLoading: false,\n drawerStyle: 'cascade',\n drawerProps: undefined,\n searchBarProps: undefined,\n showDrawerPreviousButton: false,\n showSearch: true,\n useFiltersInstance: undefined,\n onApply: undefined,\n activeGroup: undefined,\n });\n\n const emit = defineEmits<{\n /** When the drawer is opened */\n (e: 'open-drawer'): void;\n /** When the drawer is dismissed */\n (e: 'dismiss'): void;\n /** When the \"Previous\" button in the header is clicked */\n (e: 'previous'): void;\n /** When the \"Reset\" button is clicked while viewing a filter group */\n (e: 'reset-group'): void;\n /** When one of the \"Reset All\" buttons is clicked */\n (e: 'reset-all'): void;\n }>();\n\n const slots = defineSlots<DataViewFiltersSlots>();\n\n const isDesktop = useMediaQuery(`(min-width: ${SCREEN_SIZES.lg})`);\n const isViewingGroupsMenu = computed(() => props.drawerStyle === 'nested' && !props.activeGroup);\n const isViewingSingleGroup = computed(() => props.drawerStyle === 'nested' && props.activeGroup);\n\n const {\n density,\n isLoading: isDataViewLoading,\n isWithinModule,\n currentSearch,\n updateCurrentSearch,\n } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n provide(DATA_VIEW_FILTERS_UTILS_INJECTION.key, {\n useFiltersInstance: props.useFiltersInstance,\n drawerStyle: props.drawerStyle,\n });\n\n const totalActiveFiltersCount = computed(() => props.useFiltersInstance?.totalActiveFiltersCount.value ?? 0);\n /** The number of active filters in the currently active group. This is only used when the drawerStyle is 'nested'. */\n const activeGroupActiveFiltersCount = computed(\n () => Number(props.activeGroup && props.useFiltersInstance?.activeFiltersCounts.value[props.activeGroup]) || 0,\n );\n const isDrawerOpen = ref(false);\n\n async function handleApplyClick() {\n const { preventDismiss } = (await props.onApply?.()) || props.useFiltersInstance?.applyFilters() || {};\n\n if (!preventDismiss) {\n isDrawerOpen.value = false;\n }\n }\n\n function handleResetGroupClick() {\n if (!props.activeGroup) {\n return;\n }\n\n props.useFiltersInstance?.resetFilterGroup(props.activeGroup);\n emit('reset-group');\n isDrawerOpen.value = false;\n }\n\n function handleResetAllClick() {\n props.useFiltersInstance?.resetAllFilters();\n emit('reset-all');\n isDrawerOpen.value = false;\n }\n\n function onDismiss() {\n props.useFiltersInstance?.undoWorkingFilters();\n isDrawerOpen.value = false;\n emit('dismiss');\n }\n\n watch(isDrawerOpen, () => {\n if (isDrawerOpen.value) {\n emit('open-drawer');\n }\n });\n</script>\n\n<template>\n <Box\n class=\"stash-data-view-filters grid grid-cols-12 gap-6 p-3\"\n :class=\"{ 'lg:p-6': density === 'comfortable', 'mb-3': !isWithinModule }\"\n :radius=\"isWithinModule ? 'none' : 'rounded'\"\n data-test=\"stash-data-view-filters\"\n disable-padding\n >\n <SearchBar\n v-if=\"props.showSearch\"\n class=\"col-span-12 md:col-span-6 lg:col-span-4\"\n data-test=\"stash-data-view-filters|search-bar\"\n :is-loading=\"isDataViewLoading\"\n :label=\"t('ll.search')\"\n :model-value=\"currentSearch\"\n v-bind=\"props.searchBarProps\"\n @search=\"(searchTerm) => updateCurrentSearch(searchTerm, { shouldEmit: true })\"\n />\n <div\n v-if=\"slots.default\"\n class=\"col-span-12 row-start-2 md:col-start-7 md:row-start-1 lg:col-span-8 lg:col-start-5\"\n >\n <div class=\"hidden md:block\">\n <slot name=\"filters-label\">\n <Label>{{ props.filtersLabelText }}</Label>\n </slot>\n </div>\n <div class=\"flex gap-4\">\n <FilterChip\n secondary\n class=\"!md:inline-flex !flex w-full justify-center gap-4 md:w-auto\"\n data-test=\"stash-data-view-filters|drawer-toggle-button\"\n :filter-count=\"totalActiveFiltersCount\"\n @click=\"isDrawerOpen = true\"\n >\n <span class=\"inline-flex items-center gap-3\">\n <Icon name=\"filter-line\" class=\"text-ice-700\" />\n <span>{{ t('ll.filters') }}</span>\n </span>\n </FilterChip>\n <slot v-if=\"isDesktop\"></slot>\n <Button v-if=\"totalActiveFiltersCount > 0 && isDesktop\" inline @click=\"handleResetAllClick\">\n {{ t('ll.resetAll') }}\n </Button>\n </div>\n </div>\n <Modal\n v-if=\"slots.drawer\"\n data-test=\"stash-data-view-filters|drawer\"\n disable-body-padding\n position=\"right\"\n size=\"narrow\"\n :is-open=\"isDrawerOpen\"\n :title=\"t('ll.allFilters')\"\n v-bind=\"props.drawerProps\"\n @dismiss=\"onDismiss\"\n >\n <template #headerAction>\n <Button\n v-if=\"isViewingSingleGroup\"\n icon\n class=\"text-ice-100\"\n data-test=\"stash-data-view-filters|drawer-previous-button\"\n :aria-label=\"t('ll.previous')\"\n :title=\"t('ll.previous')\"\n @click=\"emit('previous')\"\n >\n <Icon name=\"chevron-left\" />\n </Button>\n </template>\n\n <slot name=\"drawer\"></slot>\n\n <template #footer>\n <div class=\"flex justify-end gap-gutter\">\n <Button v-if=\"totalActiveFiltersCount === 0\" secondary @click=\"onDismiss\">\n {{ t('ll.cancel') }}\n </Button>\n <Button\n v-if=\"(isViewingGroupsMenu || props.drawerStyle === 'cascade') && totalActiveFiltersCount > 0\"\n secondary\n :disabled=\"isDataViewLoading\"\n @click=\"handleResetAllClick\"\n >\n {{ t('ll.resetAll') }}\n </Button>\n <Button\n v-if=\"isViewingSingleGroup && activeGroupActiveFiltersCount > 0\"\n secondary\n :disabled=\"isDataViewLoading\"\n @click=\"handleResetGroupClick\"\n >\n {{ t('ll.reset') }}\n </Button>\n <Button\n v-if=\"isViewingSingleGroup || props.drawerStyle === 'cascade'\"\n :disabled=\"isDataViewLoading\"\n @click=\"handleApplyClick\"\n >\n {{ t('ll.apply') }}\n </Button>\n </div>\n </template>\n </Modal>\n </Box>\n</template>\n"],"names":["DrawerStyle","useFilters","schema","dataViewRef","appliedFilters","ref","workingFilters","filterName","dvRef","applyFilters","cloneDeep","resetAllFilters","resetFilterGroup","group","undoWorkingFilters","activeFiltersCounts","computed","counts","config","value","_a","isDefined","totalActiveFiltersCount","count","props","__props","emit","__emit","slots","_useSlots","isDesktop","useMediaQuery","SCREEN_SIZES","isViewingGroupsMenu","isViewingSingleGroup","density","isDataViewLoading","isWithinModule","currentSearch","updateCurrentSearch","inject","DATA_VIEW_INJECTION","provide","DATA_VIEW_FILTERS_UTILS_INJECTION","activeGroupActiveFiltersCount","isDrawerOpen","handleApplyClick","preventDismiss","_b","handleResetGroupClick","handleResetAllClick","onDismiss","watch"],"mappings":";;;;;;;;;;;;;;;;AASO,IAAKA,uBAAAA,OAEVA,EAAA,UAAU,WAEVA,EAAA,SAAS,UAJCA,IAAAA,MAAA,CAAA,CAAA;AC+BL,SAASC,GA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BAAwB,UAAS;AAAA,KAAC,GAErGwB,IAAgC5B;AAAA,MACpC,MAAA;;AAAM,sBAAOQ,EAAM,iBAAeJ,IAAAI,EAAM,uBAAN,gBAAAJ,EAA0B,oBAAoB,MAAMI,EAAM,aAAY,KAAK;AAAA;AAAA,IAAA,GAEzGqB,IAAexC,EAAI,EAAK;AAE9B,mBAAeyC,IAAmB;;AAChC,YAAM,EAAE,gBAAAC,MAAoB,QAAM3B,IAAAI,EAAM,YAAN,gBAAAJ,EAAA,KAAAI,SAAsBwB,IAAAxB,EAAM,uBAAN,gBAAAwB,EAA0B,mBAAkB,CAAA;AAEpG,MAAKD,MACHF,EAAa,QAAQ;AAAA,IAEzB;AAEA,aAASI,IAAwB;;AAC/B,MAAKzB,EAAM,iBAIXJ,IAAAI,EAAM,uBAAN,QAAAJ,EAA0B,iBAAiBI,EAAM,cACjDE,EAAK,aAAa,GAClBmB,EAAa,QAAQ;AAAA,IACvB;AAEA,aAASK,IAAsB;;AAC7B,OAAA9B,IAAAI,EAAM,uBAAN,QAAAJ,EAA0B,mBAC1BM,EAAK,WAAW,GAChBmB,EAAa,QAAQ;AAAA,IACvB;AAEA,aAASM,IAAY;;AACnB,OAAA/B,IAAAI,EAAM,uBAAN,QAAAJ,EAA0B,sBAC1ByB,EAAa,QAAQ,IACrBnB,EAAK,SAAS;AAAA,IAChB;AAEA,WAAA0B,EAAMP,GAAc,MAAM;AACxB,MAAIA,EAAa,SACfnB,EAAK,aAAa;AAAA,IAEtB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"DataViewFilters.js","sources":["../src/components/DataViewFilters/DataViewFilters.types.ts","../src/components/DataViewFilters/useFilters.ts","../src/components/DataViewFilters/DataViewFilters.vue"],"sourcesContent":["import { UseFiltersReturnType } from './useFilters';\n\n/**\n * A function that is called when the user clicks one of the \"Apply\" buttons in DataViewFilters.\n *\n * A return value of `{ preventDismiss: true }` can be used to prevent the DataViewFilters drawer or a FilterDropdown from closing, such as when some filters have invalid values.\n */\nexport type OnApplyFilters = () => Promise<{ preventDismiss?: boolean } | void> | { preventDismiss?: boolean } | void;\n\nexport enum DrawerStyle {\n /** Displays all groups and their fields without the need for navigating submenus. */\n Cascade = 'cascade',\n /** Displays only group names or fields; navigation between the group names and a submenu of fields is required. */\n Nested = 'nested',\n}\n\nexport type DrawerStyles = `${DrawerStyle}`;\n\nexport interface DataViewFiltersUtilsInjection {\n useFiltersInstance?: UseFiltersReturnType;\n drawerStyle?: DrawerStyles;\n}\n","import cloneDeep from 'lodash-es/cloneDeep';\nimport { computed, ComputedRef, Ref, ref } from 'vue';\n\nimport isDefined from '../../composables/useValidation/utils/isDefined';\nimport DataView from '../DataView/DataView.vue';\n\ntype DataViewInstance = InstanceType<typeof DataView>;\n\n/**\n * Contains metadata and configuration for the filters.\n * @see https://www.typescriptlang.org/docs/handbook/2/mapped-types.html\n */\nexport type UseFiltersSchema<Values extends object, Groups extends string> = {\n [Property in keyof Values]: {\n defaultValue?: Values[Property];\n group?: Groups;\n isActive?: (value: Values[Property]) => boolean;\n };\n};\n\nexport interface UseFiltersArgs<Values extends object, Groups extends string> {\n schema: UseFiltersSchema<Values, Groups>;\n /** A ref for an instance of DataView */\n dataViewRef: Ref<unknown>; // Note: using `Ref<InstanceType<typeof DataView>>` here causes type errors when providing a value for this argument\n}\n\nexport interface UseFiltersReturnType<Values = object, Groups extends string = string> {\n applyFilters: () => void;\n resetAllFilters: () => void;\n resetFilterGroup: (group: string) => void; // Note: group is intentionally not typed as `Groups` since there is no way to pass in a Groups type to UseFiltersReturnType within DataViewFilters.vue\n undoWorkingFilters: () => void;\n activeFiltersCounts: ComputedRef<Record<Groups, number>>;\n totalActiveFiltersCount: ComputedRef<number>;\n appliedFilters: Ref<Values>;\n workingFilters: Ref<Values>;\n}\n\n/**\n * Provides utility functions for working with `DataViewFilters`.\n */\nexport function useFilters<Values extends object, Groups extends string>({\n schema,\n dataViewRef,\n}: UseFiltersArgs<Values, Groups>): UseFiltersReturnType<Values, Groups> {\n const appliedFilters = ref({}) as Ref<Values>;\n const workingFilters = ref({}) as Ref<Values>;\n\n for (const filterName in schema) {\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n appliedFilters.value[filterName] = schema[filterName].defaultValue;\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n workingFilters.value[filterName] = schema[filterName].defaultValue;\n }\n\n const dvRef = dataViewRef as Ref<DataViewInstance>;\n\n /**\n * For when an \"Apply\" button is clicked. It does the following:\n * 1) applies the working filter state\n * 2) sets the current page to 1\n * 3) emits the \"update\" event from DataView\n */\n function applyFilters() {\n appliedFilters.value = cloneDeep(workingFilters.value);\n dvRef.value.updateCurrentFilters(appliedFilters.value, { shouldEmit: true });\n }\n\n /**\n * For when a \"Reset all\" button is clicked. It does the following:\n * 1) applies the defaultValue filter values to all filters\n * 2) sets the current page to 1\n * 3) emits the \"update\" event from DataView\n */\n function resetAllFilters() {\n for (const filterName in schema) {\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n appliedFilters.value[filterName] = schema[filterName].defaultValue;\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n workingFilters.value[filterName] = schema[filterName].defaultValue;\n }\n\n dvRef.value.updateCurrentFilters(appliedFilters.value, { shouldEmit: true });\n }\n\n /**\n * For when a \"Reset\" button is clicked. It does the following:\n * 1) applies the defaultValue filter values to the given filter group\n * 2) sets the current page to 1\n * 3) emits the \"update\" event from DataView\n */\n function resetFilterGroup(group: Groups) {\n for (const filterName in schema) {\n if (schema[filterName].group === group) {\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n appliedFilters.value[filterName] = schema[filterName].defaultValue;\n // @ts-expect-error \"could be instantiated with an arbitrary type\"; TODO: figure out how to resolve the types\n workingFilters.value[filterName] = schema[filterName].defaultValue;\n }\n }\n\n dvRef.value.updateCurrentFilters(appliedFilters.value, { shouldEmit: true });\n }\n\n /**\n * Resets the `workingFilters` to match the `appliedFilters`. This can be used when the FilterDrawer or a FilterDropdown is dismissed without clicking \"Reset\" or \"Apply\".\n */\n function undoWorkingFilters() {\n workingFilters.value = cloneDeep(appliedFilters.value);\n }\n\n const activeFiltersCounts = computed(() => {\n const counts = {} as Record<Groups, number>;\n\n for (const filterName in schema) {\n const config = schema[filterName];\n const value = appliedFilters.value[filterName];\n const isActive = config.isActive?.(value) || isDefined(value);\n\n if (isActive && config.group) {\n counts[config.group] = (counts[config.group] ?? 0) + 1;\n }\n }\n\n return counts;\n });\n\n const totalActiveFiltersCount = computed(() => {\n let count = 0;\n\n for (const filterName in schema) {\n const config = schema[filterName];\n const value = appliedFilters.value[filterName];\n const isActive = config.isActive?.(value) || isDefined(value);\n\n if (isActive) {\n count += 1;\n }\n }\n\n return count;\n });\n\n return {\n applyFilters,\n resetAllFilters,\n // @ts-expect-error \"could be instantiated with a different subtype\": TODO: figure out how to resolve the types\n resetFilterGroup,\n undoWorkingFilters,\n activeFiltersCounts,\n totalActiveFiltersCount,\n appliedFilters,\n workingFilters,\n };\n}\n\nexport default useFilters;\n","<script lang=\"ts\">\n export * from './DataViewFilters.keys';\n export * from './DataViewFilters.types';\n export * from './useFilters';\n</script>\n\n<script setup lang=\"ts\">\n import { computed, inject, provide, ref, watch } from 'vue';\n\n import useMediaQuery from '../../composables/useMediaQuery/useMediaQuery';\n import { SCREEN_SIZES } from '../../constants';\n import { t } from '../../locale';\n import Box from '../Box/Box.vue';\n import Button from '../Button/Button.vue';\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import FilterChip from '../FilterChip/FilterChip.vue';\n import Icon from '../Icon/Icon.vue';\n import Label from '../Label/Label.vue';\n import Modal, { type ModalProps } from '../Modal/Modal.vue';\n import SearchBar, { SearchBarProps } from '../SearchBar/SearchBar.vue';\n import { DATA_VIEW_FILTERS_UTILS_INJECTION } from './DataViewFilters.keys';\n import type { DrawerStyles, OnApplyFilters } from './DataViewFilters.types';\n import type { UseFiltersReturnType } from './useFilters';\n\n export interface DataViewFiltersProps {\n filtersLabelText?: string;\n /**\n * Props to pass to the `SearchBar` component.\n */\n searchBarProps?: SearchBarProps;\n showSearch?: boolean;\n /** 'cascade' displays all fields within every filter group; 'nested' displays only the group names and requires clicking a group to view its fields. */\n drawerStyle?: DrawerStyles;\n drawerProps?: ModalProps;\n /**\n * @deprecated The `activeGroup` prop is a sufficient replacement for this prop. A falsy `activeGroup` will hide the button and a truthy `activeGroup` will show it (when the `drawerStyle` is 'nested').\n *\n * **Note:** This prop has no effect when using a \"cascade\" `drawerStyle`.\n */\n showDrawerPreviousButton?: boolean;\n /**\n * Required when using filters. This prop should contain the return value of the `useFilters()` composable.\n */\n useFiltersInstance?: UseFiltersReturnType;\n onApply?: OnApplyFilters;\n /**\n * The name of the active filter group. The active filter group is determined by which instance of FilterDropdown or FilterDrawerItem is open.\n *\n * **Note:** This prop is required when using a \"nested\" `drawerStyle`, but has no effect when using a \"cascade\" `drawerStyle`.\n */\n activeGroup?: string;\n }\n\n export interface DataViewFiltersSlots {\n default?: () => unknown;\n drawer?: () => unknown;\n 'filters-label'?: () => unknown;\n }\n\n const props = withDefaults(defineProps<DataViewFiltersProps>(), {\n filtersLabelText: t('ll.filterBy'),\n isLoading: false,\n drawerStyle: 'cascade',\n drawerProps: undefined,\n searchBarProps: undefined,\n showDrawerPreviousButton: false,\n showSearch: true,\n useFiltersInstance: undefined,\n onApply: undefined,\n activeGroup: undefined,\n });\n\n const emit = defineEmits<{\n /** When the drawer is opened */\n (e: 'open-drawer'): void;\n /** When the drawer is dismissed */\n (e: 'dismiss'): void;\n /** When the \"Previous\" button in the header is clicked */\n (e: 'previous'): void;\n /** When the \"Reset\" button is clicked while viewing a filter group */\n (e: 'reset-group'): void;\n /** When one of the \"Reset All\" buttons is clicked */\n (e: 'reset-all'): void;\n }>();\n\n const slots = defineSlots<DataViewFiltersSlots>();\n\n const isDesktop = useMediaQuery(`(min-width: ${SCREEN_SIZES.lg})`);\n const isViewingGroupsMenu = computed(() => props.drawerStyle === 'nested' && !props.activeGroup);\n const isViewingSingleGroup = computed(() => props.drawerStyle === 'nested' && props.activeGroup);\n\n const {\n density,\n isLoading: isDataViewLoading,\n isWithinModule,\n currentSearch,\n updateCurrentSearch,\n } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n provide(DATA_VIEW_FILTERS_UTILS_INJECTION.key, {\n useFiltersInstance: props.useFiltersInstance,\n drawerStyle: props.drawerStyle,\n });\n\n const totalActiveFiltersCount = computed(() => props.useFiltersInstance?.totalActiveFiltersCount.value ?? 0);\n /** The number of active filters in the currently active group. This is only used when the drawerStyle is 'nested'. */\n const activeGroupActiveFiltersCount = computed(\n () => Number(props.activeGroup && props.useFiltersInstance?.activeFiltersCounts.value[props.activeGroup]) || 0,\n );\n const isDrawerOpen = ref(false);\n\n async function handleApplyClick() {\n const { preventDismiss } = (await props.onApply?.()) || props.useFiltersInstance?.applyFilters() || {};\n\n if (!preventDismiss) {\n isDrawerOpen.value = false;\n }\n }\n\n function handleResetGroupClick() {\n if (!props.activeGroup) {\n return;\n }\n\n props.useFiltersInstance?.resetFilterGroup(props.activeGroup);\n emit('reset-group');\n isDrawerOpen.value = false;\n }\n\n function handleResetAllClick() {\n props.useFiltersInstance?.resetAllFilters();\n emit('reset-all');\n isDrawerOpen.value = false;\n }\n\n function onDismiss() {\n props.useFiltersInstance?.undoWorkingFilters();\n isDrawerOpen.value = false;\n emit('dismiss');\n }\n\n watch(isDrawerOpen, () => {\n if (isDrawerOpen.value) {\n emit('open-drawer');\n }\n });\n</script>\n\n<template>\n <Box\n class=\"stash-data-view-filters grid grid-cols-12 gap-6 p-3\"\n :class=\"{ 'lg:p-6': density === 'comfortable', 'mb-3': !isWithinModule }\"\n :radius=\"isWithinModule ? 'none' : 'rounded'\"\n data-test=\"stash-data-view-filters\"\n disable-padding\n >\n <SearchBar\n v-if=\"props.showSearch\"\n class=\"col-span-12 md:col-span-6 lg:col-span-4\"\n data-test=\"stash-data-view-filters|search-bar\"\n :is-loading=\"isDataViewLoading\"\n :label=\"t('ll.search')\"\n :model-value=\"currentSearch\"\n v-bind=\"props.searchBarProps\"\n @search=\"(searchTerm) => updateCurrentSearch(searchTerm, { shouldEmit: true })\"\n />\n <div\n v-if=\"slots.default\"\n class=\"col-span-12 row-start-2 md:col-start-7 md:row-start-1 lg:col-span-8 lg:col-start-5\"\n >\n <div class=\"hidden md:block\">\n <slot name=\"filters-label\">\n <Label>{{ props.filtersLabelText }}</Label>\n </slot>\n </div>\n <div class=\"flex gap-4\">\n <FilterChip\n secondary\n class=\"!md:inline-flex !flex w-full justify-center gap-4 md:w-auto\"\n data-test=\"stash-data-view-filters|drawer-toggle-button\"\n :filter-count=\"totalActiveFiltersCount\"\n @click=\"isDrawerOpen = true\"\n >\n <span class=\"inline-flex items-center gap-3\">\n <Icon name=\"filter-line\" class=\"text-ice-700\" />\n <span>{{ t('ll.filters') }}</span>\n </span>\n </FilterChip>\n <slot v-if=\"isDesktop\"></slot>\n <Button v-if=\"totalActiveFiltersCount > 0 && isDesktop\" inline @click=\"handleResetAllClick\">\n {{ t('ll.resetAll') }}\n </Button>\n </div>\n </div>\n <Modal\n v-if=\"slots.drawer\"\n data-test=\"stash-data-view-filters|drawer\"\n disable-body-padding\n position=\"right\"\n size=\"narrow\"\n :is-open=\"isDrawerOpen\"\n :title=\"t('ll.allFilters')\"\n v-bind=\"props.drawerProps\"\n @dismiss=\"onDismiss\"\n >\n <template #headerAction>\n <Button\n v-if=\"isViewingSingleGroup\"\n icon\n class=\"text-ice-100\"\n data-test=\"stash-data-view-filters|drawer-previous-button\"\n :aria-label=\"t('ll.previous')\"\n :title=\"t('ll.previous')\"\n @click=\"emit('previous')\"\n >\n <Icon name=\"chevron-left\" />\n </Button>\n </template>\n\n <slot name=\"drawer\"></slot>\n\n <template #footer>\n <div class=\"flex justify-end gap-gutter\">\n <Button v-if=\"totalActiveFiltersCount === 0\" secondary @click=\"onDismiss\">\n {{ t('ll.cancel') }}\n </Button>\n <Button\n v-if=\"(isViewingGroupsMenu || props.drawerStyle === 'cascade') && totalActiveFiltersCount > 0\"\n secondary\n :disabled=\"isDataViewLoading\"\n @click=\"handleResetAllClick\"\n >\n {{ t('ll.resetAll') }}\n </Button>\n <Button\n v-if=\"isViewingSingleGroup && activeGroupActiveFiltersCount > 0\"\n secondary\n :disabled=\"isDataViewLoading\"\n @click=\"handleResetGroupClick\"\n >\n {{ t('ll.reset') }}\n </Button>\n <Button\n v-if=\"isViewingSingleGroup || props.drawerStyle === 'cascade'\"\n :disabled=\"isDataViewLoading\"\n @click=\"handleApplyClick\"\n >\n {{ t('ll.apply') }}\n </Button>\n </div>\n </template>\n </Modal>\n </Box>\n</template>\n"],"names":["DrawerStyle","useFilters","schema","dataViewRef","appliedFilters","ref","workingFilters","filterName","dvRef","applyFilters","cloneDeep","resetAllFilters","resetFilterGroup","group","undoWorkingFilters","activeFiltersCounts","computed","counts","config","value","_a","isDefined","totalActiveFiltersCount","count","props","__props","emit","__emit","slots","_useSlots","isDesktop","useMediaQuery","SCREEN_SIZES","isViewingGroupsMenu","isViewingSingleGroup","density","isDataViewLoading","isWithinModule","currentSearch","updateCurrentSearch","inject","DATA_VIEW_INJECTION","provide","DATA_VIEW_FILTERS_UTILS_INJECTION","activeGroupActiveFiltersCount","isDrawerOpen","handleApplyClick","preventDismiss","_b","handleResetGroupClick","handleResetAllClick","onDismiss","watch","_createBlock","Box","_normalizeClass","_unref","_openBlock","SearchBar","_mergeProps","t","_cache","searchTerm","_createElementBlock","_hoisted_1","_createElementVNode","_hoisted_2","_renderSlot","_ctx","_createVNode","Label","_createTextVNode","_toDisplayString","_ho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B;AAAA,sBAAnBM,EAAAI,CAAA,EAAC,aAAA,CAAA,GAAA,CAAA;AAAA,gBAAA;;;cAGE1B,EAAA,SAAwBU,EAAA,QAA6B,UAD7DS,EAOSwB,GAAA;AAAA;gBALP,WAAA;AAAA,gBACC,UAAUrB,EAAApB,CAAA;AAAA,gBACV,SAAOa;AAAA,cAAA;2BAER,MAAmB;AAAA,sBAAhBO,EAAAI,CAAA,EAAC,UAAA,CAAA,GAAA,CAAA;AAAA,gBAAA;;;cAGE1B,EAAA,SAAwBV,EAAM,gBAAW,kBADjD6B,EAMSwB,GAAA;AAAA;gBAJN,UAAUrB,EAAApB,CAAA;AAAA,gBACV,SAAOU;AAAA,cAAA;2BAER,MAAmB;AAAA,sBAAhBU,EAAAI,CAAA,EAAC,UAAA,CAAA,GAAA,CAAA;AAAA,gBAAA;;;;;qBA5BV,MAA2B;AAAA,YAA3BO,EAA2BC,EAAA,QAAA,QAAA;AAAA,UAAA;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataViewSortButton.js","sources":["../src/components/DataViewSortButton/DataViewSortButton.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n import { inject, useCssModule } from 'vue';\n\n import { t } from '../../locale';\n import Button from '../Button/Button.vue';\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import Dropdown from '../Dropdown/Dropdown.vue';\n import Icon from '../Icon/Icon.vue';\n import IconLabel from '../IconLabel/IconLabel.vue';\n import { SortOption } from './DataViewSortButton.types';\n\n export interface DataViewToolbarProps {\n /**\n * An array of sort options to display in the dropdown.\n */\n sortOptions?: SortOption[];\n }\n\n const props = withDefaults(defineProps<DataViewToolbarProps>(), {\n sortOptions: () => [],\n });\n const classes = useCssModule();\n\n const { currentSortId, currentSortOrder, updateCurrentSort } = inject(\n DATA_VIEW_INJECTION.key,\n DATA_VIEW_INJECTION.defaults,\n );\n</script>\n\n<template>\n <Dropdown\n v-if=\"props.sortOptions.length\"\n align=\"left\"\n class=\"stash-data-view-sort-button\"\n data-test=\"stash-data-view-sort-button\"\n >\n <template #toggle=\"{ isActive, toggle }\">\n <Button\n icon-label\n :aria-expanded=\"isActive.toString()\"\n class=\"text-blue-500\"\n data-test=\"stash-data-view-sort-button|sort-menu-button\"\n @click=\"toggle\"\n >\n <IconLabel icon=\"sort\" stacked>\n {{ t('ll.sort') }}\n </IconLabel>\n </Button>\n </template>\n <ul class=\"dropdown__list\" data-test=\"stash-data-view-sort-button|sort-menu\">\n <template v-for=\"sortOption in props.sortOptions\" :key=\"sortOption.id\">\n <li\n class=\"dropdown__item rounded\"\n :class=\"[\n classes.dropdown__item,\n { 'bg-blue-100 text-ice-700': sortOption.id === currentSortId && currentSortOrder === 'asc' },\n ]\"\n @click=\"() => updateCurrentSort(sortOption.id, { sortOrder: 'asc', shouldEmit: true })\"\n >\n <Button inline class=\"h-9\">\n {{ sortOption.labelAsc }}\n <Icon\n v-if=\"sortOption.id === currentSortId && currentSortOrder === 'asc'\"\n name=\"check\"\n class=\"ml-auto text-blue-500\"\n />\n </Button>\n </li>\n <li\n class=\"dropdown__item rounded\"\n :class=\"[\n classes.dropdown__item,\n { 'bg-blue-100 text-ice-700': sortOption.id === currentSortId && currentSortOrder === 'desc' },\n ]\"\n @click=\"() => updateCurrentSort(sortOption.id, { sortOrder: 'desc', shouldEmit: true })\"\n >\n <Button inline class=\"h-9\">\n {{ sortOption.labelDesc }}\n <Icon\n v-if=\"sortOption.id === currentSortId && currentSortOrder === 'desc'\"\n name=\"check\"\n class=\"ml-auto text-blue-500\"\n />\n </Button>\n </li>\n </template>\n </ul>\n </Dropdown>\n</template>\n\n<style module>\n @layer utilities {\n .dropdown__item > button {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n }\n</style>\n"],"names":["props","__props","classes","useCssModule","currentSortId","currentSortOrder","updateCurrentSort","inject","DATA_VIEW_INJECTION"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBE,UAAMA,IAAQC,GAGRC,IAAUC,EAAA,GAEV,EAAE,eAAAC,GAAe,kBAAAC,GAAkB,mBAAAC,EAAA,IAAsBC;AAAA,MAC7DC,EAAoB;AAAA,MACpBA,EAAoB;AAAA,IAAA
|
|
1
|
+
{"version":3,"file":"DataViewSortButton.js","sources":["../src/components/DataViewSortButton/DataViewSortButton.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n import { inject, useCssModule } from 'vue';\n\n import { t } from '../../locale';\n import Button from '../Button/Button.vue';\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import Dropdown from '../Dropdown/Dropdown.vue';\n import Icon from '../Icon/Icon.vue';\n import IconLabel from '../IconLabel/IconLabel.vue';\n import { SortOption } from './DataViewSortButton.types';\n\n export interface DataViewToolbarProps {\n /**\n * An array of sort options to display in the dropdown.\n */\n sortOptions?: SortOption[];\n }\n\n const props = withDefaults(defineProps<DataViewToolbarProps>(), {\n sortOptions: () => [],\n });\n const classes = useCssModule();\n\n const { currentSortId, currentSortOrder, updateCurrentSort } = inject(\n DATA_VIEW_INJECTION.key,\n DATA_VIEW_INJECTION.defaults,\n );\n</script>\n\n<template>\n <Dropdown\n v-if=\"props.sortOptions.length\"\n align=\"left\"\n class=\"stash-data-view-sort-button\"\n data-test=\"stash-data-view-sort-button\"\n >\n <template #toggle=\"{ isActive, toggle }\">\n <Button\n icon-label\n :aria-expanded=\"isActive.toString()\"\n class=\"text-blue-500\"\n data-test=\"stash-data-view-sort-button|sort-menu-button\"\n @click=\"toggle\"\n >\n <IconLabel icon=\"sort\" stacked>\n {{ t('ll.sort') }}\n </IconLabel>\n </Button>\n </template>\n <ul class=\"dropdown__list\" data-test=\"stash-data-view-sort-button|sort-menu\">\n <template v-for=\"sortOption in props.sortOptions\" :key=\"sortOption.id\">\n <li\n class=\"dropdown__item rounded\"\n :class=\"[\n classes.dropdown__item,\n { 'bg-blue-100 text-ice-700': sortOption.id === currentSortId && currentSortOrder === 'asc' },\n ]\"\n @click=\"() => updateCurrentSort(sortOption.id, { sortOrder: 'asc', shouldEmit: true })\"\n >\n <Button inline class=\"h-9\">\n {{ sortOption.labelAsc }}\n <Icon\n v-if=\"sortOption.id === currentSortId && currentSortOrder === 'asc'\"\n name=\"check\"\n class=\"ml-auto text-blue-500\"\n />\n </Button>\n </li>\n <li\n class=\"dropdown__item rounded\"\n :class=\"[\n classes.dropdown__item,\n { 'bg-blue-100 text-ice-700': sortOption.id === currentSortId && currentSortOrder === 'desc' },\n ]\"\n @click=\"() => updateCurrentSort(sortOption.id, { sortOrder: 'desc', shouldEmit: true })\"\n >\n <Button inline class=\"h-9\">\n {{ sortOption.labelDesc }}\n <Icon\n v-if=\"sortOption.id === currentSortId && currentSortOrder === 'desc'\"\n name=\"check\"\n class=\"ml-auto text-blue-500\"\n />\n </Button>\n </li>\n </template>\n </ul>\n </Dropdown>\n</template>\n\n<style module>\n @layer utilities {\n .dropdown__item > button {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n }\n</style>\n"],"names":["props","__props","classes","useCssModule","currentSortId","currentSortOrder","updateCurrentSort","inject","DATA_VIEW_INJECTION","_createBlock","Dropdown","_withCtx","isActive","toggle","_createVNode","Button","IconLabel","_unref","t","_createElementVNode","_hoisted_1","_openBlock","_createElementBlock","_Fragment","_renderList","sortOption","Icon"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBE,UAAMA,IAAQC,GAGRC,IAAUC,EAAA,GAEV,EAAE,eAAAC,GAAe,kBAAAC,GAAkB,mBAAAC,EAAA,IAAsBC;AAAA,MAC7DC,EAAoB;AAAA,MACpBA,EAAoB;AAAA,IAAA;qBAMdR,EAAM,YAAY,eAD1BS,EAyDWC,GAAA;AAAA;MAvDT,OAAM;AAAA,MACN,OAAM;AAAA,MACN,aAAU;AAAA,IAAA;MAEC,QAAMC,EACf,CAUS,EAXU,UAAAC,GAAU,QAAAC,QAAM;AAAA,QACnCC,EAUSC,GAAA;AAAA,UATP,cAAA;AAAA,UACC,iBAAeH,EAAS,SAAA;AAAA,UACzB,OA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AA;AAAA,YAAA;cAE7CX,EAOSC,GAAA;AAAA,gBAPD,QAAA;AAAA,gBAAO,OAAM;AAAA,cAAA;2BACnB,MAA0B;AAAA,sBAAvBU,EAAW,SAAS,IAAG,KAC1B,CAAA;AAAA,kBACQA,EAAW,OAAOR,EAAAb,CAAA,KAAiBa,EAAAZ,CAAA,MAAgB,eAD3DI,EAIEiB,GAAA;AAAA;oBAFA,MAAK;AAAA,oBACL,OAAM;AAAA,kBAAA;;;;;;;;;;;;;;;;"}
|
package/dist/DataViewToolbar.js
CHANGED
|
@@ -148,14 +148,14 @@ const ue = { class: "flex place-items-center" }, pe = {
|
|
|
148
148
|
icon: "ellipsis",
|
|
149
149
|
stacked: ""
|
|
150
150
|
}, {
|
|
151
|
-
default: r(() => f[2] || (f[2] = [
|
|
152
|
-
ae(" More ")
|
|
153
|
-
])),
|
|
151
|
+
default: r(() => [...f[2] || (f[2] = [
|
|
152
|
+
ae(" More ", -1)
|
|
153
|
+
])]),
|
|
154
154
|
_: 1
|
|
155
155
|
})
|
|
156
156
|
]),
|
|
157
|
-
_:
|
|
158
|
-
},
|
|
157
|
+
_: 1
|
|
158
|
+
}, 8, ["onClick"])
|
|
159
159
|
]),
|
|
160
160
|
"more-actions": r(() => [
|
|
161
161
|
R(m.$slots, "more-actions")
|
|
@@ -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"],"mappings":";;;;;;;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AA,GAEV,EAAE,cAAA5C,EAAA,IAAiBR,GAAgB;AAAA,MACvC,WAAWgC;AAAA,MACX,cAAcE;AAAA,MACd,YAAYC;AAAA,MACZ,qBAAA9B;AAAA,MACA,cAAAC;AAAA,MACA,SAAAC;AAAA,IAAA,CACD,GAEK8C,IAAiBC,GAA0B,MAC3C1B,EAAM,SACDA,EAAM,SAGXQ,EAAe,QACV,SAGLC,EAAgB,UAAU,UACxBT,EAAM,eACD,sBAGF,gBAGF,SACR,GAEK2B,IAAYC,GAAmB,EAAE,aAAAjB,GAAa,UAAAI,GAAU,YAAYC,GAAgB;AAE1F,aAASa,IAAW;AAClB,MAAA3B,EAAK,QAAQ,GAOboB,EAAY;AAAA,IACd;AAEA,WAAAQ,GAAc,MAAM;AAClB,MAAIlB,MACFA,EAAW,QAAQ;AAAA,IAEvB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
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","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