@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.
Files changed (75) hide show
  1. package/dist/Accordion.js +28 -29
  2. package/dist/Accordion.js.map +1 -1
  3. package/dist/Accordion.vue.d.ts +6 -1
  4. package/dist/AppNavigationItem.vue.d.ts +5 -0
  5. package/dist/AppSidebar.js +1 -1
  6. package/dist/AppSidebar.js.map +1 -1
  7. package/dist/CurrencyInput.js.map +1 -1
  8. package/dist/DataView.js +102 -98
  9. package/dist/DataView.js.map +1 -1
  10. package/dist/{DataView.keys-C7eaZg2G.js → DataView.keys-aSOnA4AD.js} +2 -1
  11. package/dist/DataView.keys-aSOnA4AD.js.map +1 -0
  12. package/dist/DataView.vue.d.ts +11 -0
  13. package/dist/DataViewFilters.js +1 -1
  14. package/dist/DataViewSortButton.js +1 -1
  15. package/dist/DataViewToolbar.js +61 -60
  16. package/dist/DataViewToolbar.js.map +1 -1
  17. package/dist/Dropdown.js +10 -10
  18. package/dist/Dropdown.js.map +1 -1
  19. package/dist/Field.vue_vue_type_script_setup_true_lang-DEizIcDo.js.map +1 -1
  20. package/dist/FilterDropdown.js +1 -1
  21. package/dist/Filters.js.map +1 -1
  22. package/dist/Icon.js.map +1 -1
  23. package/dist/Icon.vue.d.ts +5 -0
  24. package/dist/IconLabel.vue.d.ts +5 -0
  25. package/dist/InlineEdit.js.map +1 -1
  26. package/dist/InputOptions.js.map +1 -1
  27. package/dist/ListView.js.map +1 -1
  28. package/dist/ListView.vue.d.ts +38 -13
  29. package/dist/Modals.js +7 -7
  30. package/dist/Modals.js.map +1 -1
  31. package/dist/Paginate.js +73 -55
  32. package/dist/Paginate.js.map +1 -1
  33. package/dist/Paginate.vue.d.ts +12 -1
  34. package/dist/QuickAction.vue.d.ts +5 -0
  35. package/dist/SearchBar.js +1 -1
  36. package/dist/SearchBar.js.map +1 -1
  37. package/dist/Select.js +5 -5
  38. package/dist/Select.js.map +1 -1
  39. package/dist/SelectStatus.js +15 -15
  40. package/dist/SelectStatus.js.map +1 -1
  41. package/dist/SelectStatus.vue.d.ts +5 -0
  42. package/dist/Step.js +15 -15
  43. package/dist/Step.js.map +1 -1
  44. package/dist/Table.js +5 -5
  45. package/dist/Table.js.map +1 -1
  46. package/dist/TableCell.js +2 -2
  47. package/dist/TableHeaderCell.js +2 -2
  48. package/dist/TableHeaderRow.js +1 -1
  49. package/dist/TableRow.js +1 -1
  50. package/dist/TextEditor.js +1 -0
  51. package/dist/TextEditor.js.map +1 -1
  52. package/dist/TextEditor.vue.d.ts +5 -0
  53. package/dist/Textarea.js.map +1 -1
  54. package/dist/components.css +1 -1
  55. package/dist/directives/autofocus.js +2 -2
  56. package/dist/directives/autofocus.js.map +1 -1
  57. package/dist/directives/sticky.js.map +1 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/locale.js +3 -2
  60. package/dist/locale.js.map +1 -1
  61. package/dist/tailwind-base.js +0 -2
  62. package/dist/tailwind-base.js.map +1 -1
  63. package/dist/useModals.js.map +1 -1
  64. package/dist/usePaginationStats-d_q39naC.js +12 -0
  65. package/dist/usePaginationStats-d_q39naC.js.map +1 -0
  66. package/dist/useSelection.js +4 -1
  67. package/dist/useSelection.js.map +1 -1
  68. package/dist/useValidation.js +39 -36
  69. package/dist/useValidation.js.map +1 -1
  70. package/dist/utils/helpers.js +29 -29
  71. package/dist/utils/helpers.js.map +1 -1
  72. package/package.json +27 -5
  73. package/tailwind-base.ts +0 -2
  74. package/types/jsonApi.ts +8 -8
  75. package/dist/DataView.keys-C7eaZg2G.js.map +0 -1
