@leaflink/stash 50.11.0 → 50.12.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/Accordion.js +28 -29
- package/dist/Accordion.js.map +1 -1
- package/dist/Accordion.vue.d.ts +6 -1
- package/dist/AppNavigationItem.vue.d.ts +5 -0
- package/dist/AppSidebar.js +1 -1
- package/dist/AppSidebar.js.map +1 -1
- package/dist/CurrencyInput.js.map +1 -1
- package/dist/DataView.js +102 -98
- package/dist/DataView.js.map +1 -1
- package/dist/{DataView.keys-C7eaZg2G.js → DataView.keys-aSOnA4AD.js} +2 -1
- package/dist/DataView.keys-aSOnA4AD.js.map +1 -0
- package/dist/DataView.vue.d.ts +11 -0
- package/dist/DataViewFilters.js +1 -1
- package/dist/DataViewSortButton.js +1 -1
- package/dist/DataViewToolbar.js +61 -60
- package/dist/DataViewToolbar.js.map +1 -1
- package/dist/Dropdown.js +10 -10
- package/dist/Dropdown.js.map +1 -1
- package/dist/Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js.map +1 -1
- package/dist/FilterDropdown.js +1 -1
- package/dist/Filters.js.map +1 -1
- package/dist/Icon.js.map +1 -1
- package/dist/Icon.vue.d.ts +5 -0
- package/dist/IconLabel.vue.d.ts +5 -0
- package/dist/InlineEdit.js.map +1 -1
- package/dist/InputOptions.js.map +1 -1
- package/dist/ListView.js.map +1 -1
- package/dist/ListView.vue.d.ts +38 -13
- package/dist/Modals.js +7 -7
- package/dist/Modals.js.map +1 -1
- package/dist/Paginate.js +73 -55
- package/dist/Paginate.js.map +1 -1
- package/dist/Paginate.vue.d.ts +12 -1
- package/dist/QuickAction.vue.d.ts +5 -0
- package/dist/SearchBar.js +1 -1
- package/dist/SearchBar.js.map +1 -1
- package/dist/Select.js +5 -5
- package/dist/Select.js.map +1 -1
- package/dist/SelectStatus.js +15 -15
- package/dist/SelectStatus.js.map +1 -1
- package/dist/SelectStatus.vue.d.ts +5 -0
- package/dist/Step.js +15 -15
- package/dist/Step.js.map +1 -1
- package/dist/Table.js +5 -5
- package/dist/Table.js.map +1 -1
- package/dist/TableCell.js +2 -2
- package/dist/TableHeaderCell.js +2 -2
- package/dist/TableHeaderRow.js +1 -1
- package/dist/TableRow.js +1 -1
- package/dist/TextEditor.js +1 -0
- package/dist/TextEditor.js.map +1 -1
- package/dist/TextEditor.vue.d.ts +5 -0
- package/dist/Textarea.js.map +1 -1
- package/dist/components.css +1 -1
- package/dist/directives/autofocus.js +2 -2
- package/dist/directives/autofocus.js.map +1 -1
- package/dist/directives/sticky.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/locale.js +3 -2
- package/dist/locale.js.map +1 -1
- package/dist/tailwind-base.js +0 -2
- package/dist/tailwind-base.js.map +1 -1
- package/dist/useModals.js.map +1 -1
- package/dist/usePaginationStats-d_q39naC.js +12 -0
- package/dist/usePaginationStats-d_q39naC.js.map +1 -0
- package/dist/useSelection.js +4 -1
- package/dist/useSelection.js.map +1 -1
- package/dist/useValidation.js +39 -36
- package/dist/useValidation.js.map +1 -1
- package/dist/utils/helpers.js +29 -29
- package/dist/utils/helpers.js.map +1 -1
- package/package.json +27 -5
- package/tailwind-base.ts +0 -2
- package/types/jsonApi.ts +8 -8
- package/dist/DataView.keys-C7eaZg2G.js.map +0 -1
package/dist/DataView.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import { M as
|
|
4
|
-
import
|
|
5
|
-
import { a as
|
|
6
|
-
import { _ as
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
return { id:
|
|
1
|
+
import { defineComponent as R, useCssModule as U, ref as l, inject as J, computed as n, watch as y, provide as W, openBlock as V, createElementBlock as G, renderSlot as Z, createBlock as q, normalizeClass as H, unref as K, createCommentVNode as Q } from "vue";
|
|
2
|
+
import X from "lodash-es/cloneDeep";
|
|
3
|
+
import { M as I } from "./Module.keys-CEsrW2f0.js";
|
|
4
|
+
import Y from "./Paginate.js";
|
|
5
|
+
import { a as w, D as O } from "./DataView.keys-aSOnA4AD.js";
|
|
6
|
+
import { _ as tt } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
7
|
+
function z(a) {
|
|
8
|
+
const o = a[0] === "-" ? "desc" : "asc";
|
|
9
|
+
return { id: o === "asc" ? a : a.slice(1), order: o };
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return `${
|
|
11
|
+
function et({ id: a, order: o }) {
|
|
12
|
+
return `${o === "desc" ? "-" : ""}${a}`;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
18
|
-
if (!
|
|
19
|
-
return
|
|
20
|
-
if (!(!
|
|
21
|
-
if (!
|
|
22
|
-
return `-${
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
25
|
-
if (!(
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
28
|
-
if (
|
|
29
|
-
return `-${
|
|
30
|
-
if (!(
|
|
31
|
-
return `-${
|
|
14
|
+
function at({ newId: a, newOrder: o, oldId: f, oldOrder: t }) {
|
|
15
|
+
if (a) {
|
|
16
|
+
if (a !== f)
|
|
17
|
+
return et({ id: a, order: o || "asc" });
|
|
18
|
+
if (!o && !t)
|
|
19
|
+
return a;
|
|
20
|
+
if (!(!o && t === "desc")) {
|
|
21
|
+
if (!o && t === "asc")
|
|
22
|
+
return `-${a}`;
|
|
23
|
+
if (o === "asc" && !t)
|
|
24
|
+
return a;
|
|
25
|
+
if (!(o === "asc" && t === "asc")) {
|
|
26
|
+
if (o === "asc" && t === "desc")
|
|
27
|
+
return a;
|
|
28
|
+
if (o === "desc" && !t)
|
|
29
|
+
return `-${a}`;
|
|
30
|
+
if (!(o === "desc" && t === "desc") && o === "desc" && t === "asc")
|
|
31
|
+
return `-${a}`;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
var
|
|
37
|
-
const
|
|
36
|
+
var nt = /* @__PURE__ */ ((a) => (a.Table = "table", a))(nt || {});
|
|
37
|
+
const ot = /* @__PURE__ */ R({
|
|
38
38
|
__name: "DataView",
|
|
39
39
|
props: {
|
|
40
40
|
currentPage: { default: 1 },
|
|
@@ -42,65 +42,66 @@ const nt = /* @__PURE__ */ F({
|
|
|
42
42
|
currentSort: { default: void 0 },
|
|
43
43
|
data: { default: () => [] },
|
|
44
44
|
density: { default: "comfortable" },
|
|
45
|
-
pageSize: { default:
|
|
45
|
+
pageSize: { default: w },
|
|
46
46
|
disablePagination: { type: Boolean, default: !1 },
|
|
47
47
|
hideBottomPagination: { type: Boolean, default: !1 },
|
|
48
48
|
totalDataCount: { default: 0 },
|
|
49
|
+
hasNextPage: { type: Boolean, default: void 0 },
|
|
49
50
|
variant: { default: void 0 },
|
|
50
51
|
isLoading: { type: Boolean }
|
|
51
52
|
},
|
|
52
53
|
emits: ["update", "update:currentFilters", "update:currentPage", "update:currentSearch", "update:currentSort"],
|
|
53
|
-
setup(
|
|
54
|
-
const t =
|
|
55
|
-
var
|
|
54
|
+
setup(a, { expose: o, emit: f }) {
|
|
55
|
+
const t = a, d = f, $ = U(), P = l(null), _ = J(I.key, I.defaults), L = n(() => {
|
|
56
|
+
var e;
|
|
56
57
|
if (t.variant)
|
|
57
58
|
return t.variant;
|
|
58
|
-
if (((
|
|
59
|
+
if (((e = _.variant) == null ? void 0 : e.value) === "table")
|
|
59
60
|
return "table";
|
|
60
|
-
}), E = n(() =>
|
|
61
|
-
var
|
|
62
|
-
u.value =
|
|
63
|
-
},
|
|
64
|
-
const
|
|
65
|
-
i(
|
|
66
|
-
},
|
|
67
|
-
const
|
|
68
|
-
i(
|
|
61
|
+
}), E = n(() => _.variant !== void 0), u = l(1), N = n(() => !t.disablePagination && t.totalDataCount > 0), x = n(() => t.totalDataCount === 1 / 0 && !t.hasNextPage), p = n(() => Math.ceil(t.totalDataCount / t.pageSize)), i = function(e, { shouldEmit: r } = {}) {
|
|
62
|
+
var c, h;
|
|
63
|
+
u.value = e, r && (S(), d("update:currentPage", e, t.pageSize)), Number((c = P.value) == null ? void 0 : c.getBoundingClientRect().top) < 0 && ((h = P.value) == null || h.scrollIntoView({ behavior: "smooth", block: "start" }));
|
|
64
|
+
}, C = function({ shouldEmit: e } = {}) {
|
|
65
|
+
const r = Math.max(u.value - 1, 1);
|
|
66
|
+
i(r, { shouldEmit: e });
|
|
67
|
+
}, D = function({ shouldEmit: e } = {}) {
|
|
68
|
+
const r = Math.min(u.value + 1, p.value);
|
|
69
|
+
i(r, { shouldEmit: e });
|
|
69
70
|
};
|
|
70
|
-
|
|
71
|
+
y(
|
|
71
72
|
() => t.currentPage,
|
|
72
73
|
() => {
|
|
73
74
|
i(t.currentPage);
|
|
74
75
|
},
|
|
75
76
|
{ immediate: !0 }
|
|
76
77
|
);
|
|
77
|
-
const s =
|
|
78
|
-
() => s.value ?
|
|
79
|
-
),
|
|
80
|
-
() => s.value ?
|
|
81
|
-
), v = function(
|
|
82
|
-
const { id: h, order:
|
|
83
|
-
s.value =
|
|
78
|
+
const s = l(void 0), B = n(
|
|
79
|
+
() => s.value ? z(s.value).id : void 0
|
|
80
|
+
), M = n(
|
|
81
|
+
() => s.value ? z(s.value).order : void 0
|
|
82
|
+
), v = function(e, { sortOrder: r, shouldEmit: c } = {}) {
|
|
83
|
+
const { id: h, order: F } = z(s.value || ""), k = at({ newId: e, newOrder: r, oldId: h, oldOrder: F });
|
|
84
|
+
s.value = k, i(1), c && (S(), d("update:currentSort", k));
|
|
84
85
|
};
|
|
85
|
-
|
|
86
|
+
y(
|
|
86
87
|
() => t.currentSort,
|
|
87
88
|
() => {
|
|
88
89
|
v(t.currentSort);
|
|
89
90
|
},
|
|
90
91
|
{ immediate: !0 }
|
|
91
92
|
);
|
|
92
|
-
const g =
|
|
93
|
-
g.value =
|
|
93
|
+
const g = l(""), T = l(!1), j = l(!1), m = function(e, { shouldEmit: r } = {}) {
|
|
94
|
+
g.value = e || "", i(1), r && (S(), d("update:currentSearch", e));
|
|
94
95
|
};
|
|
95
|
-
|
|
96
|
+
y(
|
|
96
97
|
() => t.currentSearch,
|
|
97
98
|
() => {
|
|
98
99
|
m(t.currentSearch);
|
|
99
100
|
},
|
|
100
101
|
{ immediate: !0 }
|
|
101
102
|
);
|
|
102
|
-
const
|
|
103
|
-
|
|
103
|
+
const b = l({}), A = function(e, { shouldEmit: r } = {}) {
|
|
104
|
+
b.value = e, i(1), r && (S(), d("update:currentFilters", e));
|
|
104
105
|
};
|
|
105
106
|
function S() {
|
|
106
107
|
d("update", {
|
|
@@ -108,90 +109,93 @@ const nt = /* @__PURE__ */ F({
|
|
|
108
109
|
pageSize: t.pageSize,
|
|
109
110
|
ordering: s.value,
|
|
110
111
|
search: g.value,
|
|
111
|
-
filters:
|
|
112
|
+
filters: X(b.value)
|
|
112
113
|
});
|
|
113
114
|
}
|
|
114
|
-
return
|
|
115
|
-
|
|
115
|
+
return W(
|
|
116
|
+
O.key,
|
|
116
117
|
Object.freeze({
|
|
117
118
|
// Pagination
|
|
118
119
|
currentPage: n(() => u.value),
|
|
119
|
-
isPaginationEnabled:
|
|
120
|
+
isPaginationEnabled: N,
|
|
121
|
+
isPaginateNextDisabled: x,
|
|
120
122
|
pageCount: p,
|
|
121
123
|
pageSize: n(() => t.pageSize),
|
|
122
124
|
totalDataCount: n(() => t.totalDataCount),
|
|
123
125
|
setPage: i,
|
|
124
|
-
goPrevPage:
|
|
125
|
-
goNextPage:
|
|
126
|
+
goPrevPage: C,
|
|
127
|
+
goNextPage: D,
|
|
126
128
|
// Sorting
|
|
127
|
-
currentSortId:
|
|
128
|
-
currentSortOrder:
|
|
129
|
+
currentSortId: B,
|
|
130
|
+
currentSortOrder: M,
|
|
129
131
|
updateCurrentSort: v,
|
|
130
132
|
// Search
|
|
131
133
|
currentSearch: n(() => g.value),
|
|
132
134
|
updateCurrentSearch: m,
|
|
133
135
|
// Miscellaneous
|
|
134
136
|
density: n(() => t.density),
|
|
135
|
-
hasToolbar:
|
|
137
|
+
hasToolbar: T,
|
|
136
138
|
isEmpty: n(() => t.data.length === 0),
|
|
137
|
-
isSelectable:
|
|
139
|
+
isSelectable: j,
|
|
138
140
|
isLoading: n(() => t.isLoading),
|
|
139
141
|
isWithinModule: E,
|
|
140
|
-
variant:
|
|
142
|
+
variant: L
|
|
141
143
|
})
|
|
142
|
-
),
|
|
144
|
+
), o({
|
|
143
145
|
page: n(() => u.value),
|
|
144
146
|
pageSize: n(() => t.pageSize),
|
|
145
147
|
setPage: i,
|
|
146
|
-
goPrevPage:
|
|
147
|
-
goNextPage:
|
|
148
|
+
goPrevPage: C,
|
|
149
|
+
goNextPage: D,
|
|
148
150
|
ordering: n(() => s.value),
|
|
149
151
|
updateCurrentSort: v,
|
|
150
152
|
search: n(() => g.value),
|
|
151
153
|
updateCurrentSearch: m,
|
|
152
|
-
filters: n(() =>
|
|
153
|
-
updateCurrentFilters:
|
|
154
|
-
}), (
|
|
154
|
+
filters: n(() => b.value),
|
|
155
|
+
updateCurrentFilters: A
|
|
156
|
+
}), (e, r) => (V(), G("div", {
|
|
155
157
|
ref_key: "rootRef",
|
|
156
|
-
ref:
|
|
158
|
+
ref: P,
|
|
157
159
|
class: "stash-data-view tw-relative",
|
|
158
160
|
"data-test": "stash-data-view"
|
|
159
161
|
}, [
|
|
160
|
-
|
|
162
|
+
Z(e.$slots, "default", {
|
|
161
163
|
currentPage: u.value,
|
|
162
|
-
currentSortId:
|
|
163
|
-
currentSortOrder:
|
|
164
|
-
data:
|
|
165
|
-
goPrevPage:
|
|
166
|
-
goNextPage:
|
|
164
|
+
currentSortId: B.value,
|
|
165
|
+
currentSortOrder: M.value,
|
|
166
|
+
data: e.data,
|
|
167
|
+
goPrevPage: C,
|
|
168
|
+
goNextPage: D,
|
|
167
169
|
pageCount: p.value,
|
|
168
170
|
setPage: i,
|
|
169
171
|
totalDataCount: t.totalDataCount,
|
|
170
172
|
updateCurrentSort: v,
|
|
171
173
|
updateCurrentSearch: m
|
|
172
174
|
}),
|
|
173
|
-
|
|
175
|
+
N.value && !E.value && p.value > 1 && !t.hideBottomPagination ? (V(), q(Y, {
|
|
174
176
|
key: 0,
|
|
175
|
-
class:
|
|
177
|
+
class: H(["tw-mt-6", K($).paginate]),
|
|
176
178
|
"current-page": u.value,
|
|
179
|
+
"is-next-disabled": e.isLoading || x.value,
|
|
177
180
|
"list-length": t.totalDataCount,
|
|
178
181
|
"page-size": t.pageSize,
|
|
179
|
-
|
|
180
|
-
|
|
182
|
+
variant: t.totalDataCount === 1 / 0 ? "stats" : "standard",
|
|
183
|
+
onSetPage: r[0] || (r[0] = (c) => i(c, { shouldEmit: !0 }))
|
|
184
|
+
}, null, 8, ["class", "current-page", "is-next-disabled", "list-length", "page-size", "variant"])) : Q("", !0)
|
|
181
185
|
], 512));
|
|
182
186
|
}
|
|
183
|
-
}), rt = "_paginate_1jnlh_2",
|
|
187
|
+
}), rt = "_paginate_1jnlh_2", it = {
|
|
184
188
|
paginate: rt
|
|
185
|
-
},
|
|
186
|
-
$style:
|
|
187
|
-
},
|
|
189
|
+
}, ut = {
|
|
190
|
+
$style: it
|
|
191
|
+
}, vt = /* @__PURE__ */ tt(ot, [["__cssModules", ut]]);
|
|
188
192
|
export {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
O as DATA_VIEW_INJECTION,
|
|
194
|
+
w as DEFAULT_PAGE_SIZE,
|
|
195
|
+
nt as DataViewVariant,
|
|
196
|
+
vt as default,
|
|
197
|
+
z as deserializeSortValue,
|
|
198
|
+
at as getNextSort,
|
|
199
|
+
et as serializeSortValue
|
|
196
200
|
};
|
|
197
201
|
//# sourceMappingURL=DataView.js.map
|
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 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 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 * 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 * 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 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 // #region pagination\n const internalPage = ref(1);\n const isPaginationEnabled = computed(() => !props.disablePagination && props.totalDataCount > 0);\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 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 tw-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=\"isPaginationEnabled && !isWithinModule && pageCount > 1 && !props.hideBottomPagination\"\n class=\"tw-mt-6\"\n :class=\"classes.paginate\"\n :current-page=\"internalPage\"\n :list-length=\"props.totalDataCount\"\n :page-size=\"props.pageSize\"\n @set-page=\"(page: number) => setPage(page, { shouldEmit: true })\"\n />\n </div>\n</template>\n\n<style module>\n .paginate ul {\n margin: 0;\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","internalPage","isPaginationEnabled","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":";;;;;;AAKO,SAASA,EAAqBC,GAAwC;AAC3E,QAAMC,IAAQD,EAAK,CAAC,MAAM,MAAM,SAAS;AAGlC,SAAA,EAAE,IAFEC,MAAU,QAAQD,IAAOA,EAAK,MAAM,CAAC,GAEnC,OAAAC,EAAM;AACrB;AAKO,SAASC,GAAmB,EAAE,IAAAC,GAAI,OAAAF,KAA2C;AAClF,SAAO,GAAGA,MAAU,SAAS,MAAM,EAAE,GAAGE,CAAE;AAC5C;AAcO,SAASC,GAAY,EAAE,OAAAC,GAAO,UAAAC,GAAU,OAAAC,GAAO,UAAAC,KAAoD;AACxG,MAAKH,GAIL;AAAA,QAAIA,MAAUE;AAEZ,aAAOL,GAAmB,EAAE,IAAIG,GAAO,OAAOC,KAAY,OAAO;AAS/D,QAAA,CAACA,KAAY,CAACE;AACT,aAAAH;AAGL,QAAA,GAACC,KAAYE,MAAa,SAI1B;AAAA,UAAA,CAACF,KAAYE,MAAa;AAC5B,eAAO,IAAIH,CAAK;AAKd,UAAAC,MAAa,SAAS,CAACE;AAClB,eAAAH;AAGL,UAAA,EAAAC,MAAa,SAASE,MAAa,QAInC;AAAA,YAAAF,MAAa,SAASE,MAAa;AAC9B,iBAAAH;AAKL,YAAAC,MAAa,UAAU,CAACE;AAC1B,iBAAO,IAAIH,CAAK;AAGd,YAAA,EAAAC,MAAa,UAAUE,MAAa,WAIpCF,MAAa,UAAUE,MAAa;AACtC,iBAAO,IAAIH,CAAK;AAAA;AAAA;AAAA;AAGpB;ACnFY,IAAAI,uBAAAA,OACVA,EAAA,QAAQ,SADEA,IAAAA,MAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;ACqFV,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S,MAAMZ,EAAM,QAAQ;AAAA,MACvC,SAAAkB;AAAA,MACA,YAAAK;AAAA,MACA,YAAAC;AAAA,MACA,UAAUZ,EAAS,MAAMc,EAAa,KAAK;AAAA,MAC3C,mBAAAG;AAAA,MACA,QAAQjB,EAAS,MAAMqB,EAAe,KAAK;AAAA,MAC3C,qBAAAG;AAAA,MACA,SAASxB,EAAS,MAAM0B,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 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 // #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 tw-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=\"isPaginationEnabled && !isWithinModule && pageCount > 1 && !props.hideBottomPagination\"\n class=\"tw-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 .paginate ul {\n margin: 0;\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","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":";;;;;;AAKO,SAASA,EAAqBC,GAAwC;AAC3E,QAAMC,IAAQD,EAAK,CAAC,MAAM,MAAM,SAAS;AAGlC,SAAA,EAAE,IAFEC,MAAU,QAAQD,IAAOA,EAAK,MAAM,CAAC,GAEnC,OAAAC,EAAM;AACrB;AAKO,SAASC,GAAmB,EAAE,IAAAC,GAAI,OAAAF,KAA2C;A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4,6 +4,7 @@ const a = 12, o = Object.freeze({
|
|
|
4
4
|
defaults: Object.freeze({
|
|
5
5
|
// Pagination
|
|
6
6
|
currentPage: e(() => 1),
|
|
7
|
+
isPaginateNextDisabled: e(() => !1),
|
|
7
8
|
isPaginationEnabled: e(() => !1),
|
|
8
9
|
pageCount: e(() => 1),
|
|
9
10
|
pageSize: e(() => a),
|
|
@@ -40,4 +41,4 @@ export {
|
|
|
40
41
|
o as D,
|
|
41
42
|
a
|
|
42
43
|
};
|
|
43
|
-
//# sourceMappingURL=DataView.keys-
|
|
44
|
+
//# sourceMappingURL=DataView.keys-aSOnA4AD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataView.keys-aSOnA4AD.js","sources":["../src/components/DataView/DataView.constants.ts","../src/components/DataView/DataView.keys.ts"],"sourcesContent":["export const DEFAULT_PAGE_SIZE = 12;\n","import { computed, ref } from 'vue';\n\nimport { InjectionWithDefaults } from '../../../types/utils';\nimport { DEFAULT_PAGE_SIZE } from './DataView.constants';\nimport { DataViewInjection } from './DataView.types';\n\n// See: https://vuejs.org/guide/typescript/composition-api.html#typing-provide-inject\n\n/**\n * Miscellaneous data that is not related to pagination, sorting, or searching.\n * TODO: merge all DataView injections into one. https://leaflink.atlassian.net/browse/STASH-507\n */\nexport const DATA_VIEW_INJECTION: InjectionWithDefaults<DataViewInjection> = Object.freeze({\n key: Symbol('DATA_VIEW_INJECTION_KEY'),\n defaults: Object.freeze({\n // Pagination\n currentPage: computed(() => 1),\n isPaginateNextDisabled: computed(() => false),\n isPaginationEnabled: computed(() => false),\n pageCount: computed(() => 1),\n pageSize: computed(() => DEFAULT_PAGE_SIZE),\n totalDataCount: computed(() => 0),\n setPage() {},\n goPrevPage() {},\n goNextPage() {},\n\n // Sorting\n currentSortId: computed(() => undefined),\n currentSortOrder: computed(() => undefined),\n updateCurrentSort() {},\n\n // Search\n currentSearch: computed(() => ''),\n updateCurrentSearch() {},\n\n // Miscellanous\n density: computed(() => undefined),\n isEmpty: computed(() => false),\n isLoading: computed(() => false),\n isSelectable: ref(false),\n isWithinModule: computed(() => false),\n variant: computed(() => undefined),\n }),\n});\n"],"names":["DEFAULT_PAGE_SIZE","DATA_VIEW_INJECTION","computed","ref"],"mappings":";AAAO,MAAMA,IAAoB,ICYpBC,IAAgE,OAAO,OAAO;AAAA,EACzF,KAAK,OAAO,yBAAyB;AAAA,EACrC,UAAU,OAAO,OAAO;AAAA;AAAA,IAEtB,aAAaC,EAAS,MAAM,CAAC;AAAA,IAC7B,wBAAwBA,EAAS,MAAM,EAAK;AAAA,IAC5C,qBAAqBA,EAAS,MAAM,EAAK;AAAA,IACzC,WAAWA,EAAS,MAAM,CAAC;AAAA,IAC3B,UAAUA,EAAS,MAAMF,CAAiB;AAAA,IAC1C,gBAAgBE,EAAS,MAAM,CAAC;AAAA,IAChC,UAAU;AAAA,IAAC;AAAA,IACX,aAAa;AAAA,IAAC;AAAA,IACd,aAAa;AAAA,IAAC;AAAA;AAAA,IAGd,eAAeA,EAAS,MAAM;AAAA,KAAS;AAAA,IACvC,kBAAkBA,EAAS,MAAM;AAAA,KAAS;AAAA,IAC1C,oBAAoB;AAAA,IAAC;AAAA;AAAA,IAGrB,eAAeA,EAAS,MAAM,EAAE;AAAA,IAChC,sBAAsB;AAAA,IAAC;AAAA;AAAA,IAGvB,SAASA,EAAS,MAAM;AAAA,KAAS;AAAA,IACjC,SAASA,EAAS,MAAM,EAAK;AAAA,IAC7B,WAAWA,EAAS,MAAM,EAAK;AAAA,IAC/B,cAAcC,EAAI,EAAK;AAAA,IACvB,gBAAgBD,EAAS,MAAM,EAAK;AAAA,IACpC,SAASA,EAAS,MAAA;AAAA,KAAe;AAAA,EAClC,CAAA;AACH,CAAC;"}
|
package/dist/DataView.vue.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export declare const DATA_VIEW_INJECTION: InjectionWithDefaults<DataViewInjectio
|
|
|
43
43
|
|
|
44
44
|
export declare interface DataViewInjection {
|
|
45
45
|
currentPage: ComputedRef<number>;
|
|
46
|
+
/** Optional override for the next button disabled state */
|
|
47
|
+
isPaginateNextDisabled: ComputedRef<boolean>;
|
|
46
48
|
isPaginationEnabled: ComputedRef<boolean>;
|
|
47
49
|
pageCount: ComputedRef<number>;
|
|
48
50
|
pageSize: ComputedRef<number>;
|
|
@@ -130,10 +132,16 @@ export declare interface DataViewProps {
|
|
|
130
132
|
/**
|
|
131
133
|
* The total number of records available.
|
|
132
134
|
* Used to auto-enable pagination when results exist.
|
|
135
|
+
* Use `Infinity` for activating 'n of many' pagination
|
|
133
136
|
* DataView does not paginate data for you; instead, `props.data` should always show
|
|
134
137
|
* the current page of results.
|
|
135
138
|
*/
|
|
136
139
|
totalDataCount?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Whether there is a next page of data or not as informed by the server.
|
|
142
|
+
* This only applies when`totalDataCount="Infinity"` to determine if the "Next" pagination button should be disabled.
|
|
143
|
+
*/
|
|
144
|
+
hasNextPage?: boolean;
|
|
137
145
|
/**
|
|
138
146
|
* DataView variant. The default value is `undefined`. Will default to `table` when used within
|
|
139
147
|
* a `<Module variant="table">`.
|
|
@@ -157,6 +165,7 @@ density: string;
|
|
|
157
165
|
pageSize: number;
|
|
158
166
|
disablePagination: boolean;
|
|
159
167
|
totalDataCount: number;
|
|
168
|
+
hasNextPage: undefined;
|
|
160
169
|
hideBottomPagination: boolean;
|
|
161
170
|
variant: undefined;
|
|
162
171
|
}>>, {
|
|
@@ -186,6 +195,7 @@ density: string;
|
|
|
186
195
|
pageSize: number;
|
|
187
196
|
disablePagination: boolean;
|
|
188
197
|
totalDataCount: number;
|
|
198
|
+
hasNextPage: undefined;
|
|
189
199
|
hideBottomPagination: boolean;
|
|
190
200
|
variant: undefined;
|
|
191
201
|
}>>> & Readonly<{
|
|
@@ -205,6 +215,7 @@ density: "compact" | "comfortable";
|
|
|
205
215
|
currentSort: string;
|
|
206
216
|
disablePagination: boolean;
|
|
207
217
|
hideBottomPagination: boolean;
|
|
218
|
+
hasNextPage: boolean;
|
|
208
219
|
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>, {
|
|
209
220
|
default?(_: {
|
|
210
221
|
currentPage: number;
|
package/dist/DataViewFilters.js
CHANGED
|
@@ -6,7 +6,7 @@ import { _ as K } from "./Box.vue_vue_type_script_setup_true_lang-DgJHq-09.js";
|
|
|
6
6
|
import _ from "./Button.js";
|
|
7
7
|
import L from "lodash-es/cloneDeep";
|
|
8
8
|
import P from "./Icon.js";
|
|
9
|
-
import { D as R } from "./DataView.keys-
|
|
9
|
+
import { D as R } from "./DataView.keys-aSOnA4AD.js";
|
|
10
10
|
import X from "./FilterChip.js";
|
|
11
11
|
import { _ as Y } from "./Label.vue_vue_type_script_setup_true_lang-C4JKdqvC.js";
|
|
12
12
|
import ee from "./Modal.js";
|
|
@@ -3,7 +3,7 @@ import { t as B } from "./locale.js";
|
|
|
3
3
|
import _ from "./Button.js";
|
|
4
4
|
import "lodash-es/cloneDeep";
|
|
5
5
|
import h from "./Icon.js";
|
|
6
|
-
import { D as C } from "./DataView.keys-
|
|
6
|
+
import { D as C } from "./DataView.keys-aSOnA4AD.js";
|
|
7
7
|
import E from "./Dropdown.js";
|
|
8
8
|
import I from "./IconLabel.js";
|
|
9
9
|
import { _ as N } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|