@leaflink/stash 43.0.1 → 43.2.0
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/DataViewFilters.js +67 -66
- package/dist/DataViewFilters.js.map +1 -1
- package/dist/DataViewFilters.vue.d.ts +8 -0
- package/dist/FilterDrawerItem.js +55 -39
- package/dist/FilterDrawerItem.js.map +1 -1
- package/dist/FilterDrawerItem.vue.d.ts +12 -2
- package/dist/PageNavigation.js +84 -341
- package/dist/PageNavigation.js.map +1 -1
- package/dist/PageNavigation.vue.d.ts +76 -163
- package/dist/Step.vue.d.ts +1 -1
- package/dist/Tab.js +5 -87
- package/dist/Tab.js.map +1 -1
- package/dist/Tab.vue_vue_type_script_setup_true_lang-b810bee8.js +90 -0
- package/dist/Tab.vue_vue_type_script_setup_true_lang-b810bee8.js.map +1 -0
- package/dist/Tabs.js +9 -6
- package/dist/Tabs.js.map +1 -1
- package/dist/Tabs.vue_used_vue_type_style_index_0_lang.module-4f247ed7.js +156 -0
- package/dist/Tabs.vue_used_vue_type_style_index_0_lang.module-4f247ed7.js.map +1 -0
- package/dist/components.css +1 -1
- package/dist/locale.js +8 -7
- package/dist/locale.js.map +1 -1
- package/package.json +1 -1
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-56e85faa.js +0 -154
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-56e85faa.js.map +0 -1
package/dist/DataViewFilters.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref as x, computed as
|
|
1
|
+
import { ref as x, computed as S, defineComponent as R, useSlots as W, inject as j, provide as M, watch as O, openBlock as c, createBlock as v, normalizeClass as J, unref as t, withCtx as o, mergeProps as P, createCommentVNode as f, createElementBlock as z, createElementVNode as C, renderSlot as V, createVNode as I, createTextVNode as h, toDisplayString as _ } from "vue";
|
|
2
2
|
import Q from "./useMediaQuery.js";
|
|
3
3
|
import { SCREEN_SIZES as U } from "./constants.js";
|
|
4
4
|
import { t as n } from "./locale.js";
|
|
@@ -28,53 +28,53 @@ import "lodash-es/isNil";
|
|
|
28
28
|
import "./utils/i18n.js";
|
|
29
29
|
import "./Field.vue_vue_type_script_setup_true_lang-475832fe.js";
|
|
30
30
|
function Pe({
|
|
31
|
-
schema:
|
|
31
|
+
schema: a,
|
|
32
32
|
dataViewRef: w
|
|
33
33
|
}) {
|
|
34
34
|
const e = x({}), u = x({});
|
|
35
|
-
for (const l in
|
|
36
|
-
e.value[l] =
|
|
37
|
-
const
|
|
38
|
-
function
|
|
39
|
-
e.value = T(u.value),
|
|
35
|
+
for (const l in a)
|
|
36
|
+
e.value[l] = a[l].defaultValue, u.value[l] = a[l].defaultValue;
|
|
37
|
+
const y = w;
|
|
38
|
+
function D() {
|
|
39
|
+
e.value = T(u.value), y.value.updateCurrentFilters(e.value, { shouldEmit: !0 });
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
for (const l in
|
|
43
|
-
e.value[l] =
|
|
44
|
-
|
|
41
|
+
function F() {
|
|
42
|
+
for (const l in a)
|
|
43
|
+
e.value[l] = a[l].defaultValue, u.value[l] = a[l].defaultValue;
|
|
44
|
+
y.value.updateCurrentFilters(e.value, { shouldEmit: !0 });
|
|
45
45
|
}
|
|
46
46
|
function b(l) {
|
|
47
|
-
for (const r in
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
for (const r in a)
|
|
48
|
+
a[r].group === l && (e.value[r] = a[r].defaultValue, u.value[r] = a[r].defaultValue);
|
|
49
|
+
y.value.updateCurrentFilters(e.value, { shouldEmit: !0 });
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function B() {
|
|
52
52
|
u.value = T(e.value);
|
|
53
53
|
}
|
|
54
|
-
const
|
|
54
|
+
const E = S(() => {
|
|
55
55
|
var r;
|
|
56
56
|
const l = {};
|
|
57
|
-
for (const m in
|
|
58
|
-
const
|
|
59
|
-
(((r =
|
|
57
|
+
for (const m in a) {
|
|
58
|
+
const i = a[m], p = e.value[m];
|
|
59
|
+
(((r = i.isActive) == null ? void 0 : r.call(i, p)) || L(p)) && i.group && (l[i.group] = (l[i.group] ?? 0) + 1);
|
|
60
60
|
}
|
|
61
61
|
return l;
|
|
62
|
-
}), k =
|
|
62
|
+
}), k = S(() => {
|
|
63
63
|
var r;
|
|
64
64
|
let l = 0;
|
|
65
|
-
for (const m in
|
|
66
|
-
const
|
|
67
|
-
(((r =
|
|
65
|
+
for (const m in a) {
|
|
66
|
+
const i = a[m], p = e.value[m];
|
|
67
|
+
(((r = i.isActive) == null ? void 0 : r.call(i, p)) || L(p)) && (l += 1);
|
|
68
68
|
}
|
|
69
69
|
return l;
|
|
70
70
|
});
|
|
71
71
|
return {
|
|
72
|
-
applyFilters:
|
|
73
|
-
resetAllFilters:
|
|
72
|
+
applyFilters: D,
|
|
73
|
+
resetAllFilters: F,
|
|
74
74
|
// @ts-expect-error "could be instantiated with a different subtype": TODO: figure out how to resolve the types
|
|
75
75
|
resetFilterGroup: b,
|
|
76
|
-
undoWorkingFilters:
|
|
77
|
-
activeFiltersCounts:
|
|
76
|
+
undoWorkingFilters: B,
|
|
77
|
+
activeFiltersCounts: E,
|
|
78
78
|
totalActiveFiltersCount: k,
|
|
79
79
|
appliedFilters: e,
|
|
80
80
|
workingFilters: u
|
|
@@ -89,6 +89,7 @@ const ee = {
|
|
|
89
89
|
filtersLabelText: { default: n("ll.filterBy") },
|
|
90
90
|
searchBarProps: { default: void 0 },
|
|
91
91
|
showSearch: { type: Boolean, default: !0 },
|
|
92
|
+
drawerStyle: { default: "nested" },
|
|
92
93
|
drawerProps: { default: void 0 },
|
|
93
94
|
showDrawerPreviousButton: { type: Boolean, default: !1 },
|
|
94
95
|
useFiltersInstance: { default: void 0 },
|
|
@@ -96,45 +97,45 @@ const ee = {
|
|
|
96
97
|
activeGroup: { default: "" }
|
|
97
98
|
},
|
|
98
99
|
emits: ["open-drawer", "dismiss", "previous", "reset-group", "reset-all"],
|
|
99
|
-
setup(
|
|
100
|
-
const e =
|
|
101
|
-
density:
|
|
102
|
-
isLoading:
|
|
100
|
+
setup(a, { emit: w }) {
|
|
101
|
+
const e = a, u = W(), y = Q(`(min-width: ${U.lg})`), {
|
|
102
|
+
density: D,
|
|
103
|
+
isLoading: F,
|
|
103
104
|
isWithinModule: b,
|
|
104
|
-
currentSearch:
|
|
105
|
-
updateCurrentSearch:
|
|
105
|
+
currentSearch: B,
|
|
106
|
+
updateCurrentSearch: E
|
|
106
107
|
} = j(G.key, G.defaults);
|
|
107
|
-
M(Y.key, { useFiltersInstance: e.useFiltersInstance });
|
|
108
|
-
const k =
|
|
108
|
+
M(Y.key, { useFiltersInstance: e.useFiltersInstance, drawerStyle: e.drawerStyle });
|
|
109
|
+
const k = S(() => {
|
|
109
110
|
var s;
|
|
110
111
|
return ((s = e.useFiltersInstance) == null ? void 0 : s.totalActiveFiltersCount.value) ?? 0;
|
|
111
|
-
}), l =
|
|
112
|
+
}), l = S(
|
|
112
113
|
() => {
|
|
113
114
|
var s;
|
|
114
115
|
return ((s = e.useFiltersInstance) == null ? void 0 : s.activeFiltersCounts.value[e.activeGroup]) ?? 0;
|
|
115
116
|
}
|
|
116
117
|
), r = x(!1);
|
|
117
118
|
async function m() {
|
|
118
|
-
var d,
|
|
119
|
-
const { preventDismiss: s } = await ((d = e.onApply) == null ? void 0 : d.call(e)) || ((
|
|
119
|
+
var d, g;
|
|
120
|
+
const { preventDismiss: s } = await ((d = e.onApply) == null ? void 0 : d.call(e)) || ((g = e.useFiltersInstance) == null ? void 0 : g.applyFilters()) || {};
|
|
120
121
|
s || (r.value = !1);
|
|
121
122
|
}
|
|
122
|
-
function
|
|
123
|
+
function i() {
|
|
123
124
|
var s;
|
|
124
125
|
(s = e.useFiltersInstance) == null || s.resetFilterGroup(e.activeGroup), w("reset-group"), r.value = !1;
|
|
125
126
|
}
|
|
126
|
-
function
|
|
127
|
+
function p() {
|
|
127
128
|
var s;
|
|
128
129
|
(s = e.useFiltersInstance) == null || s.resetAllFilters(), w("reset-all"), r.value = !1;
|
|
129
130
|
}
|
|
130
|
-
function
|
|
131
|
+
function N() {
|
|
131
132
|
var s;
|
|
132
133
|
(s = e.useFiltersInstance) == null || s.undoWorkingFilters(), r.value = !1, w("dismiss");
|
|
133
134
|
}
|
|
134
135
|
return O(r, () => {
|
|
135
136
|
r.value && w("open-drawer");
|
|
136
137
|
}), (s, d) => (c(), v(Z, {
|
|
137
|
-
class: J(["stash-data-view-filters tw-grid tw-grid-cols-12 tw-p-3 tw-gap-6", { "lg:tw-p-6": t(
|
|
138
|
+
class: J(["stash-data-view-filters tw-grid tw-grid-cols-12 tw-p-3 tw-gap-6", { "lg:tw-p-6": t(D) === "comfortable", "tw-mb-3": !t(b) }]),
|
|
138
139
|
radius: t(b) ? "none" : "rounded",
|
|
139
140
|
"data-test": "stash-data-view-filters",
|
|
140
141
|
"disable-padding": ""
|
|
@@ -144,12 +145,12 @@ const ee = {
|
|
|
144
145
|
key: 0,
|
|
145
146
|
class: "tw-col-span-12 md:tw-col-span-6 lg:tw-col-span-4",
|
|
146
147
|
"data-test": "stash-data-view-filters|search-bar",
|
|
147
|
-
"is-loading": t(
|
|
148
|
+
"is-loading": t(F),
|
|
148
149
|
label: t(n)("ll.search"),
|
|
149
|
-
"model-value": t(
|
|
150
|
+
"model-value": t(B)
|
|
150
151
|
}, e.searchBarProps, {
|
|
151
|
-
onSearch: d[0] || (d[0] = (
|
|
152
|
-
}), null, 16, ["is-loading", "label", "model-value"])) :
|
|
152
|
+
onSearch: d[0] || (d[0] = (g) => t(E)(g, { shouldEmit: !0 }))
|
|
153
|
+
}), null, 16, ["is-loading", "label", "model-value"])) : f("", !0),
|
|
153
154
|
t(u).default ? (c(), z("div", ee, [
|
|
154
155
|
C("div", te, [
|
|
155
156
|
V(s.$slots, "filters-label", {}, () => [
|
|
@@ -167,7 +168,7 @@ const ee = {
|
|
|
167
168
|
class: "!tw-flex tw-w-full tw-justify-center tw-gap-4 md:!tw-inline-flex md:tw-w-auto",
|
|
168
169
|
"data-test": "stash-data-view-filters|drawer-toggle-button",
|
|
169
170
|
"filter-count": k.value,
|
|
170
|
-
onClick: d[1] || (d[1] = (
|
|
171
|
+
onClick: d[1] || (d[1] = (g) => r.value = !0)
|
|
171
172
|
}, {
|
|
172
173
|
default: o(() => [
|
|
173
174
|
C("span", re, [
|
|
@@ -180,19 +181,19 @@ const ee = {
|
|
|
180
181
|
]),
|
|
181
182
|
_: 1
|
|
182
183
|
}, 8, ["filter-count"]),
|
|
183
|
-
t(
|
|
184
|
-
k.value > 0 && t(
|
|
184
|
+
t(y) ? V(s.$slots, "default", { key: 0 }) : f("", !0),
|
|
185
|
+
k.value > 0 && t(y) ? (c(), v(A, {
|
|
185
186
|
key: 1,
|
|
186
187
|
inline: "",
|
|
187
|
-
onClick:
|
|
188
|
+
onClick: p
|
|
188
189
|
}, {
|
|
189
190
|
default: o(() => [
|
|
190
191
|
h(_(t(n)("ll.resetAll")), 1)
|
|
191
192
|
]),
|
|
192
193
|
_: 1
|
|
193
|
-
})) :
|
|
194
|
+
})) : f("", !0)
|
|
194
195
|
])
|
|
195
|
-
])) :
|
|
196
|
+
])) : f("", !0),
|
|
196
197
|
t(u).drawer ? (c(), v(K, P({
|
|
197
198
|
key: 2,
|
|
198
199
|
"data-test": "stash-data-view-filters|drawer",
|
|
@@ -200,7 +201,7 @@ const ee = {
|
|
|
200
201
|
position: "right",
|
|
201
202
|
"is-open": r.value,
|
|
202
203
|
title: t(n)("ll.allFilters")
|
|
203
|
-
}, e.drawerProps, { onDismiss:
|
|
204
|
+
}, e.drawerProps, { onDismiss: N }), {
|
|
204
205
|
headerAction: o(() => [
|
|
205
206
|
e.showDrawerPreviousButton ? (c(), v(A, {
|
|
206
207
|
key: 0,
|
|
@@ -209,55 +210,55 @@ const ee = {
|
|
|
209
210
|
"data-test": "stash-data-view-filters|drawer-previous-button",
|
|
210
211
|
"aria-label": t(n)("ll.previous"),
|
|
211
212
|
title: t(n)("ll.previous"),
|
|
212
|
-
onClick: d[2] || (d[2] = (
|
|
213
|
+
onClick: d[2] || (d[2] = (g) => w("previous"))
|
|
213
214
|
}, {
|
|
214
215
|
default: o(() => [
|
|
215
216
|
I($, { name: "chevron-left" })
|
|
216
217
|
]),
|
|
217
218
|
_: 1
|
|
218
|
-
}, 8, ["aria-label", "title"])) :
|
|
219
|
+
}, 8, ["aria-label", "title"])) : f("", !0)
|
|
219
220
|
]),
|
|
220
221
|
footer: o(() => [
|
|
221
222
|
C("div", se, [
|
|
222
223
|
!e.showDrawerPreviousButton && k.value > 0 ? (c(), v(A, {
|
|
223
224
|
key: 0,
|
|
224
225
|
secondary: "",
|
|
225
|
-
disabled: t(
|
|
226
|
-
onClick:
|
|
226
|
+
disabled: t(F),
|
|
227
|
+
onClick: p
|
|
227
228
|
}, {
|
|
228
229
|
default: o(() => [
|
|
229
230
|
h(_(t(n)("ll.resetAll")), 1)
|
|
230
231
|
]),
|
|
231
232
|
_: 1
|
|
232
|
-
}, 8, ["disabled"])) :
|
|
233
|
-
e.showDrawerPreviousButton && l.value > 0 ? (c(), v(A, {
|
|
233
|
+
}, 8, ["disabled"])) : f("", !0),
|
|
234
|
+
(e.showDrawerPreviousButton || e.drawerStyle === "cascade") && l.value > 0 ? (c(), v(A, {
|
|
234
235
|
key: 1,
|
|
235
236
|
secondary: "",
|
|
236
|
-
disabled: t(
|
|
237
|
-
onClick:
|
|
237
|
+
disabled: t(F),
|
|
238
|
+
onClick: i
|
|
238
239
|
}, {
|
|
239
240
|
default: o(() => [
|
|
240
241
|
h(_(t(n)("ll.reset")), 1)
|
|
241
242
|
]),
|
|
242
243
|
_: 1
|
|
243
|
-
}, 8, ["disabled"])) :
|
|
244
|
-
e.showDrawerPreviousButton ? (c(), v(A, {
|
|
244
|
+
}, 8, ["disabled"])) : f("", !0),
|
|
245
|
+
e.showDrawerPreviousButton || e.drawerStyle === "cascade" ? (c(), v(A, {
|
|
245
246
|
key: 2,
|
|
246
|
-
disabled: t(
|
|
247
|
+
disabled: t(F),
|
|
247
248
|
onClick: m
|
|
248
249
|
}, {
|
|
249
250
|
default: o(() => [
|
|
250
251
|
h(_(t(n)("ll.apply")), 1)
|
|
251
252
|
]),
|
|
252
253
|
_: 1
|
|
253
|
-
}, 8, ["disabled"])) :
|
|
254
|
+
}, 8, ["disabled"])) : f("", !0)
|
|
254
255
|
])
|
|
255
256
|
]),
|
|
256
257
|
default: o(() => [
|
|
257
258
|
V(s.$slots, "drawer")
|
|
258
259
|
]),
|
|
259
260
|
_: 3
|
|
260
|
-
}, 16, ["is-open", "title"])) :
|
|
261
|
+
}, 16, ["is-open", "title"])) : f("", !0)
|
|
261
262
|
]),
|
|
262
263
|
_: 3
|
|
263
264
|
}, 8, ["class", "radius"]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataViewFilters.js","sources":["../src/components/DataViewFilters/useFilters.ts","../src/components/DataViewFilters/DataViewFilters.vue"],"sourcesContent":["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 { 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 drawerProps?: ModalProps;\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 /** The name of the active filter group. The active filter group is determined by which instance of FilterDropdown or FilterDrawerItem is open. */\n activeGroup?: string;\n }\n\n export interface DataViewFiltersSlots {\n default?: void;\n drawer?: void;\n 'filters-label'?: void;\n }\n\n const props = withDefaults(defineProps<DataViewFiltersProps>(), {\n filtersLabelText: t('ll.filterBy'),\n isLoading: false,\n drawerProps: undefined,\n searchBarProps: undefined,\n showDrawerPreviousButton: false,\n showSearch: true,\n useFiltersInstance: undefined,\n onApply: undefined,\n activeGroup: '',\n });\n\n const emit =\n 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\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, { useFiltersInstance: props.useFiltersInstance });\n\n const totalActiveFiltersCount = computed(() => props.useFiltersInstance?.totalActiveFiltersCount.value ?? 0);\n const activeGroupActiveFiltersCount = computed(\n () => 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 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 tw-grid tw-grid-cols-12 tw-p-3 tw-gap-6\"\n :class=\"{ 'lg:tw-p-6': density === 'comfortable', 'tw-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=\"tw-col-span-12 md:tw-col-span-6 lg:tw-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=\"tw-col-span-12 tw-row-start-2 md:tw-row-start-1 md:tw-col-start-7 lg:tw-col-start-5 lg:tw-col-span-8\"\n >\n <div class=\"tw-hidden md:tw-block\">\n <slot name=\"filters-label\">\n <Label>{{ props.filtersLabelText }}</Label>\n </slot>\n </div>\n <div class=\"tw-flex tw-gap-4\">\n <FilterChip\n secondary\n class=\"!tw-flex tw-w-full tw-justify-center tw-gap-4 md:!tw-inline-flex md:tw-w-auto\"\n data-test=\"stash-data-view-filters|drawer-toggle-button\"\n :filter-count=\"totalActiveFiltersCount\"\n @click=\"isDrawerOpen = true\"\n >\n <span class=\"tw-inline-flex tw-items-center tw-gap-3\">\n <Icon name=\"filter-line\" class=\"tw-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 :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=\"props.showDrawerPreviousButton\"\n icon\n class=\"tw-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=\"tw-flex tw-flex-col-reverse lg:tw-flex-row lg:tw-justify-end tw-gap-gutter\">\n <Button\n v-if=\"!props.showDrawerPreviousButton && totalActiveFiltersCount > 0\"\n secondary\n :disabled=\"isDataViewLoading\"\n @click=\"handleResetAllClick\"\n >\n {{ t('ll.resetAll') }}\n </Button>\n <Button\n v-if=\"props.showDrawerPreviousButton && activeGroupActiveFiltersCount > 0\"\n secondary\n :disabled=\"isDataViewLoading\"\n @click=\"handleResetGroupClick\"\n >\n {{ t('ll.reset') }}\n </Button>\n <Button v-if=\"props.showDrawerPreviousButton\" :disabled=\"isDataViewLoading\" @click=\"handleApplyClick\">\n {{ t('ll.apply') }}\n </Button>\n </div>\n </template>\n </Modal>\n </Box>\n</template>\n"],"names":["useFilters","schema","dataViewRef","appliedFilters","ref","workingFilters","filterName","dvRef","applyFilters","cloneDeep","resetAllFilters","resetFilterGroup","group","undoWorkingFilters","activeFiltersCounts","computed","counts","config","value","_a","isDefined","totalActiveFiltersCount","count","slots","_useSlots","isDesktop","useMediaQuery","SCREEN_SIZES","density","isDataViewLoading","isWithinModule","currentSearch","updateCurrentSearch","inject","DATA_VIEW_INJECTION","provide","DATA_VIEW_FILTERS_UTILS_INJECTION","props","activeGroupActiveFiltersCount","isDrawerOpen","handleApplyClick","preventDismiss","_b","handleResetGroupClick","emit","handleResetAllClick","onDismiss","watch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCO,SAASA,GAAyD;AAAA,EACvE,QAAAC;AAAA,EACA,aAAAC;AACF,GAAyE;AACjE,QAAAC,IAAiBC,EAAI,CAAA,CAAE,GACvBC,IAAiBD,EAAI,CAAA,CAAE;AAE7B,aAAWE,KAAcL;AAEvB,IAAAE,EAAe,MAAMG,CAAU,IAAIL,EAAOK,CAAU,EAAE,cAEtDD,EAAe,MAAMC,CAAU,IAAIL,EAAOK,CAAU,EAAE;AAGxD,QAAMC,IAAQL;AAQd,WAASM,IAAe;AACP,IAAAL,EAAA,QAAQM,EAAUJ,EAAe,KAAK,GACrDE,EAAM,MAAM,qBAAqBJ,EAAe,OAAO,EAAE,YAAY,IAAM;AAAA,EAC7E;AAQA,WAASO,IAAkB;AACzB,eAAWJ,KAAcL;AAEvB,MAAAE,EAAe,MAAMG,CAAU,IAAIL,EAAOK,CAAU,EAAE,cAEtDD,EAAe,MAAMC,CAAU,IAAIL,EAAOK,C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SAAS;AAAA,IAChB;AAEA,WAAAG,EAAMR,GAAc,MAAM;AACxB,MAAIA,EAAa,SACfK,EAAK,aAAa;AAAA,IACpB,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"DataViewFilters.js","sources":["../src/components/DataViewFilters/useFilters.ts","../src/components/DataViewFilters/DataViewFilters.vue"],"sourcesContent":["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 { DrawerStyle, 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?: DrawerStyle;\n drawerProps?: ModalProps;\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 /** The name of the active filter group. The active filter group is determined by which instance of FilterDropdown or FilterDrawerItem is open. */\n activeGroup?: string;\n }\n\n export interface DataViewFiltersSlots {\n default?: void;\n drawer?: void;\n 'filters-label'?: void;\n }\n\n const props = withDefaults(defineProps<DataViewFiltersProps>(), {\n filtersLabelText: t('ll.filterBy'),\n isLoading: false,\n drawerStyle: 'nested',\n drawerProps: undefined,\n searchBarProps: undefined,\n showDrawerPreviousButton: false,\n showSearch: true,\n useFiltersInstance: undefined,\n onApply: undefined,\n activeGroup: '',\n });\n\n const emit =\n 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\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, { useFiltersInstance: props.useFiltersInstance, drawerStyle: props.drawerStyle});\n\n const totalActiveFiltersCount = computed(() => props.useFiltersInstance?.totalActiveFiltersCount.value ?? 0);\n const activeGroupActiveFiltersCount = computed(\n () => 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 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 tw-grid tw-grid-cols-12 tw-p-3 tw-gap-6\"\n :class=\"{ 'lg:tw-p-6': density === 'comfortable', 'tw-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=\"tw-col-span-12 md:tw-col-span-6 lg:tw-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=\"tw-col-span-12 tw-row-start-2 md:tw-row-start-1 md:tw-col-start-7 lg:tw-col-start-5 lg:tw-col-span-8\"\n >\n <div class=\"tw-hidden md:tw-block\">\n <slot name=\"filters-label\">\n <Label>{{ props.filtersLabelText }}</Label>\n </slot>\n </div>\n <div class=\"tw-flex tw-gap-4\">\n <FilterChip\n secondary\n class=\"!tw-flex tw-w-full tw-justify-center tw-gap-4 md:!tw-inline-flex md:tw-w-auto\"\n data-test=\"stash-data-view-filters|drawer-toggle-button\"\n :filter-count=\"totalActiveFiltersCount\"\n @click=\"isDrawerOpen = true\"\n >\n <span class=\"tw-inline-flex tw-items-center tw-gap-3\">\n <Icon name=\"filter-line\" class=\"tw-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 :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=\"props.showDrawerPreviousButton\"\n icon\n class=\"tw-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=\"tw-flex tw-flex-col-reverse lg:tw-flex-row lg:tw-justify-end tw-gap-gutter\">\n <Button\n v-if=\"!props.showDrawerPreviousButton && totalActiveFiltersCount > 0\"\n secondary\n :disabled=\"isDataViewLoading\"\n @click=\"handleResetAllClick\"\n >\n {{ t('ll.resetAll') }}\n </Button>\n <Button\n v-if=\"\n (props.showDrawerPreviousButton || props.drawerStyle === 'cascade') && activeGroupActiveFiltersCount > 0\n \"\n secondary\n :disabled=\"isDataViewLoading\"\n @click=\"handleResetGroupClick\"\n >\n {{ t('ll.reset') }}\n </Button>\n <Button\n v-if=\"props.showDrawerPreviousButton || 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":["useFilters","schema","dataViewRef","appliedFilters","ref","workingFilters","filterName","dvRef","applyFilters","cloneDeep","resetAllFilters","resetFilterGroup","group","undoWorkingFilters","activeFiltersCounts","computed","counts","config","value","_a","isDefined","totalActiveFiltersCount","count","slots","_useSlots","isDesktop","useMediaQuery","SCREEN_SIZES","density","isDataViewLoading","isWithinModule","currentSearch","updateCurrentSearch","inject","DATA_VIEW_INJECTION","provide","DATA_VIEW_FILTERS_UTILS_INJECTION","props","activeGroupActiveFiltersCount","isDrawerOpen","handleApplyClick","preventDismiss","_b","handleResetGroupClick","emit","handleResetAllClick","onDismiss","watch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCO,SAASA,GAAyD;AAAA,EACvE,QAAAC;AAAA,EACA,aAAAC;AACF,GAAyE;AACjE,QAAAC,IAAiBC,EAAI,CAAA,CAAE,GACvBC,IAAiBD,EAAI,CAAA,CAAE;AAE7B,aAAWE,KAAcL;AAEvB,IAAAE,EAAe,MAAMG,CAAU,IAAIL,EAAOK,CAAU,EAAE,cAEtDD,EAAe,MAAMC,CAAU,IAAIL,EAAOK,CAAU,EAAE;AAGxD,QAAMC,IAAQL;AAQd,WAASM,IAAe;AACP,IAAAL,EAAA,QAAQM,EAAUJ,EAAe,KAAK,GACrDE,EAAM,MAAM,qBAAqBJ,EAAe,OAAO,EAAE,YAAY,IAAM;AAAA,EAC7E;AAQA,WAASO,IAAkB;AACzB,eAAWJ,KAAcL;AAEvB,MAAAE,EAAe,MAAMG,CAAU,IAAIL,EAAOK,CAAU,EAAE,cAEtDD,EAAe,MAAMC,CAAU,IAAIL,EAAOK,CAAU,EAAE;AAGxD,IAAAC,EAAM,MAA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A,IAChB;AAEA,WAAAG,EAAMR,GAAc,MAAM;AACxB,MAAIA,EAAa,SACfK,EAAK,aAAa;AAAA,IACpB,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -45,6 +45,8 @@ export declare interface DataViewFiltersProps {
|
|
|
45
45
|
*/
|
|
46
46
|
searchBarProps?: SearchBarProps;
|
|
47
47
|
showSearch?: boolean;
|
|
48
|
+
/** 'cascade' displays all fields within every filter group; 'nested' displays only the group names and requires clicking a group to view its fields */
|
|
49
|
+
drawerStyle?: DrawerStyle;
|
|
48
50
|
drawerProps?: ModalProps;
|
|
49
51
|
showDrawerPreviousButton?: boolean;
|
|
50
52
|
/**
|
|
@@ -64,11 +66,13 @@ export declare interface DataViewFiltersSlots {
|
|
|
64
66
|
|
|
65
67
|
export declare interface DataViewFiltersUtilsInjection {
|
|
66
68
|
useFiltersInstance?: UseFiltersReturnType;
|
|
69
|
+
drawerStyle?: DrawerStyle;
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
declare const _default: __VLS_WithTemplateSlots<DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<DataViewFiltersProps>, {
|
|
70
73
|
filtersLabelText: any;
|
|
71
74
|
isLoading: boolean;
|
|
75
|
+
drawerStyle: string;
|
|
72
76
|
drawerProps: undefined;
|
|
73
77
|
searchBarProps: undefined;
|
|
74
78
|
showDrawerPreviousButton: boolean;
|
|
@@ -85,6 +89,7 @@ declare const _default: __VLS_WithTemplateSlots<DefineComponent<__VLS_WithDefaul
|
|
|
85
89
|
}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<DataViewFiltersProps>, {
|
|
86
90
|
filtersLabelText: any;
|
|
87
91
|
isLoading: boolean;
|
|
92
|
+
drawerStyle: string;
|
|
88
93
|
drawerProps: undefined;
|
|
89
94
|
searchBarProps: undefined;
|
|
90
95
|
showDrawerPreviousButton: boolean;
|
|
@@ -102,6 +107,7 @@ declare const _default: __VLS_WithTemplateSlots<DefineComponent<__VLS_WithDefaul
|
|
|
102
107
|
filtersLabelText: string;
|
|
103
108
|
searchBarProps: SearchBarProps;
|
|
104
109
|
showSearch: boolean;
|
|
110
|
+
drawerStyle: DrawerStyle;
|
|
105
111
|
drawerProps: ModalProps;
|
|
106
112
|
showDrawerPreviousButton: boolean;
|
|
107
113
|
useFiltersInstance: UseFiltersReturnType<object, string>;
|
|
@@ -110,6 +116,8 @@ declare const _default: __VLS_WithTemplateSlots<DefineComponent<__VLS_WithDefaul
|
|
|
110
116
|
}, {}>, Readonly<DataViewFiltersSlots>>;
|
|
111
117
|
export default _default;
|
|
112
118
|
|
|
119
|
+
export declare type DrawerStyle = 'cascade' | 'nested';
|
|
120
|
+
|
|
113
121
|
declare interface Injection<T> {
|
|
114
122
|
key: InjectionKey<T>;
|
|
115
123
|
}
|
package/dist/FilterDrawerItem.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { t as
|
|
3
|
-
import
|
|
4
|
-
import { D as
|
|
5
|
-
import
|
|
1
|
+
import { defineComponent as y, useSlots as C, inject as F, computed as p, openBlock as t, createElementBlock as a, createBlock as n, resolveDynamicComponent as k, withCtx as w, createElementVNode as s, toDisplayString as c, createCommentVNode as o, normalizeClass as x, unref as l, createTextVNode as I, renderSlot as g } from "vue";
|
|
2
|
+
import { t as u } from "./locale.js";
|
|
3
|
+
import D from "./Chip.js";
|
|
4
|
+
import { D as E } from "./DataViewFilters.keys-c80ffabe.js";
|
|
5
|
+
import S from "./Icon.js";
|
|
6
6
|
import "lodash-es/get";
|
|
7
7
|
import "./utils/colorScheme.js";
|
|
8
8
|
import "./_plugin-vue_export-helper-dad06003.js";
|
|
9
9
|
import "lodash-es/uniqueId";
|
|
10
10
|
import "./index-79ce320f.js";
|
|
11
11
|
import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
|
|
12
|
-
const
|
|
12
|
+
const N = { class: "stash-filter-drawer-item" }, T = { class: "tw-flex tw-justify-between tw-items-center tw-self-stretch" }, A = { class: "tw-flex tw-flex-col tw-items-start" }, V = {
|
|
13
13
|
key: 0,
|
|
14
14
|
class: "tw-text-xs",
|
|
15
15
|
"data-test": "description"
|
|
16
|
-
},
|
|
16
|
+
}, B = {
|
|
17
|
+
key: 0,
|
|
18
|
+
class: "tw-p-6 tw-gap-3"
|
|
19
|
+
}, M = /* @__PURE__ */ y({
|
|
17
20
|
__name: "FilterDrawerItem",
|
|
18
21
|
props: {
|
|
19
22
|
group: {},
|
|
@@ -21,45 +24,58 @@ const g = { class: "tw-py-4" }, k = { class: "tw-flex tw-justify-between tw-item
|
|
|
21
24
|
description: {}
|
|
22
25
|
},
|
|
23
26
|
emits: ["navigate"],
|
|
24
|
-
setup(
|
|
25
|
-
const
|
|
26
|
-
if (!(
|
|
27
|
+
setup(f, { emit: v }) {
|
|
28
|
+
const r = f, _ = C(), e = F(E.key);
|
|
29
|
+
if (!(e != null && e.useFiltersInstance))
|
|
27
30
|
throw new Error(
|
|
28
31
|
"FilterDropdown must be used within a <DataViewFilters> that receives an instance of useFilters()."
|
|
29
32
|
);
|
|
30
|
-
const { activeFiltersCounts:
|
|
31
|
-
return (
|
|
32
|
-
t("button", {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
const { activeFiltersCounts: h } = e.useFiltersInstance, m = p(() => h.value[r.group]), i = p(() => e.drawerStyle === "cascade");
|
|
34
|
+
return (b, d) => (t(), a("div", N, [
|
|
35
|
+
(t(), n(k(i.value ? "div" : "button"), {
|
|
36
|
+
"data-test": "stash-filter-drawer-item|dynamic-component",
|
|
37
|
+
class: "tw-w-full tw-py-4 tw-outline-none focus:tw-outline-blue-500 tw-border-b tw-border-ice-500",
|
|
38
|
+
onClick: d[0] || (d[0] = (O) => i.value ? void 0 : v("navigate"))
|
|
39
|
+
}, {
|
|
40
|
+
default: w(() => [
|
|
41
|
+
s("div", T, [
|
|
42
|
+
s("div", A, [
|
|
43
|
+
s("h4", null, c(r.title), 1),
|
|
44
|
+
r.description ? (t(), a("div", V, c(r.description), 1)) : o("", !0)
|
|
45
|
+
]),
|
|
46
|
+
s("div", {
|
|
47
|
+
class: x(["tw-inline-flex tw-items-center tw-gap-6", { "tw-mr-2 tw-mb-0.5": i.value }])
|
|
48
|
+
}, [
|
|
49
|
+
m.value ? (t(), n(D, {
|
|
50
|
+
key: 0,
|
|
51
|
+
color: "blue",
|
|
52
|
+
radius: "pill",
|
|
53
|
+
shade: "main",
|
|
54
|
+
"aria-label": l(u)("ll.numberOfActiveFilters"),
|
|
55
|
+
title: l(u)("ll.numberOfActiveFilters")
|
|
56
|
+
}, {
|
|
57
|
+
default: w(() => [
|
|
58
|
+
I(c(m.value), 1)
|
|
59
|
+
]),
|
|
60
|
+
_: 1
|
|
61
|
+
}, 8, ["aria-label", "title"])) : o("", !0),
|
|
62
|
+
i.value ? o("", !0) : (t(), n(S, {
|
|
63
|
+
key: 1,
|
|
64
|
+
name: "chevron-right",
|
|
65
|
+
title: l(u)("ll.viewFilterGroup")
|
|
66
|
+
}, null, 8, ["title"]))
|
|
67
|
+
], 2)
|
|
56
68
|
])
|
|
57
|
-
])
|
|
58
|
-
|
|
69
|
+
]),
|
|
70
|
+
_: 1
|
|
71
|
+
})),
|
|
72
|
+
i.value && l(_).default ? (t(), a("div", B, [
|
|
73
|
+
g(b.$slots, "default")
|
|
74
|
+
])) : o("", !0)
|
|
59
75
|
]));
|
|
60
76
|
}
|
|
61
77
|
});
|
|
62
78
|
export {
|
|
63
|
-
|
|
79
|
+
M as default
|
|
64
80
|
};
|
|
65
81
|
//# sourceMappingURL=FilterDrawerItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterDrawerItem.js","sources":["../src/components/FilterDrawerItem/FilterDrawerItem.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n import { computed, inject } from 'vue';\n\n import { t } from '../../locale';\n import Chip from '../Chip/Chip.vue';\n import { DATA_VIEW_FILTERS_UTILS_INJECTION } from '../DataViewFilters/DataViewFilters.keys';\n import Icon from '../Icon/Icon.vue';\n\n export interface FilterDrawerItemProps {\n /** The name of a filter group */\n group: string;\n title: string;\n description?: string;\n }\n const props = defineProps<FilterDrawerItemProps>();\n\n export interface FilterDrawerItemEmits {\n (e: 'navigate');\n }\n const emit = defineEmits<FilterDrawerItemEmits>();\n\n const dataViewFiltersUtils = inject(DATA_VIEW_FILTERS_UTILS_INJECTION.key);\n\n if (!dataViewFiltersUtils?.useFiltersInstance) {\n throw new Error(\n 'FilterDropdown must be used within a <DataViewFilters> that receives an instance of useFilters().',\n );\n }\n\n const { activeFiltersCounts } = dataViewFiltersUtils.useFiltersInstance;\n\n const activeCount = computed(() => activeFiltersCounts.value[props.group]);\n</script>\n\n<template>\n <div class=\"
|
|
1
|
+
{"version":3,"file":"FilterDrawerItem.js","sources":["../src/components/FilterDrawerItem/FilterDrawerItem.vue"],"sourcesContent":["<script lang=\"ts\" setup>\n import { computed, inject } from 'vue';\n\n import { t } from '../../locale';\n import Chip from '../Chip/Chip.vue';\n import { DATA_VIEW_FILTERS_UTILS_INJECTION } from '../DataViewFilters/DataViewFilters.keys';\n import Icon from '../Icon/Icon.vue';\n\n export interface FilterDrawerItemProps {\n /** The name of a filter group */\n group: string;\n title: string;\n description?: string;\n }\n const props = defineProps<FilterDrawerItemProps>();\n\n export interface FilterDrawerItemEmits {\n (e: 'navigate');\n }\n const emit = defineEmits<FilterDrawerItemEmits>();\n\n export interface FilterDrawerItemSlots {\n default?: void;\n }\n\n const slots = defineSlots<FilterDrawerItemSlots>();\n\n const dataViewFiltersUtils = inject(DATA_VIEW_FILTERS_UTILS_INJECTION.key);\n\n if (!dataViewFiltersUtils?.useFiltersInstance) {\n throw new Error(\n 'FilterDropdown must be used within a <DataViewFilters> that receives an instance of useFilters().',\n );\n }\n\n const { activeFiltersCounts } = dataViewFiltersUtils.useFiltersInstance;\n\n const activeCount = computed(() => activeFiltersCounts.value[props.group]);\n const isDrawerCascade = computed(() => dataViewFiltersUtils.drawerStyle === 'cascade');\n</script>\n\n<template>\n <div class=\"stash-filter-drawer-item\">\n <component\n :is=\"isDrawerCascade ? 'div' : 'button'\"\n data-test=\"stash-filter-drawer-item|dynamic-component\"\n class=\"tw-w-full tw-py-4 tw-outline-none focus:tw-outline-blue-500 tw-border-b tw-border-ice-500\"\n @click=\"isDrawerCascade ? undefined : emit('navigate')\"\n >\n <div class=\"tw-flex tw-justify-between tw-items-center tw-self-stretch\">\n <div class=\"tw-flex tw-flex-col tw-items-start\">\n <h4>{{ props.title }}</h4>\n <div v-if=\"props.description\" class=\"tw-text-xs\" data-test=\"description\">\n {{ props.description }}\n </div>\n </div>\n <div class=\"tw-inline-flex tw-items-center tw-gap-6\" :class=\"{ 'tw-mr-2 tw-mb-0.5': isDrawerCascade }\">\n <Chip\n v-if=\"activeCount\"\n color=\"blue\"\n radius=\"pill\"\n shade=\"main\"\n :aria-label=\"t('ll.numberOfActiveFilters')\"\n :title=\"t('ll.numberOfActiveFilters')\"\n >\n {{ activeCount }}\n </Chip>\n <Icon v-if=\"!isDrawerCascade\" name=\"chevron-right\" :title=\"t('ll.viewFilterGroup')\" />\n </div>\n </div>\n </component>\n <div v-if=\"isDrawerCascade && slots.default\" class=\"tw-p-6 tw-gap-3\">\n <slot></slot>\n </div>\n </div>\n</template>\n"],"names":["slots","_useSlots","dataViewFiltersUtils","inject","DATA_VIEW_FILTERS_UTILS_INJECTION","activeFiltersCounts","activeCount","computed","props","isDrawerCascade"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyBQA,IAAQC,KAERC,IAAuBC,EAAOC,EAAkC,GAAG;AAErE,QAAA,EAACF,KAAA,QAAAA,EAAsB;AACzB,YAAM,IAAI;AAAA,QACR;AAAA,MAAA;AAIE,UAAA,EAAE,qBAAAG,EAAoB,IAAIH,EAAqB,oBAE/CI,IAAcC,EAAS,MAAMF,EAAoB,MAAMG,EAAM,KAAK,CAAC,GACnEC,IAAkBF,EAAS,MAAML,EAAqB,gBAAgB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -17,11 +17,17 @@ declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
declare
|
|
20
|
+
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
21
|
+
new (): {
|
|
22
|
+
$slots: S;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
declare const _default: __VLS_WithTemplateSlots<DefineComponent<__VLS_TypePropsToRuntimeProps<FilterDrawerItemProps>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
21
27
|
navigate: () => void;
|
|
22
28
|
}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<FilterDrawerItemProps>>> & {
|
|
23
29
|
onNavigate?: (() => any) | undefined;
|
|
24
|
-
}, {}, {}
|
|
30
|
+
}, {}, {}>, Readonly<FilterDrawerItemSlots>>;
|
|
25
31
|
export default _default;
|
|
26
32
|
|
|
27
33
|
export declare interface FilterDrawerItemEmits {
|
|
@@ -35,4 +41,8 @@ export declare interface FilterDrawerItemProps {
|
|
|
35
41
|
description?: string;
|
|
36
42
|
}
|
|
37
43
|
|
|
44
|
+
export declare interface FilterDrawerItemSlots {
|
|
45
|
+
default?: void;
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
export { }
|