@leaflink/stash 46.7.2 → 46.8.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/DataView.js CHANGED
@@ -1,25 +1,25 @@
1
- import { defineComponent as A, useCssModule as F, ref as d, inject as T, computed as r, watch as D, provide as j, openBlock as V, createElementBlock as R, renderSlot as U, createBlock as J, normalizeClass as W, unref as G, createCommentVNode as Z } from "vue";
2
- import q from "lodash-es/cloneDeep";
1
+ import { defineComponent as F, useCssModule as j, ref as l, inject as R, computed as r, watch as D, provide as U, openBlock as V, createElementBlock as J, renderSlot as W, createBlock as G, normalizeClass as Z, unref as q, createCommentVNode as H } from "vue";
2
+ import K from "lodash-es/cloneDeep";
3
3
  import { M as $ } from "./Module.keys-2cc7d830.js";
4
- import H from "./Paginate.js";
5
- import { a as K, D as Q, s as X } from "./DataView.vue_used_vue_type_style_index_0_lang.module-d878ca9a.js";
6
- import { _ as Y } from "./_plugin-vue_export-helper-dad06003.js";
4
+ import Q from "./Paginate.js";
5
+ import { a as X, D as Y, s as w } from "./DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js";
6
+ import { _ as O } from "./_plugin-vue_export-helper-dad06003.js";
7
7
  import "./Icon.js";
8
8
  import "lodash-es/uniqueId";
9
9
  import "./index-79ce320f.js";
10
10
  import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
11
11
  import "./Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js";