package/dist/DataView.js CHANGED
@@ -1,40 +1,40 @@
1
- import { defineComponent as F, useCssModule as R, ref as c, inject as U, computed as n, watch as D, provide as J, openBlock as V, createElementBlock as W, renderSlot as G, createBlock as Z, normalizeClass as q, unref as H, createCommentVNode as K } from "vue";
2
- import Q from "lodash-es/cloneDeep";
3
- import { M as $ } from "./Module.keys-CEsrW2f0.js";
4
- import X from "./Paginate.js";
5
- import { a as Y, D as w } from "./DataView.keys-C7eaZg2G.js";
6
- import { _ as O } from "./_plugin-vue_export-helper-CHgC5LLL.js";
7
- function b(e) {
8
- const r = e[0] === "-" ? "desc" : "asc";
9
- return { id: r === "asc" ? e : e.slice(1), order: r };
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 tt({ id: e, order: r }) {
12
- return `${r === "desc" ? "-" : ""}${e}`;
11
+ function et({ id: a, order: o }) {
12
+ return `${o === "desc" ? "-" : ""}${a}`;
13
13
  }
14
- function et({ newId: e, newOrder: r, oldId: f, oldOrder: t }) {
15
- if (e) {
16
- if (e !== f)
17
- return tt({ id: e, order: r || "asc" });
18
- if (!r && !t)
19
- return e;
20
- if (!(!r && t === "desc")) {
21
- if (!r && t === "asc")
22
- return `-${e}`;
23
- if (r === "asc" && !t)
24
- return e;
25
- if (!(r === "asc" && t === "asc")) {
26
- if (r === "asc" && t === "desc")
27
- return e;
28
- if (r === "desc" && !t)
29
- return `-${e}`;
30
- if (!(r === "desc" && t === "desc") && r === "desc" && t === "asc")
31
- return `-${e}`;
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 at = /* @__PURE__ */ ((e) => (e.Table = "table", e))(at || {});
37
- const nt = /* @__PURE__ */ F({
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: Y },
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(e, { expose: r, emit: f }) {
54
- const t = e, d = f, x = R(), C = c(null), y = U($.key, $.defaults), I = n(() => {
55
- var a;
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 (((a = y.variant) == null ? void 0 : a.value) === "table")
59
+ if (((e = _.variant) == null ? void 0 : e.value) === "table")
59
60
  return "table";
60
- }), E = n(() => y.variant !== void 0), u = c(1), B = n(() => !t.disablePagination && t.totalDataCount > 0), p = n(() => Math.ceil(t.totalDataCount / t.pageSize)), i = function(a, { shouldEmit: o } = {}) {
61
- var l, h;
62
- u.value = a, o && (S(), d("update:currentPage", a, t.pageSize)), Number((l = C.value) == null ? void 0 : l.getBoundingClientRect().top) < 0 && ((h = C.value) == null || h.scrollIntoView({ behavior: "smooth", block: "start" }));
63
- }, P = function({ shouldEmit: a } = {}) {
64
- const o = Math.max(u.value - 1, 1);
65
- i(o, { shouldEmit: a });
66
- }, z = function({ shouldEmit: a } = {}) {
67
- const o = Math.min(u.value + 1, p.value);
68
- i(o, { shouldEmit: a });
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
- D(
71
+ y(
71
72
  () => t.currentPage,
72
73
  () => {
73
74
  i(t.currentPage);
74
75
  },
75
76
  { immediate: !0 }
76
77
  );
77
- const s = c(void 0), M = n(
78
- () => s.value ? b(s.value).id : void 0
79
- ), k = n(
80
- () => s.value ? b(s.value).order : void 0
81
- ), v = function(a, { sortOrder: o, shouldEmit: l } = {}) {
82
- const { id: h, order: A } = b(s.value || ""), N = et({ newId: a, newOrder: o, oldId: h, oldOrder: A });
83
- s.value = N, i(1), l && (S(), d("update:currentSort", N));
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
- D(
86
+ y(
86
87
  () => t.currentSort,
87
88
  () => {
88
89
  v(t.currentSort);
89
90
  },
90
91
  { immediate: !0 }
91
92
  );
92
- const g = c(""), L = c(!1), T = c(!1), m = function(a, { shouldEmit: o } = {}) {
93
- g.value = a || "", i(1), o && (S(), d("update:currentSearch", a));
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
- D(
96
+ y(
96
97
  () => t.currentSearch,
97
98
  () => {
98
99
  m(t.currentSearch);
99
100
  },
100
101
  { immediate: !0 }
101
102
  );
102
- const _ = c({}), j = function(a, { shouldEmit: o } = {}) {
103
- _.value = a, i(1), o && (S(), d("update:currentFilters", a));
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: Q(_.value)
112
+ filters: X(b.value)
112
113
  });
113
114
  }
114
- return J(
115
- w.key,
115
+ return W(
116
+ O.key,
116
117
  Object.freeze({
117
118
  // Pagination
118
119
  currentPage: n(() => u.value),
119
- isPaginationEnabled: B,
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: P,
125
- goNextPage: z,
126
+ goPrevPage: C,
127
+ goNextPage: D,
126
128
  // Sorting
127
- currentSortId: M,
128
- currentSortOrder: k,
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: L,
137
+ hasToolbar: T,
136
138
  isEmpty: n(() => t.data.length === 0),
137
- isSelectable: T,
139
+ isSelectable: j,
138
140
  isLoading: n(() => t.isLoading),
139
141
  isWithinModule: E,
140
- variant: I
142
+ variant: L
141
143
  })
142
- ), r({
144
+ ), o({
143
145
  page: n(() => u.value),
144
146
  pageSize: n(() => t.pageSize),
145
147
  setPage: i,
146
- goPrevPage: P,
147
- goNextPage: z,
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(() => _.value),
153
- updateCurrentFilters: j
154
- }), (a, o) => (V(), W("div", {
154
+ filters: n(() => b.value),
155
+ updateCurrentFilters: A
156
+ }), (e, r) => (V(), G("div", {
155
157
  ref_key: "rootRef",
156
- ref: C,
158
+ ref: P,
157
159
  class: "stash-data-view tw-relative",
158
160
  "data-test": "stash-data-view"
159
161
  }, [
160
- G(a.$slots, "default", {
162
+ Z(e.$slots, "default", {
161
163
  currentPage: u.value,
162
- currentSortId: M.value,
163
- currentSortOrder: k.value,
164
- data: a.data,
165
- goPrevPage: P,
166
- goNextPage: z,
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
- B.value && !E.value && p.value > 1 && !t.hideBottomPagination ? (V(), Z(X, {
175
+ N.value && !E.value && p.value > 1 && !t.hideBottomPagination ? (V(), q(Y, {
174
176
  key: 0,
175
- class: q(["tw-mt-6", H(x).paginate]),
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
- onSetPage: o[0] || (o[0] = (l) => i(l, { shouldEmit: !0 }))
180
- }, null, 8, ["class", "current-page", "list-length", "page-size"])) : K("", !0)
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", ot = {
187
+ }), rt = "_paginate_1jnlh_2", it = {
184
188
  paginate: rt
185
- }, it = {
186
- $style: ot
187
- }, pt = /* @__PURE__ */ O(nt, [["__cssModules", it]]);
189
+ }, ut = {
190
+ $style: it
191
+ }, vt = /* @__PURE__ */ tt(ot, [["__cssModules", ut]]);
188
192
  export {
189
- w as DATA_VIEW_INJECTION,
190
- Y as DEFAULT_PAGE_SIZE,
191
- at as DataViewVariant,
192
- pt as default,
193
- b as deserializeSortValue,
194
- et as getNextSort,
195
- tt as serializeSortValue
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
@@ -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":";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AAAG;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;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,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A,QACA,wBAAAC;AAAA,QACA,WAAAC;AAAA,QACA,UAAUN,EAAS,MAAMZ,EAAM,QAAQ;AAAA,QACvC,gBAAgBY,EAAS,MAAMZ,EAAM,cAAc;AAAA,QACnD,SAAAmB;AAAA,QACA,YAAAK;AAAA,QACA,YAAAC;AAAA;AAAA,QAGA,eAAeG;AAAA,QACf,kBAAkBC;AAAA,QAClB,mBAAAC;AAAA;AAAA,QAGA,eAAelB,EAAS,MAAMsB,EAAe,KAAK;AAAA,QAClD,qBAAAG;AAAA;AAAA,QAGA,SAASzB,EAAS,MAAMZ,EAAM,OAAO;AAAA,QACrC,YAAAmC;AAAA,QACA,SAASvB,EAAS,MAAMZ,EAAM,KAAK,WAAW,CAAC;AAAA,QAC/C,cAAAoC;AAAA,QACA,WAAWxB,EAAS,MAAMZ,EAAM,SAAS;AAAA,QACzC,gBAAAc;AAAA,QACA,SAASH;AAAA,MACV,CAAA;AAAA,IACH,GAEakC,EAAA;AAAA,MACX,MAAMjC,EAAS,MAAMG,EAAa,KAAK;AAAA,MACvC,UAAUH,EAAS,MAAMZ,EAAM,QAAQ;AAAA,MACvC,SAAAmB;AAAA,MACA,YAAAK;AAAA,MACA,YAAAC;AAAA,MACA,UAAUb,EAAS,MAAMe,EAAa,KAAK;AAAA,MAC3C,mBAAAG;AAAA,MACA,QAAQlB,EAAS,MAAMsB,EAAe,KAAK;AAAA,MAC3C,qBAAAG;AAAA,MACA,SAASzB,EAAS,MAAM2B,EAAgB,KAAK;AAAA,MAC7C,sBAAAC;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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-C7eaZg2G.js.map
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;"}
@@ -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;
@@ -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-C7eaZg2G.js";
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-C7eaZg2G.js";
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";