12
- function _(e) {
12
+ function b(e) {
13
13
  const n = e[0] === "-" ? "desc" : "asc";
14
14
  return { id: n === "asc" ? e : e.slice(1), order: n };
15
15
  }
16
- function w({ id: e, order: n }) {
16
+ function tt({ id: e, order: n }) {
17
17
  return `${n === "desc" ? "-" : ""}${e}`;
18
18
  }
19
- function O({ newId: e, newOrder: n, oldId: i, oldOrder: t }) {
19
+ function et({ newId: e, newOrder: n, oldId: i, oldOrder: t }) {
20
20
  if (e) {
21
21
  if (e !== i)
22
- return w({ id: e, order: n || "asc" });
22
+ return tt({ id: e, order: n || "asc" });
23
23
  if (!n && !t)
24
24
  return e;
25
25
  if (!(!n && t === "desc")) {
@@ -38,8 +38,8 @@ function O({ newId: e, newOrder: n, oldId: i, oldOrder: t }) {
38
38
  }
39
39
  }
40
40
  }
41
- var tt = /* @__PURE__ */ ((e) => (e.Table = "table", e))(tt || {});
42
- const et = /* @__PURE__ */ A({
41
+ var at = /* @__PURE__ */ ((e) => (e.Table = "table", e))(at || {});
42
+ const rt = /* @__PURE__ */ F({
43
43
  __name: "DataView",
44
44
  props: {
45
45
  currentPage: { default: 1 },
@@ -47,7 +47,7 @@ const et = /* @__PURE__ */ A({
47
47
  currentSort: { default: void 0 },
48
48
  data: { default: () => [] },
49
49
  density: { default: "comfortable" },
50
- pageSize: { default: K },
50
+ pageSize: { default: X },
51
51
  disablePagination: { type: Boolean, default: !1 },
52
52
  totalDataCount: { default: 0 },
53
53
  variant: { default: void 0 },
@@ -55,15 +55,15 @@ const et = /* @__PURE__ */ A({
55
55
  },
56
56
  emits: ["update", "update:currentFilters", "update:currentPage", "update:currentSearch", "update:currentSort"],
57
57
  setup(e, { expose: n, emit: i }) {
58
- const t = e, x = F(), h = d(null), b = T($.key, $.defaults), B = r(() => {
58
+ const t = e, x = j(), h = l(null), _ = R($.key, $.defaults), B = r(() => {
59
59
  var a;
60
60
  if (t.variant)
61
61
  return t.variant;
62
- if (((a = b.variant) == null ? void 0 : a.value) === "table")
62
+ if (((a = _.variant) == null ? void 0 : a.value) === "table")
63
63
  return "table";
64
- }), y = r(() => b.variant !== void 0), s = d(1), E = r(() => !t.disablePagination && t.totalDataCount > 0), p = r(() => Math.ceil(t.totalDataCount / t.pageSize)), u = function(a, { shouldEmit: o } = {}) {
65
- var l, S;
66
- s.value = a, o && (m(), i("update:currentPage", a, t.pageSize)), Number((l = h.value) == null ? void 0 : l.getBoundingClientRect().top) < 0 && ((S = h.value) == null || S.scrollIntoView({ behavior: "smooth", block: "start" }));
64
+ }), y = r(() => _.variant !== void 0), s = l(1), E = r(() => !t.disablePagination && t.totalDataCount > 0), p = r(() => Math.ceil(t.totalDataCount / t.pageSize)), u = function(a, { shouldEmit: o } = {}) {
65
+ var d, m;
66
+ s.value = a, o && (S(), i("update:currentPage", a, t.pageSize)), Number((d = h.value) == null ? void 0 : d.getBoundingClientRect().top) < 0 && ((m = h.value) == null || m.scrollIntoView({ behavior: "smooth", block: "start" }));
67
67
  }, C = function({ shouldEmit: a } = {}) {
68
68
  const o = Math.max(s.value - 1, 1);
69
69
  u(o, { shouldEmit: a });
@@ -78,13 +78,13 @@ const et = /* @__PURE__ */ A({
78
78
  },
79
79
  { immediate: !0 }
80
80
  );
81
- const c = d(void 0), M = r(
82
- () => c.value ? _(c.value).id : void 0
81
+ const c = l(void 0), M = r(
82
+ () => c.value ? b(c.value).id : void 0
83
83
  ), k = r(
84
- () => c.value ? _(c.value).order : void 0
85
- ), f = function(a, { sortOrder: o, shouldEmit: l } = {}) {
86
- const { id: S, order: L } = _(c.value || ""), N = O({ newId: a, newOrder: o, oldId: S, oldOrder: L });
87
- c.value = N, u(1), l && (m(), i("update:currentSort", N));
84
+ () => c.value ? b(c.value).order : void 0
85
+ ), f = function(a, { sortOrder: o, shouldEmit: d } = {}) {
86
+ const { id: m, order: A } = b(c.value || ""), N = et({ newId: a, newOrder: o, oldId: m, oldOrder: A });
87
+ c.value = N, u(1), d && (S(), i("update:currentSort", N));
88
88
  };
89
89
  D(
90
90
  () => t.currentSort,
@@ -93,8 +93,8 @@ const et = /* @__PURE__ */ A({
93
93
  },
94
94
  { immediate: !0 }
95
95
  );
96
- const v = d(""), g = function(a, { shouldEmit: o } = {}) {
97
- v.value = a || "", u(1), o && (m(), i("update:currentSearch", a));
96
+ const v = l(""), I = l(!1), L = l(!1), g = function(a, { shouldEmit: o } = {}) {
97
+ v.value = a || "", u(1), o && (S(), i("update:currentSearch", a));
98
98
  };
99
99
  D(
100
100
  () => t.currentSearch,
@@ -103,20 +103,20 @@ const et = /* @__PURE__ */ A({
103
103
  },
104
104
  { immediate: !0 }
105
105
  );
106
- const z = d({}), I = function(a, { shouldEmit: o } = {}) {
107
- z.value = a, u(1), o && (m(), i("update:currentFilters", a));
106
+ const z = l({}), T = function(a, { shouldEmit: o } = {}) {
107
+ z.value = a, u(1), o && (S(), i("update:currentFilters", a));
108
108
  };
109
- function m() {
109
+ function S() {
110
110
  i("update", {
111
111
  page: s.value,
112
112
  pageSize: t.pageSize,
113
113
  ordering: c.value,
114
114
  search: v.value,
115
- filters: q(z.value)
115
+ filters: K(z.value)
116
116
  });
117
117
  }
118
- return j(
119
- Q.key,
118
+ return U(
119
+ Y.key,
120
120
  Object.freeze({
121
121
  // Pagination
122
122
  currentPage: r(() => s.value),
@@ -136,8 +136,10 @@ const et = /* @__PURE__ */ A({
136
136
  updateCurrentSearch: g,
137
137
  // Miscellaneous
138
138
  density: r(() => t.density),
139
- isLoading: r(() => t.isLoading),
139
+ hasToolbar: I,
140
140
  isEmpty: r(() => t.data.length === 0),
141
+ isSelectable: L,
142
+ isLoading: r(() => t.isLoading),
141
143
  isWithinModule: y,
142
144
  variant: B
143
145
  })
@@ -152,14 +154,14 @@ const et = /* @__PURE__ */ A({
152
154
  search: r(() => v.value),
153
155
  updateCurrentSearch: g,
154
156
  filters: r(() => z.value),
155
- updateCurrentFilters: I
156
- }), (a, o) => (V(), R("div", {
157
+ updateCurrentFilters: T
158
+ }), (a, o) => (V(), J("div", {
157
159
  ref_key: "rootRef",
158
160
  ref: h,
159
161
  class: "stash-data-view tw-relative",
160
162
  "data-test": "stash-data-view"
161
163
  }, [
162
- U(a.$slots, "default", {
164
+ W(a.$slots, "default", {
163
165
  currentPage: s.value,
164
166
  currentSortId: M.value,
165
167
  currentSortOrder: k.value,
@@ -172,26 +174,26 @@ const et = /* @__PURE__ */ A({
172
174
  updateCurrentSort: f,
173
175
  updateCurrentSearch: g
174
176
  }),
175
- E.value && !y.value && p.value > 1 ? (V(), J(H, {
177
+ E.value && !y.value && p.value > 1 ? (V(), G(Q, {
176
178
  key: 0,
177
- class: W(["tw-mt-6", G(x).paginate]),
179
+ class: Z(["tw-mt-6", q(x).paginate]),
178
180
  "current-page": s.value,
179
181
  "list-length": t.totalDataCount,
180
182
  "page-size": t.pageSize,
181
- onSetPage: o[0] || (o[0] = (l) => u(l, { shouldEmit: !0 }))
182
- }, null, 8, ["class", "current-page", "list-length", "page-size"])) : Z("", !0)
183
+ onSetPage: o[0] || (o[0] = (d) => u(d, { shouldEmit: !0 }))
184
+ }, null, 8, ["class", "current-page", "list-length", "page-size"])) : H("", !0)
183
185
  ], 512));
184
186
  }
185
- }), at = {
186
- $style: X
187
- }, vt = /* @__PURE__ */ Y(et, [["__cssModules", at]]);
187
+ }), nt = {
188
+ $style: w
189
+ }, St = /* @__PURE__ */ O(rt, [["__cssModules", nt]]);
188
190
  export {
189
- Q as DATA_VIEW_INJECTION,
190
- K as DEFAULT_PAGE_SIZE,
191
- tt as DataViewVariant,
192
- vt as default,
193
- _ as deserializeSortValue,
194
- O as getNextSort,
195
- w as serializeSortValue
191
+ Y as DATA_VIEW_INJECTION,
192
+ X as DEFAULT_PAGE_SIZE,
193
+ at as DataViewVariant,
194
+ St as default,
195
+ b as deserializeSortValue,
196
+ et as getNextSort,
197
+ tt as serializeSortValue
196
198
  };
197
199
  //# 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 } 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 * 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 * 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 * 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 variant: undefined,\n });\n\n const emit =\n 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 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 isLoading: computed(() => props.isLoading),\n isEmpty: computed(() => props.data.length === 0),\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\"\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","classes","useCssModule","rootRef","ref","moduleInjection","inject","MODULE_INJECTION","computedVariant","computed","props","_a","isWithinModule","internalPage","isPaginationEnabled","pageCount","setPage","page","shouldEmit","emitUpdate","emit","_b","goPrevPage","goNextPage","watch","internalSort","internalSortId","internalSortOrder","updateCurrentSort","sortId","sortOrder","nextSort","internalSearch","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;AACf;AAKO,SAASC,EAAmB,EAAE,IAAAC,GAAI,OAAAF,KAA2C;AAClF,SAAO,GAAGA,MAAU,SAAS,MAAM,EAAE,GAAGE,CAAE;AAC5C;AAcO,SAASC,EAAY,EAAE,OAAAC,GAAO,UAAAC,GAAU,OAAAC,GAAO,UAAAC,KAAoD;AACxG,MAAKH,GAIL;AAAA,QAAIA,MAAUE;AAEZ,a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AAA,QAGA,eAAeG;AAAA,QACf,kBAAkBC;AAAA,QAClB,mBAAAC;AAAA;AAAA,QAGA,eAAenB,EAAS,MAAMuB,EAAe,KAAK;AAAA,QAClD,qBAAAC;AAAA;AAAA,QAGA,SAASxB,EAAS,MAAMC,EAAM,OAAO;AAAA,QACrC,WAAWD,EAAS,MAAMC,EAAM,SAAS;AAAA,QACzC,SAASD,EAAS,MAAMC,EAAM,KAAK,WAAW,CAAC;AAAA,QAC/C,gBAAAE;AAAA,QACA,SAASJ;AAAA,MAAA,CACV;AAAA,IAAA,GAGUiC,EAAA;AAAA,MACX,MAAMhC,EAAS,MAAMI,EAAa,KAAK;AAAA,MACvC,UAAUJ,EAAS,MAAMC,EAAM,QAAQ;AAAA,MACvC,SAAAM;AAAA,MACA,YAAAM;AAAA,MACA,YAAAC;AAAA,MACA,UAAUd,EAAS,MAAMgB,EAAa,KAAK;AAAA,MAC3C,mBAAAG;AAAA,MACA,QAAQnB,EAAS,MAAMuB,EAAe,KAAK;AAAA,MAC3C,qBAAAC;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 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.\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 * 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 variant: undefined,\n });\n\n const emit =\n 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\"\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","classes","useCssModule","rootRef","ref","moduleInjection","inject","MODULE_INJECTION","computedVariant","computed","props","_a","isWithinModule","internalPage","isPaginationEnabled","pageCount","setPage","page","shouldEmit","emitUpdate","emit","_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;AACf;AAKO,SAASC,GAAmB,EAAE,IAAAC,GAAI,OAAAF,KAA2C;AAClF,SAAO,GAAGA,MAAU,SAAS,MAAM,EAAE,GAAGE,CAAE;AAC5C;AAcO,SAASC,GAAY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AA,QACA,WAAAC;AAAA,QACA,UAAUN,EAAS,MAAMC,EAAM,QAAQ;AAAA,QACvC,gBAAgBD,EAAS,MAAMC,EAAM,cAAc;AAAA,QACnD,SAAAM;AAAA,QACA,YAAAM;AAAA,QACA,YAAAC;AAAA;AAAA,QAGA,eAAeG;AAAA,QACf,kBAAkBC;AAAA,QAClB,mBAAAC;AAAA;AAAA,QAGA,eAAenB,EAAS,MAAMuB,EAAe,KAAK;AAAA,QAClD,qBAAAG;AAAA;AAAA,QAGA,SAAS1B,EAAS,MAAMC,EAAM,OAAO;AAAA,QACrC,YAAAuB;AAAA,QACA,SAASxB,EAAS,MAAMC,EAAM,KAAK,WAAW,CAAC;AAAA,QAC/C,cAAAwB;AAAA,QACA,WAAWzB,EAAS,MAAMC,EAAM,SAAS;AAAA,QACzC,gBAAAE;AAAA,QACA,SAASJ;AAAA,MAAA,CACV;AAAA,IAAA,GAGUmC,EAAA;AAAA,MACX,MAAMlC,EAAS,MAAMI,EAAa,KAAK;AAAA,MACvC,UAAUJ,EAAS,MAAMC,EAAM,QAAQ;AAAA,MACvC,SAAAM;AAAA,MACA,YAAAM;AAAA,MACA,YAAAC;AAAA,MACA,UAAUd,EAAS,MAAMgB,EAAa,KAAK;AAAA,MAC3C,mBAAAG;AAAA,MACA,QAAQnB,EAAS,MAAMuB,EAAe,KAAK;AAAA,MAC3C,qBAAAG;AAAA,MACA,SAAS1B,EAAS,MAAM4B,EAAgB,KAAK;AAAA,MAC7C,sBAAAC;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -6,6 +6,7 @@ import { DefineComponent } from 'vue';
6
6
  import { ExtractPropTypes } from 'vue';
7
7
  import { InjectionKey } from 'vue';
8
8
  import { PropType } from 'vue';
9
+ import { Ref } from 'vue';
9
10
  import { VNodeProps } from 'vue';
10
11
 
11
12
  declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -64,6 +65,10 @@ export declare interface DataViewInjection {
64
65
  * The DataView's padding; the default value is "comfortable". On small screens, the density will always be "compact".
65
66
  */
66
67
  density: ComputedRef<SpacingDensities | undefined>;
68
+ /**
69
+ * Defines if a DataView has a Toolbar rendered.
70
+ */
71
+ hasToolbar?: Ref<boolean>;
67
72
  /**
68
73
  * Enables certain loading indicators to be displayed within the DataView.
69
74
  */
@@ -72,6 +77,10 @@ export declare interface DataViewInjection {
72
77
  * Enables certain empty states to be displayed within the DataView.
73
78
  */
74
79
  isEmpty?: ComputedRef<boolean>;
80
+ /**
81
+ * Allows Table to control whether or not a DataViewToolbar should show a checkmark
82
+ */
83
+ isSelectable?: Ref<boolean>;
75
84
  /**
76
85
  * Whether or not the DataView is rendered within a Module; the value is inferred based on being
77
86
  * able to inject details from Module.
@@ -1,12 +1,12 @@
1
- import { computed as e } from "vue";
2
- const t = 12, o = Object.freeze({
1
+ import { computed as e, ref as t } from "vue";
2
+ const a = 12, n = Object.freeze({
3
3
  key: Symbol("DATA_VIEW_INJECTION_KEY"),
4
4
  defaults: Object.freeze({
5
5
  // Pagination
6
6
  currentPage: e(() => 1),
7
7
  isPaginationEnabled: e(() => !1),
8
8
  pageCount: e(() => 1),
9
- pageSize: e(() => t),
9
+ pageSize: e(() => a),
10
10
  totalDataCount: e(() => 0),
11
11
  setPage() {
12
12
  },
@@ -28,18 +28,19 @@ const t = 12, o = Object.freeze({
28
28
  // Miscellanous
29
29
  density: e(() => {
30
30
  }),
31
- isLoading: e(() => !1),
32
31
  isEmpty: e(() => !1),
32
+ isLoading: e(() => !1),
33
+ isSelectable: t(!1),
33
34
  isWithinModule: e(() => !1),
34
35
  variant: e(() => {
35
36
  })
36
37
  })
37
- }), a = "_paginate_1jnlh_2", n = {
38
- paginate: a
38
+ }), r = "_paginate_1jnlh_2", s = {
39
+ paginate: r
39
40
  };
40
41
  export {
41
- o as D,
42
- t as a,
43
- n as s
42
+ n as D,
43
+ a,
44
+ s
44
45
  };
45
- //# sourceMappingURL=DataView.vue_used_vue_type_style_index_0_lang.module-d878ca9a.js.map
46
+ //# sourceMappingURL=DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.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 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,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,MAAM;AAAA,KAAS;AAAA,EAAA,CAClC;AACH,CAAC;;;"}
@@ -7,7 +7,7 @@ import A from "./Button.js";
7
7
  import T from "lodash-es/cloneDeep";
8
8
  import $ from "./Icon.js";
9
9
  import "./Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js";
10
- import { D as G } from "./DataView.vue_used_vue_type_style_index_0_lang.module-d878ca9a.js";
10
+ import { D as G } from "./DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js";
11
11
  import q from "./FilterChip.js";
12
12
  import { _ as H } from "./Label.vue_vue_type_script_setup_true_lang-4b02087f.js";
13
13
  import K from "./Modal.js";
@@ -4,7 +4,7 @@ import u from "./Button.js";
4
4
  import "lodash-es/cloneDeep";
5
5
  import h from "./Icon.js";
6
6
  import "./Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js";
7
- import { D as C } from "./DataView.vue_used_vue_type_style_index_0_lang.module-d878ca9a.js";
7
+ import { D as C } from "./DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js";
8
8
  import E from "./Dropdown.js";
9
9
  import I from "./IconLabel.js";
10
10
  import { _ as N } from "./_plugin-vue_export-helper-dad06003.js";
@@ -1,91 +1,114 @@
1
- import { defineComponent as S, inject as V, computed as g, openBlock as o, createElementBlock as r, normalizeClass as N, unref as t, createElementVNode as D, renderSlot as B, toDisplayString as I, createCommentVNode as d, Fragment as T, createVNode as n, withCtx as b } from "vue";
2
- import { t as $ } from "./locale.js";
3
- import h from "./Button.js";
1
+ import { defineComponent as T, inject as A, ref as M, computed as x, onBeforeMount as $, openBlock as a, createElementBlock as n, normalizeClass as j, unref as e, createElementVNode as k, createBlock as z, createCommentVNode as r, renderSlot as U, toDisplayString as W, Fragment as F, createVNode as s, withCtx as S } from "vue";
2
+ import { t as y } from "./locale.js";
3
+ import _ from "./Button.js";
4
+ import J from "./Checkbox.js";
4
5
  import "lodash-es/cloneDeep";
5
- import x from "./Icon.js";
6
+ import C from "./Icon.js";
6
7
  import "./Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js";
7
- import { D as _ } from "./DataView.vue_used_vue_type_style_index_0_lang.module-d878ca9a.js";
8
+ import { D as B } from "./DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js";
8
9
  import "lodash-es/get";
9
10
  import "./Button.vue_used_vue_type_style_index_0_lang.module-63d31dc0.js";
10
11
  import "./_plugin-vue_export-helper-dad06003.js";
12
+ import "@leaflink/snitch";
11
13
  import "lodash-es/uniqueId";
14
+ import "./Checkbox.vue_used_vue_type_style_index_0_lang.module-fa8d9c06.js";
12
15
  import "./index-79ce320f.js";
13
16
  import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
14
- const j = { class: "tw-flex tw-items-center tw-gap-x-2 lg:tw-gap-x-6" }, z = {
17
+ const K = { class: "tw-flex tw-place-items-center" }, O = { class: "tw-flex tw-items-center tw-gap-x-2 lg:tw-gap-x-6" }, q = {
15
18
  key: 0,
16
19
  class: "tw-flex tw-items-center"
17
- }, A = {
20
+ }, G = {
18
21
  key: 0,
19
22
  class: "tw-mr-1.5 tw-text-xs"
20
- }, X = /* @__PURE__ */ S({
23
+ }, ce = /* @__PURE__ */ T({
21
24
  __name: "DataViewToolbar",
22
25
  props: {
26
+ allRowsSelected: { type: Boolean, default: !1 },
23
27
  hidePageStats: { type: Boolean, default: !1 },
24
- radius: { default: "rounded" }
28
+ radius: { default: "rounded" },
29
+ someRowsSelected: { type: Boolean, default: !1 }
25
30
  },
26
- setup(y) {
27
- const u = y, {
28
- isWithinModule: s,
29
- variant: m,
30
- density: p,
31
- currentPage: a,
32
- isPaginationEnabled: C,
33
- pageCount: c,
34
- pageSize: w,
35
- totalDataCount: f,
36
- goPrevPage: k,
37
- goNextPage: E
38
- } = V(_.key, _.defaults), v = g(() => s.value ? "none" : m.value === "table" ? "rounded-top" : u.radius), P = g(() => {
39
- const i = w.value * (a.value - 1) + 1, e = Math.min(w.value * a.value, f.value), l = f.value;
40
- return $("ll.pageStats", { from: i, to: e, total: l });
31
+ emits: ["select"],
32
+ setup(E, { emit: P }) {
33
+ const o = E, {
34
+ isWithinModule: i,
35
+ variant: u,
36
+ density: m,
37
+ currentPage: l,
38
+ hasToolbar: p,
39
+ isPaginationEnabled: V,
40
+ isSelectable: N,
41
+ pageCount: w,
42
+ pageSize: f,
43
+ totalDataCount: v,
44
+ goPrevPage: R,
45
+ goNextPage: D
46
+ } = A(B.key, B.defaults), h = M(0), b = x(() => i.value ? "none" : u.value === "table" ? "rounded-top" : o.radius), I = x(() => {
47
+ const d = f.value * (l.value - 1) + 1, t = Math.min(f.value * l.value, v.value), c = v.value;
48
+ return y("ll.pageStats", { from: d, to: t, total: c });
41
49
  });
42
- return (i, e) => (o(), r("div", {
43
- class: N(["stash-data-view-toolbar tw-flex tw-min-h-15 tw-items-center tw-justify-between tw-bg-white tw-py-1.5", {
44
- "tw-border-t tw-border-ice-200": t(s),
45
- "tw-rounded": v.value === "rounded",
46
- "tw-rounded-t": v.value === "rounded-top",
47
- "tw-mb-3": t(m) !== "table" && !t(s),
48
- "tw-px-0": t(p) === "compact",
49
- "lg:tw-px-3": t(p) === "comfortable"
50
+ function g() {
51
+ P("select"), h.value++;
52
+ }
53
+ return $(() => {
54
+ p && (p.value = !0);
55
+ }), (d, t) => (a(), n("div", {
56
+ class: j(["stash-data-view-toolbar tw-flex tw-min-h-15 tw-items-center tw-justify-between tw-bg-white tw-py-1.5", {
57
+ "tw-border-t tw-border-ice-200": e(i),
58
+ "tw-rounded": b.value === "rounded",
59
+ "tw-rounded-t": b.value === "rounded-top",
60
+ "tw-mb-3": e(u) !== "table" && !e(i),
61
+ "tw-px-0": e(m) === "compact",
62
+ "lg:tw-px-3": e(m) === "comfortable"
50
63
  }]),
51
64
  "data-test": "stash-data-view-toolbar"
52
65
  }, [
53
- D("div", j, [
54
- B(i.$slots, "default")
66
+ k("div", K, [
67
+ e(N) ? (a(), z(J, {
68
+ key: h.value,
69
+ checked: o.allRowsSelected,
70
+ indeterminate: o.someRowsSelected && !o.allRowsSelected,
71
+ title: e(y)("ll.selectAll"),
72
+ "onUpdate:indeterminate": g,
73
+ "onUpdate:checked": g
74
+ }, null, 8, ["checked", "indeterminate", "title"])) : r("", !0),
75
+ k("div", O, [
76
+ U(d.$slots, "default")
77
+ ])
55
78
  ]),
56
- t(C) ? (o(), r("div", z, [
57
- u.hidePageStats ? d("", !0) : (o(), r("span", A, I(P.value), 1)),
58
- t(c) > 1 ? (o(), r(T, { key: 1 }, [
59
- n(h, {
79
+ e(V) ? (a(), n("div", q, [
80
+ o.hidePageStats ? r("", !0) : (a(), n("span", G, W(I.value), 1)),
81
+ e(w) > 1 ? (a(), n(F, { key: 1 }, [
82
+ s(_, {
60
83
  icon: "",
61
84
  class: "tw-h-9 tw-w-9 tw-p-1.5",
62
85
  "data-test": "button|prev-page",
63
- disabled: t(a) === 1,
64
- onClick: e[0] || (e[0] = (l) => t(k)({ shouldEmit: !0 }))
86
+ disabled: e(l) === 1,
87
+ onClick: t[0] || (t[0] = (c) => e(R)({ shouldEmit: !0 }))
65
88
  }, {
66
- default: b(() => [
67
- n(x, { name: "chevron-left" })
89
+ default: S(() => [
90
+ s(C, { name: "chevron-left" })
68
91
  ]),
69
92
  _: 1
70
93
  }, 8, ["disabled"]),
71
- n(h, {
94
+ s(_, {
72
95
  icon: "",
73
96
  class: "tw-h-9 tw-w-9 tw-p-1.5",
74
97
  "data-test": "button|next-page",
75
- disabled: t(a) === t(c),
76
- onClick: e[1] || (e[1] = (l) => t(E)({ shouldEmit: !0 }))
98
+ disabled: e(l) === e(w),
99
+ onClick: t[1] || (t[1] = (c) => e(D)({ shouldEmit: !0 }))
77
100
  }, {
78
- default: b(() => [
79
- n(x, { name: "chevron-right" })
101
+ default: S(() => [
102
+ s(C, { name: "chevron-right" })
80
103
  ]),
81
104
  _: 1
82
105
  }, 8, ["disabled"])
83
- ], 64)) : d("", !0)
84
- ])) : d("", !0)
106
+ ], 64)) : r("", !0)
107
+ ])) : r("", !0)
85
108
  ], 2));
86
109
  }
87
110
  });
88
111
  export {
89
- X as default
112
+ ce as default
90
113
  };
91
114
  //# sourceMappingURL=DataViewToolbar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataViewToolbar.js","sources":["../src/components/DataViewToolbar/DataViewToolbar.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, inject } from 'vue';\n\n import { t } from '../../locale';\n import Button from '../Button/Button.vue';\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import Icon from '../Icon/Icon.vue';\n import { ToolbarRadiuses } from './DataViewToolbar.types';\n\n export interface DataViewToolbarProps {\n /**\n * Hides the page statistics (ex: \"1 - 12 of 20\") in the toolbar\n */\n hidePageStats?: boolean;\n\n /**\n * Controls the corners of DataViewToolbar with the \"border-radius\" CSS property. The default value is \"rounded\".\n */\n radius?: ToolbarRadiuses;\n }\n\n const props = withDefaults(defineProps<DataViewToolbarProps>(), {\n hidePageStats: false,\n radius: 'rounded',\n });\n\n const {\n isWithinModule,\n variant: dataViewVariant,\n density,\n currentPage,\n isPaginationEnabled,\n pageCount,\n pageSize,\n totalDataCount,\n goPrevPage,\n goNextPage,\n } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n const computedRadius = computed<ToolbarRadiuses>(() => {\n if (isWithinModule.value) {\n return 'none';\n }\n\n if (dataViewVariant.value === 'table') {\n return 'rounded-top';\n }\n\n return props.radius;\n });\n\n // #region pagination\n const pageStats = computed(() => {\n const from = pageSize.value * (currentPage.value - 1) + 1;\n const to = Math.min(pageSize.value * currentPage.value, totalDataCount.value);\n const total = totalDataCount.value;\n\n return t('ll.pageStats', { from, to, total });\n });\n // #endregion pagination\n</script>\n\n<template>\n <div\n class=\"stash-data-view-toolbar tw-flex tw-min-h-15 tw-items-center tw-justify-between tw-bg-white tw-py-1.5\"\n :class=\"{\n 'tw-border-t tw-border-ice-200': isWithinModule,\n 'tw-rounded': computedRadius === 'rounded',\n 'tw-rounded-t': computedRadius === 'rounded-top',\n 'tw-mb-3': dataViewVariant !== 'table' && !isWithinModule,\n 'tw-px-0': density === 'compact',\n 'lg:tw-px-3': density === 'comfortable',\n }\"\n data-test=\"stash-data-view-toolbar\"\n >\n <div class=\"tw-flex tw-items-center tw-gap-x-2 lg:tw-gap-x-6\">\n <!-- @slot default -->\n <slot></slot>\n </div>\n\n <!-- Pagination -->\n <div v-if=\"isPaginationEnabled\" class=\"tw-flex tw-items-center\">\n <span v-if=\"!props.hidePageStats\" class=\"tw-mr-1.5 tw-text-xs\">\n {{ pageStats }}\n </span>\n <template v-if=\"pageCount > 1\">\n <Button\n icon\n class=\"tw-h-9 tw-w-9 tw-p-1.5\"\n data-test=\"button|prev-page\"\n :disabled=\"currentPage === 1\"\n @click=\"goPrevPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-left\" />\n </Button>\n <Button\n icon\n class=\"tw-h-9 tw-w-9 tw-p-1.5\"\n data-test=\"button|next-page\"\n :disabled=\"currentPage === pageCount\"\n @click=\"goNextPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-right\" />\n </Button>\n </template>\n </div>\n </div>\n</template>\n"],"names":["isWithinModule","dataViewVariant","density","currentPage","isPaginationEnabled","pageCount","pageSize","totalDataCount","goPrevPage","goNextPage","inject","DATA_VIEW_INJECTION","computedRadius","computed","props","pageStats","from","to","total","t"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BQ;AAAA,MACJ,gBAAAA;AAAA,MACA,SAASC;AAAA,MACT,SAAAC;AAAA,MACA,aAAAC;AAAA,MACA,qBAAAC;AAAA,MACA,WAAAC;AAAA,MACA,UAAAC;AAAA,MACA,gBAAAC;AAAA,MACA,YAAAC;AAAA,MACA,YAAAC;AAAA,IACE,IAAAC,EAAOC,EAAoB,KAAKA,EAAoB,QAAQ,GAE1DC,IAAiBC,EAA0B,MAC3Cb,EAAe,QACV,SAGLC,EAAgB,UAAU,UACrB,gBAGFa,EAAM,MACd,GAGKC,IAAYF,EAAS,MAAM;AAC/B,YAAMG,IAAOV,EAAS,SAASH,EAAY,QAAQ,KAAK,GAClDc,IAAK,KAAK,IAAIX,EAAS,QAAQH,EAAY,OAAOI,EAAe,KAAK,GACtEW,IAAQX,EAAe;AAE7B,aAAOY,EAAE,gBAAgB,EAAE,MAAAH,GAAM,IAAAC,GAAI,OAAAC,GAAO;AAAA,IAAA,CAC7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"DataViewToolbar.js","sources":["../src/components/DataViewToolbar/DataViewToolbar.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed, inject, onBeforeMount, ref } from 'vue';\n\n import { t } from '../../locale';\n import Button from '../Button/Button.vue';\n import Checkbox from '../Checkbox/Checkbox.vue';\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import Icon from '../Icon/Icon.vue';\n import { ToolbarRadiuses } from './DataViewToolbar.types';\n\n export interface DataViewToolbarProps {\n /**\n * When DataView has `variant=\"table\"` and Table has `is-selectable` enabled, it provides a way to flag\n * a checkbox whenever all rows are selected, just like the standalone version on TableHeaderRow.\n */\n allRowsSelected?: boolean;\n\n /**\n * Hides the page statistics (ex: \"1 - 12 of 20\") in the toolbar\n */\n hidePageStats?: boolean;\n\n /**\n * Controls the corners of DataViewToolbar with the \"border-radius\" CSS property. The default value is \"rounded\".\n */\n radius?: ToolbarRadiuses;\n\n /**\n * When DataView has variant=\"table\" and Table has `is-selectable` enabled, it provides a way to flag\n * a checkbox whenever one or more, but not all rows are selected, just like the standalone\n * version on TableHeaderRow.\n */\n someRowsSelected?: boolean;\n }\n\n const props = withDefaults(defineProps<DataViewToolbarProps>(), {\n allRowsSelected: false,\n hidePageStats: false,\n radius: 'rounded',\n someRowsSelected: false,\n });\n\n const emit =\n defineEmits<{\n (e: 'select'): void;\n }>();\n\n const {\n isWithinModule,\n variant: dataViewVariant,\n density,\n currentPage,\n hasToolbar,\n isPaginationEnabled,\n isSelectable,\n pageCount,\n pageSize,\n totalDataCount,\n goPrevPage,\n goNextPage,\n } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n const checkboxKey = ref(0);\n\n const computedRadius = computed<ToolbarRadiuses>(() => {\n if (isWithinModule.value) {\n return 'none';\n }\n\n if (dataViewVariant.value === 'table') {\n return 'rounded-top';\n }\n\n return props.radius;\n });\n\n // #region pagination\n const pageStats = computed(() => {\n const from = pageSize.value * (currentPage.value - 1) + 1;\n const to = Math.min(pageSize.value * currentPage.value, totalDataCount.value);\n const total = totalDataCount.value;\n\n return t('ll.pageStats', { from, to, total });\n });\n // #endregion pagination\n\n function onSelect() {\n emit('select');\n\n /**\n * In Vue (as of this writing), if a user checks a native checkbox but the v-model is `false` and does not change from `false`, then the checkbox will display as checked even though the v-model is still `false`.\n * Forcing a re-render with a `key` change allows the checkbox to stay unchecked if its v-model is still `false` and its v-model not been changed.\n * To verify that this is necessary, test the \"select all\" checkbox in the SelectionWithSomeDisabled story in Table.story.ts with and without the `key` attribute.\n */\n checkboxKey.value++;\n }\n\n onBeforeMount(() => {\n if (hasToolbar) {\n hasToolbar.value = true;\n }\n });\n</script>\n\n<template>\n <div\n class=\"stash-data-view-toolbar tw-flex tw-min-h-15 tw-items-center tw-justify-between tw-bg-white tw-py-1.5\"\n :class=\"{\n 'tw-border-t tw-border-ice-200': isWithinModule,\n 'tw-rounded': computedRadius === 'rounded',\n 'tw-rounded-t': computedRadius === 'rounded-top',\n 'tw-mb-3': dataViewVariant !== 'table' && !isWithinModule,\n 'tw-px-0': density === 'compact',\n 'lg:tw-px-3': density === 'comfortable',\n }\"\n data-test=\"stash-data-view-toolbar\"\n >\n <div class=\"tw-flex tw-place-items-center\">\n <Checkbox\n v-if=\"isSelectable\"\n :key=\"checkboxKey\"\n :checked=\"props.allRowsSelected\"\n :indeterminate=\"props.someRowsSelected && !props.allRowsSelected\"\n :title=\"t('ll.selectAll')\"\n @update:indeterminate=\"onSelect\"\n @update:checked=\"onSelect\"\n />\n <div class=\"tw-flex tw-items-center tw-gap-x-2 lg:tw-gap-x-6\">\n <!-- @slot default -->\n <slot></slot>\n </div>\n </div>\n\n <!-- Pagination -->\n <div v-if=\"isPaginationEnabled\" class=\"tw-flex tw-items-center\">\n <span v-if=\"!props.hidePageStats\" class=\"tw-mr-1.5 tw-text-xs\">\n {{ pageStats }}\n </span>\n <template v-if=\"pageCount > 1\">\n <Button\n icon\n class=\"tw-h-9 tw-w-9 tw-p-1.5\"\n data-test=\"button|prev-page\"\n :disabled=\"currentPage === 1\"\n @click=\"goPrevPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-left\" />\n </Button>\n <Button\n icon\n class=\"tw-h-9 tw-w-9 tw-p-1.5\"\n data-test=\"button|next-page\"\n :disabled=\"currentPage === pageCount\"\n @click=\"goNextPage({ shouldEmit: true })\"\n >\n <Icon name=\"chevron-right\" />\n </Button>\n </template>\n </div>\n </div>\n</template>\n"],"names":["isWithinModule","dataViewVariant","density","currentPage","hasToolbar","isPaginationEnabled","isSelectable","pageCount","pageSize","totalDataCount","goPrevPage","goNextPage","inject","DATA_VIEW_INJECTION","checkboxKey","ref","computedRadius","computed","props","pageStats","from","to","total","t","onSelect","emit","onBeforeMount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+CQ;AAAA,MACJ,gBAAAA;AAAA,MACA,SAASC;AAAA,MACT,SAAAC;AAAA,MACA,aAAAC;AAAA,MACA,YAAAC;AAAA,MACA,qBAAAC;AAAA,MACA,cAAAC;AAAA,MACA,WAAAC;AAAA,MACA,UAAAC;AAAA,MACA,gBAAAC;AAAA,MACA,YAAAC;AAAA,MACA,YAAAC;AAAA,IACE,IAAAC,EAAOC,EAAoB,KAAKA,EAAoB,QAAQ,GAE1DC,IAAcC,EAAI,CAAC,GAEnBC,IAAiBC,EAA0B,MAC3CjB,EAAe,QACV,SAGLC,EAAgB,UAAU,UACrB,gBAGFiB,EAAM,MACd,GAGKC,IAAYF,EAAS,MAAM;AAC/B,YAAMG,IAAOZ,EAAS,SAASL,EAAY,QAAQ,KAAK,GAClDkB,IAAK,KAAK,IAAIb,EAAS,QAAQL,EAAY,OAAOM,EAAe,KAAK,GACtEa,IAAQb,EAAe;AAE7B,aAAOc,EAAE,gBAAgB,EAAE,MAAAH,GAAM,IAAAC,GAAI,OAAAC,GAAO;AAAA,IAAA,CAC7C;AAGD,aAASE,IAAW;AAClB,MAAAC,EAAK,QAAQ,GAODX,EAAA;AAAA,IACd;AAEA,WAAAY,EAAc,MAAM;AAClB,MAAItB,MACFA,EAAW,QAAQ;AAAA,IACrB,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}