@leaflink/stash 46.7.3 → 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 +51 -49
- package/dist/DataView.js.map +1 -1
- package/dist/DataView.vue.d.ts +9 -0
- package/dist/{DataView.vue_used_vue_type_style_index_0_lang.module-d878ca9a.js → DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js} +11 -10
- package/dist/DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js.map +1 -0
- package/dist/DataViewFilters.js +1 -1
- package/dist/DataViewSortButton.js +1 -1
- package/dist/DataViewToolbar.js +73 -50
- package/dist/DataViewToolbar.js.map +1 -1
- package/dist/DataViewToolbar.vue.d.ts +23 -2
- package/dist/FilterDropdown.js +1 -1
- package/dist/ListView.vue.d.ts +1 -1
- package/dist/Table.js +38 -35
- package/dist/Table.js.map +1 -1
- package/dist/TableCell.js +1 -1
- package/dist/TableHeaderCell.js +1 -1
- package/dist/TableHeaderRow.js +44 -40
- package/dist/TableHeaderRow.js.map +1 -1
- package/dist/TableRow.js +1 -1
- package/package.json +1 -1
- package/dist/DataView.vue_used_vue_type_style_index_0_lang.module-d878ca9a.js.map +0 -1
package/dist/DataView.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
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
|
|
5
|
-
import { a as
|
|
6
|
-
import { _ as
|
|
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
|
|
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
|
|
16
|
+
function tt({ id: e, order: n }) {
|
|
17
17
|
return `${n === "desc" ? "-" : ""}${e}`;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function et({ newId: e, newOrder: n, oldId: i, oldOrder: t }) {
|
|
20
20
|
if (e) {
|
|
21
21
|
if (e !== i)
|
|
22
|
-
return
|
|
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
|
|
42
|
-
const
|
|
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:
|
|
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 =
|
|
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 =
|
|
62
|
+
if (((a = _.variant) == null ? void 0 : a.value) === "table")
|
|
63
63
|
return "table";
|
|
64
|
-
}), y = r(() =>
|
|
65
|
-
var
|
|
66
|
-
s.value = a, o && (
|
|
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 =
|
|
82
|
-
() => c.value ?
|
|
81
|
+
const c = l(void 0), M = r(
|
|
82
|
+
() => c.value ? b(c.value).id : void 0
|
|
83
83
|
), k = r(
|
|
84
|
-
() => c.value ?
|
|
85
|
-
), f = function(a, { sortOrder: o, shouldEmit:
|
|
86
|
-
const { id:
|
|
87
|
-
c.value = N, u(1),
|
|
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 =
|
|
97
|
-
v.value = a || "", u(1), o && (
|
|
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 =
|
|
107
|
-
z.value = a, u(1), o && (
|
|
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
|
|
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:
|
|
115
|
+
filters: K(z.value)
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
|
-
return
|
|
119
|
-
|
|
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
|
-
|
|
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:
|
|
156
|
-
}), (a, o) => (V(),
|
|
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
|
-
|
|
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(),
|
|
177
|
+
E.value && !y.value && p.value > 1 ? (V(), G(Q, {
|
|
176
178
|
key: 0,
|
|
177
|
-
class:
|
|
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] = (
|
|
182
|
-
}, null, 8, ["class", "current-page", "list-length", "page-size"])) :
|
|
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
|
-
}),
|
|
186
|
-
$style:
|
|
187
|
-
},
|
|
187
|
+
}), nt = {
|
|
188
|
+
$style: w
|
|
189
|
+
}, St = /* @__PURE__ */ O(rt, [["__cssModules", nt]]);
|
|
188
190
|
export {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
package/dist/DataView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataView.js","sources":["../src/components/DataView/DataView.utils.ts","../src/components/DataView/DataView.types.ts","../src/components/DataView/DataView.vue"],"sourcesContent":["import { SortId, SortOrder, SortValue, SortValueDeserialized } from './DataView.types';\n\n/**\n * Receives a SortValue (ex: `'-product_name'`) and returns an object with a `id` and an `order`.\n */\nexport function deserializeSortValue(sort: SortValue): SortValueDeserialized {\n const order = sort[0] === '-' ? 'desc' : 'asc';\n const id = order === 'asc' ? sort : sort.slice(1);\n\n return { id, order };\n}\n\n/**\n * Receives an object with a `id` and an `order` and returns a SortValue (ex: `'-product_name'`).\n */\nexport function serializeSortValue({ id, order }: SortValueDeserialized): SortValue {\n return `${order === 'desc' ? '-' : ''}${id}`;\n}\n\ninterface GetNextSortArgs {\n newId: SortId | undefined;\n newOrder?: SortOrder;\n oldId?: SortId;\n oldOrder?: SortOrder;\n}\n\n/**\n * Given new and old sorting data, it returns the next sorting value using the following sorting cycle:\n *\n * \"unsorted --> ascending --> descending --> unsorted\"\n */\nexport function getNextSort({ newId, newOrder, oldId, oldOrder }: GetNextSortArgs): SortValue | undefined {\n if (!newId) {\n return undefined;\n }\n\n if (newId !== oldId) {\n // if sorting by a new field, sort ascending\n return serializeSortValue({ id: newId, order: newOrder || 'asc' });\n }\n\n /**\n * `newOrder` and `oldOrder` can each have 3 different values: undefined, 'asc', or 'desc'.\n * Therefore, there are 9 possible combinations (3 times 3). See below:\n */\n\n // #region newOrder: undefined\n if (!newOrder && !oldOrder) {\n return newId; // ascending\n }\n\n if (!newOrder && oldOrder === 'desc') {\n return undefined; // unsorted\n }\n\n if (!newOrder && oldOrder === 'asc') {\n return `-${newId}`; // descending\n }\n // #endregion\n\n // #region newOrder: asc\n if (newOrder === 'asc' && !oldOrder) {\n return newId;\n }\n\n if (newOrder === 'asc' && oldOrder === 'asc') {\n return undefined;\n }\n\n if (newOrder === 'asc' && oldOrder === 'desc') {\n return newId;\n }\n // #endregion\n\n // #region newOrder: desc\n if (newOrder === 'desc' && !oldOrder) {\n return `-${newId}`;\n }\n\n if (newOrder === 'desc' && oldOrder === 'desc') {\n return undefined;\n }\n\n if (newOrder === 'desc' && oldOrder === 'asc') {\n return `-${newId}`;\n }\n // #endregion\n}\n","import { ComputedRef } 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,aAAOL,EAAmB,EAAE,IAAIG,GAAO,OAAOC,KAAY,OAAO;AAS/D,QAAA,CAACA,KAAY,CAACE;AACT,aAAAH;AAGL,QAAA,GAACC,KAAYE,MAAa,SAI1B;AAAA,UAAA,CAACF,KAAYE,MAAa;AAC5B,eAAO,IAAIH,CAAK;AAKd,UAAAC,MAAa,SAAS,CAACE;AAClB,eAAAH;AAGL,UAAA,EAAAC,MAAa,SAASE,MAAa,QAInC;AAAA,YAA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AC/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,EAAE,OAAAC,GAAO,UAAAC,GAAU,OAAAC,GAAO,UAAAC,KAAoD;AACxG,MAAKH,GAIL;AAAA,QAAIA,MAAUE;AAEZ,aAAOL,GAAmB,EAAE,IAAIG,GAAO,OAAOC,KAAY,OAAO;AAS/D,QAAA,CAACA,KAAY,CAACE;AACT,aAAAH;AAGL,QAAA,GAACC,KAAYE,MAAa,SAI1B;AAAA,UAAA,CAACF,KAAYE,MAAa;AAC5B,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AAA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/DataView.vue.d.ts
CHANGED
|
@@ -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
|
|
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(() =>
|
|
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
|
-
}),
|
|
38
|
-
paginate:
|
|
38
|
+
}), r = "_paginate_1jnlh_2", s = {
|
|
39
|
+
paginate: r
|
|
39
40
|
};
|
|
40
41
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
n as D,
|
|
43
|
+
a,
|
|
44
|
+
s
|
|
44
45
|
};
|
|
45
|
-
//# sourceMappingURL=DataView.vue_used_vue_type_style_index_0_lang.module-
|
|
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;;;"}
|
package/dist/DataViewFilters.js
CHANGED
|
@@ -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-
|
|
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-
|
|
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";
|
package/dist/DataViewToolbar.js
CHANGED
|
@@ -1,91 +1,114 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { t as
|
|
3
|
-
import
|
|
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
|
|
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
|
|
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
|
|
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
|
-
},
|
|
20
|
+
}, G = {
|
|
18
21
|
key: 0,
|
|
19
22
|
class: "tw-mr-1.5 tw-text-xs"
|
|
20
|
-
},
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
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
|
-
|
|
54
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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:
|
|
64
|
-
onClick:
|
|
86
|
+
disabled: e(l) === 1,
|
|
87
|
+
onClick: t[0] || (t[0] = (c) => e(R)({ shouldEmit: !0 }))
|
|
65
88
|
}, {
|
|
66
|
-
default:
|
|
67
|
-
|
|
89
|
+
default: S(() => [
|
|
90
|
+
s(C, { name: "chevron-left" })
|
|
68
91
|
]),
|
|
69
92
|
_: 1
|
|
70
93
|
}, 8, ["disabled"]),
|
|
71
|
-
|
|
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:
|
|
76
|
-
onClick:
|
|
98
|
+
disabled: e(l) === e(w),
|
|
99
|
+
onClick: t[1] || (t[1] = (c) => e(D)({ shouldEmit: !0 }))
|
|
77
100
|
}, {
|
|
78
|
-
default:
|
|
79
|
-
|
|
101
|
+
default: S(() => [
|
|
102
|
+
s(C, { name: "chevron-right" })
|
|
80
103
|
]),
|
|
81
104
|
_: 1
|
|
82
105
|
}, 8, ["disabled"])
|
|
83
|
-
], 64)) :
|
|
84
|
-
])) :
|
|
106
|
+
], 64)) : r("", !0)
|
|
107
|
+
])) : r("", !0)
|
|
85
108
|
], 2));
|
|
86
109
|
}
|
|
87
110
|
});
|
|
88
111
|
export {
|
|
89
|
-
|
|
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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -34,6 +34,11 @@ declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export declare interface DataViewToolbarProps {
|
|
37
|
+
/**
|
|
38
|
+
* When DataView has `variant="table"` and Table has `is-selectable` enabled, it provides a way to flag
|
|
39
|
+
* a checkbox whenever all rows are selected, just like the standalone version on TableHeaderRow.
|
|
40
|
+
*/
|
|
41
|
+
allRowsSelected?: boolean;
|
|
37
42
|
/**
|
|
38
43
|
* Hides the page statistics (ex: "1 - 12 of 20") in the toolbar
|
|
39
44
|
*/
|
|
@@ -42,17 +47,33 @@ export declare interface DataViewToolbarProps {
|
|
|
42
47
|
* Controls the corners of DataViewToolbar with the "border-radius" CSS property. The default value is "rounded".
|
|
43
48
|
*/
|
|
44
49
|
radius?: ToolbarRadiuses;
|
|
50
|
+
/**
|
|
51
|
+
* When DataView has variant="table" and Table has `is-selectable` enabled, it provides a way to flag
|
|
52
|
+
* a checkbox whenever one or more, but not all rows are selected, just like the standalone
|
|
53
|
+
* version on TableHeaderRow.
|
|
54
|
+
*/
|
|
55
|
+
someRowsSelected?: boolean;
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
declare const _default: __VLS_WithTemplateSlots<DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<DataViewToolbarProps>, {
|
|
59
|
+
allRowsSelected: boolean;
|
|
48
60
|
hidePageStats: boolean;
|
|
49
61
|
radius: string;
|
|
50
|
-
|
|
62
|
+
someRowsSelected: boolean;
|
|
63
|
+
}>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
64
|
+
select: () => void;
|
|
65
|
+
}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<DataViewToolbarProps>, {
|
|
66
|
+
allRowsSelected: boolean;
|
|
51
67
|
hidePageStats: boolean;
|
|
52
68
|
radius: string;
|
|
53
|
-
|
|
69
|
+
someRowsSelected: boolean;
|
|
70
|
+
}>>> & {
|
|
71
|
+
onSelect?: (() => any) | undefined;
|
|
72
|
+
}, {
|
|
54
73
|
radius: "none" | "rounded" | "rounded-top";
|
|
74
|
+
allRowsSelected: boolean;
|
|
55
75
|
hidePageStats: boolean;
|
|
76
|
+
someRowsSelected: boolean;
|
|
56
77
|
}, {}>, {
|
|
57
78
|
default?(_: {}): any;
|
|
58
79
|
}>;
|
package/dist/FilterDropdown.js
CHANGED
|
@@ -6,7 +6,7 @@ import "lodash-es/cloneDeep";
|
|
|
6
6
|
import "lodash-es/uniqueId";
|
|
7
7
|
import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
|
|
8
8
|
import "./Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js";
|
|
9
|
-
import { D as F } from "./DataView.vue_used_vue_type_style_index_0_lang.module-
|
|
9
|
+
import { D as F } from "./DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js";
|
|
10
10
|
import { D as z } from "./DataViewFilters.keys-c80ffabe.js";
|
|
11
11
|
import G from "./Dropdown.js";
|
|
12
12
|
import $ from "./FilterChip.js";
|
package/dist/ListView.vue.d.ts
CHANGED
|
@@ -564,9 +564,9 @@ declare const _default: DefineComponent<{
|
|
|
564
564
|
items: unknown[];
|
|
565
565
|
loading: boolean;
|
|
566
566
|
pageSize: number;
|
|
567
|
+
isSelectable: boolean;
|
|
567
568
|
disablePersistency: boolean;
|
|
568
569
|
validationSchema: Function;
|
|
569
|
-
isSelectable: boolean;
|
|
570
570
|
hideBulkActionOptions: boolean;
|
|
571
571
|
hideNumberOfTotalSelected: boolean;
|
|
572
572
|
emptyStateText: string;
|
package/dist/Table.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as C, inject as b, computed as a, provide as L, onBeforeMount as H, openBlock as n, createElementBlock as N, normalizeClass as v, unref as m, normalizeStyle as D, createElementVNode as u, renderSlot as p, createBlock as g, withCtx as r, createVNode as i } from "vue";
|
|
2
2
|
import "lodash-es/cloneDeep";
|
|
3
|
-
import { M as
|
|
3
|
+
import { M as h } from "./Module.keys-2cc7d830.js";
|
|
4
4
|
import "lodash-es/uniqueId";
|
|
5
5
|
import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
|
|
6
6
|
import "./Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js";
|
|
7
|
-
import { D as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { T as
|
|
13
|
-
import { S as
|
|
7
|
+
import { D as E } from "./DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js";
|
|
8
|
+
import V from "./EmptyState.js";
|
|
9
|
+
import I from "./Loading.js";
|
|
10
|
+
import k from "./TableCell.js";
|
|
11
|
+
import S from "./TableRow.js";
|
|
12
|
+
import { T as A } from "./Table.keys-cf93df19.js";
|
|
13
|
+
import { S as O } from "./misc-76697f61.js";
|
|
14
14
|
import "./locale.js";
|
|
15
15
|
import "lodash-es/get";
|
|
16
16
|
import "./Illustration.vue_vue_type_script_setup_true_lang-e52df837.js";
|
|
@@ -26,8 +26,8 @@ import "./ChevronToggle.vue_vue_type_script_setup_true_lang-1591294c.js";
|
|
|
26
26
|
import "./Button.js";
|
|
27
27
|
import "./Icon.js";
|
|
28
28
|
import "./Expand.vue_vue_type_script_setup_true_lang-1751f4a6.js";
|
|
29
|
-
var
|
|
30
|
-
const
|
|
29
|
+
var J = /* @__PURE__ */ ((e) => (e.Scroll = "scroll", e.Stack = "stack", e))(J || {}), M = /* @__PURE__ */ ((e) => (e.None = "none", e.Rounded = "rounded", e.RoundedBottom = "rounded-bottom", e))(M || {});
|
|
30
|
+
const $ = { class: "tw-relative tw-min-w-full tw-max-w-initial tw-border-separate" }, ft = /* @__PURE__ */ C({
|
|
31
31
|
__name: "Table",
|
|
32
32
|
props: {
|
|
33
33
|
density: { default: void 0 },
|
|
@@ -46,63 +46,66 @@ const J = { class: "tw-relative tw-min-w-full tw-max-w-initial tw-border-separat
|
|
|
46
46
|
const t = e, {
|
|
47
47
|
density: x,
|
|
48
48
|
variant: c,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
isEmpty: _,
|
|
50
|
+
isLoading: B,
|
|
51
|
+
isSelectable: f
|
|
52
|
+
} = b(E.key, E.defaults), { variant: s } = b(h.key, h.defaults), y = a(() => (s == null ? void 0 : s.value) === "table" || c.value === "table" ? "rounded-bottom" : t.radius), l = a(() => t.stickyHeader ? "scroll" : t.layout), w = a(() => {
|
|
52
53
|
var o, d;
|
|
53
54
|
return !!((o = t.stickyHeader) != null && o.maxHeight && // table can't scroll without a max height; sticky headers only needed for a scrollable table
|
|
54
55
|
((d = t.stickyHeader) == null ? void 0 : d.listLength) > 3);
|
|
55
56
|
}), T = a(() => {
|
|
56
57
|
var o;
|
|
57
58
|
return {
|
|
58
|
-
maxHeight:
|
|
59
|
+
maxHeight: w.value ? (o = t.stickyHeader) == null ? void 0 : o.maxHeight : ""
|
|
59
60
|
};
|
|
60
61
|
});
|
|
61
|
-
return
|
|
62
|
-
density: a(() => t.density || x.value ||
|
|
62
|
+
return L(A.key, {
|
|
63
|
+
density: a(() => t.density || x.value || O.Comfortable),
|
|
63
64
|
hasCustomExpandToggle: a(() => t.hasCustomExpandToggle),
|
|
64
65
|
hasActions: a(() => t.hasActions),
|
|
65
66
|
isExpandable: a(() => t.isExpandable),
|
|
66
67
|
isSelectable: a(() => t.isSelectable && !t.isLoading && !t.isEmpty),
|
|
67
68
|
layout: l
|
|
68
|
-
}), (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
}), H(() => {
|
|
70
|
+
f && (f.value = t.isSelectable);
|
|
71
|
+
}), (o, d) => (n(), N("div", {
|
|
72
|
+
class: v(["stash-table tw-relative", [
|
|
73
|
+
{ "tw-rounded": y.value === "rounded" },
|
|
74
|
+
{ "tw-rounded-b": y.value === "rounded-bottom" },
|
|
72
75
|
{ "tw-border-t tw-border-ice-200": m(c) === "table" },
|
|
73
76
|
{ "tw-overflow-auto tw-shadow": l.value === "scroll" },
|
|
74
77
|
{ "tw-overflow-visble lg:tw-overflow-auto lg:tw-shadow": l.value === "stack" },
|
|
75
|
-
{ "tw-min-h-[300px]":
|
|
78
|
+
{ "tw-min-h-[300px]": w.value && !t.isLoading }
|
|
76
79
|
// prevent the table from collapsing on small screen heights when the max-height is dynamic
|
|
77
80
|
]]),
|
|
78
81
|
"data-test": "stash-table",
|
|
79
|
-
style:
|
|
82
|
+
style: D(T.value)
|
|
80
83
|
}, [
|
|
81
|
-
u("table",
|
|
84
|
+
u("table", $, [
|
|
82
85
|
u("thead", {
|
|
83
|
-
class:
|
|
86
|
+
class: v(["tw-border-b tw-border-ice-200", {
|
|
84
87
|
"tw-hidden lg:tw-table-header-group": l.value === "stack"
|
|
85
88
|
}])
|
|
86
89
|
}, [
|
|
87
90
|
p(o.$slots, "head")
|
|
88
91
|
], 2),
|
|
89
92
|
u("tbody", null, [
|
|
90
|
-
t.isLoading || m(
|
|
93
|
+
t.isLoading || m(B) ? (n(), g(S, { key: 0 }, {
|
|
91
94
|
default: r(() => [
|
|
92
|
-
i(
|
|
95
|
+
i(k, { colspan: "100%" }, {
|
|
93
96
|
default: r(() => [
|
|
94
|
-
i(
|
|
97
|
+
i(I)
|
|
95
98
|
]),
|
|
96
99
|
_: 1
|
|
97
100
|
})
|
|
98
101
|
]),
|
|
99
102
|
_: 1
|
|
100
|
-
})) : t.isEmpty || m(_) ? (n(),
|
|
103
|
+
})) : t.isEmpty || m(_) ? (n(), g(S, { key: 1 }, {
|
|
101
104
|
default: r(() => [
|
|
102
|
-
i(
|
|
105
|
+
i(k, { colspan: "100%" }, {
|
|
103
106
|
default: r(() => [
|
|
104
107
|
p(o.$slots, "empty", {}, () => [
|
|
105
|
-
i(
|
|
108
|
+
i(V, {
|
|
106
109
|
class: "tw-w-full tw-bg-white",
|
|
107
110
|
text: t.emptyStateText
|
|
108
111
|
}, null, 8, ["text"])
|
|
@@ -119,9 +122,9 @@ const J = { class: "tw-relative tw-min-w-full tw-max-w-initial tw-border-separat
|
|
|
119
122
|
}
|
|
120
123
|
});
|
|
121
124
|
export {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
J as Layout,
|
|
126
|
+
A as TABLE_INJECTION,
|
|
127
|
+
M as TableRadius,
|
|
128
|
+
ft as default
|
|
126
129
|
};
|
|
127
130
|
//# sourceMappingURL=Table.js.map
|
package/dist/Table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","sources":["../src/components/Table/Table.types.ts","../src/components/Table/Table.vue"],"sourcesContent":["import { ComputedRef } from 'vue';\n\nimport { SpacingDensities } from '../../../types/misc';\n\nexport enum Layout {\n Scroll = 'scroll',\n Stack = 'stack',\n}\n\nexport type Layouts = `${Layout}`;\n\nexport enum TableRadius {\n None = 'none',\n Rounded = 'rounded',\n RoundedBottom = 'rounded-bottom',\n}\n\nexport type TableRadiuses = `${TableRadius}`;\n\n/**\n * Properties and utilities provided to children of a Table instance\n */\nexport interface TableInjection {\n /**\n * Controls the Table's padding; the default value is \"comfortable\". On small screens, the density will always be \"compact\".\n */\n density: ComputedRef<SpacingDensities>;\n\n /**\n * Styles the last column for \"row actions\"\n */\n hasActions: ComputedRef<boolean>;\n\n /**\n * If true, hides the default expansion toggle column\n */\n hasCustomExpandToggle: ComputedRef<boolean>;\n\n /**\n * Adds a toggle column for row expansion. This is primarily needed for ensuring the corresponding empty TableHeaderRow is included.\n */\n isExpandable: ComputedRef<boolean>;\n\n /**\n * Adds a checkbox column for selecting rows; intended for use with the `useSelection` composable.\n */\n isSelectable: ComputedRef<boolean>;\n\n /**\n * Sets the table layout; the default value is \"scroll\".\n */\n layout: ComputedRef<Layouts>;\n}\n","<script lang=\"ts\">\n import { SpacingDensities, SpacingDensity } from '../../../types/misc';\n import { MODULE_INJECTION } from '../Module/Module.keys';\n import { Layouts, TableRadiuses } from './Table.types';\n\n export * from './Table.keys';\n export * from './Table.types';\n\n export interface TableProps {\n /**\n * Controls the Table's padding; the default value is \"comfortable\". On small screens, \"compact\" density is applied regardless of this prop's value.\n */\n density?: SpacingDensities;\n\n /**\n * Sets the text for the empty state; the default value is \"No Results\".\n */\n emptyStateText?: string;\n\n /**\n * Styles the last column for \"row actions\"\n */\n hasActions?: boolean;\n\n /**\n * If true, hides the default expansion toggle column\n */\n hasCustomExpandToggle?: boolean;\n\n /**\n * Shows the empty state\n */\n isEmpty?: boolean;\n\n /**\n * Shows the loading state\n */\n isLoading?: boolean;\n\n /**\n * Adds a toggle column for row expansion. This is primarily needed for ensuring the corresponding empty TableHeaderRow is included.\n */\n isExpandable?: boolean;\n\n /**\n * Adds a checkbox column for selecting rows; intended for use with the `useSelection` composable.\n */\n isSelectable?: boolean;\n\n /**\n * Sets the table layout; the default value is \"scroll\".\n */\n layout?: Layouts;\n\n /**\n * Controls the corners of the table with the \"border-radius\" CSS property. The default value is \"rounded\".\n */\n radius?: TableRadiuses;\n\n /**\n * Allows the table head to be sticky when scrolling inside the table body\n */\n stickyHeader?: {\n listLength: number;\n maxHeight: string;\n };\n }\n</script>\n\n<script setup lang=\"ts\">\n import { computed, inject, provide } from 'vue';\n\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import EmptyState from '../EmptyState/EmptyState.vue';\n import Loading from '../Loading/Loading.vue';\n import TableCell from '../TableCell/TableCell.vue';\n import TableRow from '../TableRow/TableRow.vue';\n import { TABLE_INJECTION } from './Table.keys';\n\n const props = withDefaults(defineProps<TableProps>(), {\n density: undefined,\n emptyStateText: '',\n hasActions: false,\n hasCustomExpandToggle: false,\n isEmpty: false,\n isLoading: false,\n isExpandable: false,\n isSelectable: false,\n layout: 'scroll',\n radius: 'rounded',\n stickyHeader: undefined,\n });\n\n const {\n density: dataViewDensity,\n variant: dataViewVariant,\n isLoading: isDataViewLoading,\n
|
|
1
|
+
{"version":3,"file":"Table.js","sources":["../src/components/Table/Table.types.ts","../src/components/Table/Table.vue"],"sourcesContent":["import { ComputedRef } from 'vue';\n\nimport { SpacingDensities } from '../../../types/misc';\n\nexport enum Layout {\n Scroll = 'scroll',\n Stack = 'stack',\n}\n\nexport type Layouts = `${Layout}`;\n\nexport enum TableRadius {\n None = 'none',\n Rounded = 'rounded',\n RoundedBottom = 'rounded-bottom',\n}\n\nexport type TableRadiuses = `${TableRadius}`;\n\n/**\n * Properties and utilities provided to children of a Table instance\n */\nexport interface TableInjection {\n /**\n * Controls the Table's padding; the default value is \"comfortable\". On small screens, the density will always be \"compact\".\n */\n density: ComputedRef<SpacingDensities>;\n\n /**\n * Styles the last column for \"row actions\"\n */\n hasActions: ComputedRef<boolean>;\n\n /**\n * If true, hides the default expansion toggle column\n */\n hasCustomExpandToggle: ComputedRef<boolean>;\n\n /**\n * Adds a toggle column for row expansion. This is primarily needed for ensuring the corresponding empty TableHeaderRow is included.\n */\n isExpandable: ComputedRef<boolean>;\n\n /**\n * Adds a checkbox column for selecting rows; intended for use with the `useSelection` composable.\n */\n isSelectable: ComputedRef<boolean>;\n\n /**\n * Sets the table layout; the default value is \"scroll\".\n */\n layout: ComputedRef<Layouts>;\n}\n","<script lang=\"ts\">\n import { SpacingDensities, SpacingDensity } from '../../../types/misc';\n import { MODULE_INJECTION } from '../Module/Module.keys';\n import { Layouts, TableRadiuses } from './Table.types';\n\n export * from './Table.keys';\n export * from './Table.types';\n\n export interface TableProps {\n /**\n * Controls the Table's padding; the default value is \"comfortable\". On small screens, \"compact\" density is applied regardless of this prop's value.\n */\n density?: SpacingDensities;\n\n /**\n * Sets the text for the empty state; the default value is \"No Results\".\n */\n emptyStateText?: string;\n\n /**\n * Styles the last column for \"row actions\"\n */\n hasActions?: boolean;\n\n /**\n * If true, hides the default expansion toggle column\n */\n hasCustomExpandToggle?: boolean;\n\n /**\n * Shows the empty state\n */\n isEmpty?: boolean;\n\n /**\n * Shows the loading state\n */\n isLoading?: boolean;\n\n /**\n * Adds a toggle column for row expansion. This is primarily needed for ensuring the corresponding empty TableHeaderRow is included.\n */\n isExpandable?: boolean;\n\n /**\n * Adds a checkbox column for selecting rows; intended for use with the `useSelection` composable.\n */\n isSelectable?: boolean;\n\n /**\n * Sets the table layout; the default value is \"scroll\".\n */\n layout?: Layouts;\n\n /**\n * Controls the corners of the table with the \"border-radius\" CSS property. The default value is \"rounded\".\n */\n radius?: TableRadiuses;\n\n /**\n * Allows the table head to be sticky when scrolling inside the table body\n */\n stickyHeader?: {\n listLength: number;\n maxHeight: string;\n };\n }\n</script>\n\n<script setup lang=\"ts\">\n import { computed, inject, onBeforeMount, provide } from 'vue';\n\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.vue';\n import EmptyState from '../EmptyState/EmptyState.vue';\n import Loading from '../Loading/Loading.vue';\n import TableCell from '../TableCell/TableCell.vue';\n import TableRow from '../TableRow/TableRow.vue';\n import { TABLE_INJECTION } from './Table.keys';\n\n const props = withDefaults(defineProps<TableProps>(), {\n density: undefined,\n emptyStateText: '',\n hasActions: false,\n hasCustomExpandToggle: false,\n isEmpty: false,\n isLoading: false,\n isExpandable: false,\n isSelectable: false,\n layout: 'scroll',\n radius: 'rounded',\n stickyHeader: undefined,\n });\n\n const {\n density: dataViewDensity,\n variant: dataViewVariant,\n isEmpty: isDataViewEmpty,\n isLoading: isDataViewLoading,\n isSelectable: isDataViewSelectable,\n } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n const { variant: moduleVariant } = inject(MODULE_INJECTION.key, MODULE_INJECTION.defaults);\n\n const computedRadius = computed<TableRadiuses>(() => {\n // Will work for tables when rendered inside of a Module with OR without a DataView.\n if (moduleVariant?.value === 'table') {\n return 'rounded-bottom';\n }\n\n if (dataViewVariant.value === 'table') {\n return 'rounded-bottom';\n }\n\n return props.radius;\n });\n\n const computedLayout = computed<Layouts>(() => {\n if (props.stickyHeader) {\n return 'scroll';\n }\n\n return props.layout;\n });\n\n const isStickyHeaderEnabled = computed<boolean>(() => {\n return !!(\n (\n props.stickyHeader?.maxHeight && // table can't scroll without a max height; sticky headers only needed for a scrollable table\n props.stickyHeader?.listLength > 3\n ) // scrollable table and sticky headers not needed when list is small\n );\n });\n\n const rootStyle = computed(() => ({\n maxHeight: isStickyHeaderEnabled.value ? props.stickyHeader?.maxHeight : '',\n }));\n\n provide(TABLE_INJECTION.key, {\n density: computed(() => props.density || dataViewDensity.value || SpacingDensity.Comfortable),\n hasCustomExpandToggle: computed(() => props.hasCustomExpandToggle),\n hasActions: computed(() => props.hasActions),\n isExpandable: computed(() => props.isExpandable),\n isSelectable: computed(() => props.isSelectable && !props.isLoading && !props.isEmpty),\n layout: computedLayout,\n });\n\n onBeforeMount(() => {\n /**\n * To avoid breaking changes and developer experience, a DataView injection is passed down and updated whenever it exists.\n */\n if (isDataViewSelectable) {\n isDataViewSelectable.value = props.isSelectable;\n }\n });\n</script>\n\n<template>\n <div\n class=\"stash-table tw-relative\"\n :class=\"[\n { 'tw-rounded': computedRadius === 'rounded' },\n { 'tw-rounded-b': computedRadius === 'rounded-bottom' },\n { 'tw-border-t tw-border-ice-200': dataViewVariant === 'table' },\n { 'tw-overflow-auto tw-shadow': computedLayout === 'scroll' },\n { 'tw-overflow-visble lg:tw-overflow-auto lg:tw-shadow': computedLayout === 'stack' },\n { 'tw-min-h-[300px]': isStickyHeaderEnabled && !props.isLoading }, // prevent the table from collapsing on small screen heights when the max-height is dynamic\n ]\"\n data-test=\"stash-table\"\n :style=\"rootStyle\"\n >\n <table class=\"tw-relative tw-min-w-full tw-max-w-initial tw-border-separate\">\n <thead\n class=\"tw-border-b tw-border-ice-200\"\n :class=\"{\n 'tw-hidden lg:tw-table-header-group': computedLayout === 'stack',\n }\"\n >\n <!-- @slot head -->\n <slot name=\"head\"> </slot>\n </thead>\n <tbody>\n <TableRow v-if=\"props.isLoading || isDataViewLoading\">\n <TableCell colspan=\"100%\">\n <Loading />\n </TableCell>\n </TableRow>\n <!-- @slot empty -->\n <template v-else-if=\"props.isEmpty || isDataViewEmpty\">\n <TableRow>\n <TableCell colspan=\"100%\">\n <slot name=\"empty\">\n <EmptyState class=\"tw-w-full tw-bg-white\" :text=\"props.emptyStateText\" />\n </slot>\n </TableCell>\n </TableRow>\n </template>\n <!-- @slot body -->\n <slot v-else name=\"body\"></slot>\n </tbody>\n </table>\n </div>\n</template>\n"],"names":["Layout","TableRadius","dataViewDensity","dataViewVariant","isDataViewEmpty","isDataViewLoading","isDataViewSelectable","inject","DATA_VIEW_INJECTION","moduleVariant","MODULE_INJECTION","computedRadius","computed","props","computedLayout","isStickyHeaderEnabled","_a","_b","rootStyle","provide","TABLE_INJECTION","SpacingDensity","onBeforeMount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIY,IAAAA,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,QAAQ,SAFEA,IAAAA,KAAA,CAAA,CAAA,GAOAC,sBAAAA,OACVA,EAAA,OAAO,QACPA,EAAA,UAAU,WACVA,EAAA,gBAAgB,kBAHNA,IAAAA,KAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;iBCkFJ;AAAA,MACJ,SAASC;AAAA,MACT,SAASC;AAAA,MACT,SAASC;AAAA,MACT,WAAWC;AAAA,MACX,cAAcC;AAAA,IACZ,IAAAC,EAAOC,EAAoB,KAAKA,EAAoB,QAAQ,GAE1D,EAAE,SAASC,MAAkBF,EAAOG,EAAiB,KAAKA,EAAiB,QAAQ,GAEnFC,IAAiBC,EAAwB,OAEzCH,KAAA,gBAAAA,EAAe,WAAU,WAIzBN,EAAgB,UAAU,UACrB,mBAGFU,EAAM,MACd,GAEKC,IAAiBF,EAAkB,MACnCC,EAAM,eACD,WAGFA,EAAM,MACd,GAEKE,IAAwBH,EAAkB,MAAM;;AAC7C,aAAA,CAAC,GAEJI,IAAAH,EAAM,iBAAN,QAAAG,EAAoB;AAAA,QACpBC,IAAAJ,EAAM,iBAAN,gBAAAI,EAAoB,cAAa;AAAA,IAAA,CAGtC,GAEKC,IAAYN,EAAS,MAAO;;AAAA;AAAA,QAChC,WAAWG,EAAsB,SAAQC,IAAAH,EAAM,iBAAN,gBAAAG,EAAoB,YAAY;AAAA,MACzE;AAAA,KAAA;AAEF,WAAAG,EAAQC,EAAgB,KAAK;AAAA,MAC3B,SAASR,EAAS,MAAMC,EAAM,WAAWX,EAAgB,SAASmB,EAAe,WAAW;AAAA,MAC5F,uBAAuBT,EAAS,MAAMC,EAAM,qBAAqB;AAAA,MACjE,YAAYD,EAAS,MAAMC,EAAM,UAAU;AAAA,MAC3C,cAAcD,EAAS,MAAMC,EAAM,YAAY;AAAA,MAC/C,cAAcD,EAAS,MAAMC,EAAM,gBAAgB,CAACA,EAAM,aAAa,CAACA,EAAM,OAAO;AAAA,MACrF,QAAQC;AAAA,IAAA,CACT,GAEDQ,EAAc,MAAM;AAIlB,MAAIhB,MACFA,EAAqB,QAAQO,EAAM;AAAA,IACrC,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/TableCell.js
CHANGED
|
@@ -3,7 +3,7 @@ import "lodash-es/cloneDeep";
|
|
|
3
3
|
import "lodash-es/uniqueId";
|
|
4
4
|
import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
|
|
5
5
|
import "./Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js";
|
|
6
|
-
import "./DataView.vue_used_vue_type_style_index_0_lang.module-
|
|
6
|
+
import "./DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js";
|
|
7
7
|
import "lodash-es/get";
|
|
8
8
|
import "./Illustration.vue_vue_type_script_setup_true_lang-e52df837.js";
|
|
9
9
|
import "./EmptyState.vue_used_vue_type_style_index_0_lang.module-f5d89366.js";
|
package/dist/TableHeaderCell.js
CHANGED
|
@@ -2,7 +2,7 @@ import { defineComponent as k, useCssModule as T, inject as u, computed as p, op
|
|
|
2
2
|
import "lodash-es/cloneDeep";
|
|
3
3
|
import f from "./Icon.js";
|
|
4
4
|
import "./Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js";
|
|
5
|
-
import { D as b } from "./DataView.vue_used_vue_type_style_index_0_lang.module-
|
|
5
|
+
import { D as b } from "./DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js";
|
|
6
6
|
import "lodash-es/get";
|
|
7
7
|
import "./Illustration.vue_vue_type_script_setup_true_lang-e52df837.js";
|
|
8
8
|
import "./EmptyState.vue_used_vue_type_style_index_0_lang.module-f5d89366.js";
|
package/dist/TableHeaderRow.js
CHANGED
|
@@ -1,74 +1,78 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { t as
|
|
3
|
-
import
|
|
1
|
+
import { defineComponent as T, inject as p, ref as u, onMounted as R, openBlock as l, createElementBlock as x, unref as e, createBlock as r, normalizeClass as a, withCtx as C, createCommentVNode as w, renderSlot as E } from "vue";
|
|
2
|
+
import { t as S } from "./locale.js";
|
|
3
|
+
import B from "./Checkbox.js";
|
|
4
|
+
import { D as f } from "./DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js";
|
|
4
5
|
import "lodash-es/cloneDeep";
|
|
5
6
|
import "lodash-es/uniqueId";
|
|
6
7
|
import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
|
|
7
8
|
import "./Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js";
|
|
8
|
-
import "./DataView.vue_used_vue_type_style_index_0_lang.module-d878ca9a.js";
|
|
9
9
|
import "./Illustration.vue_vue_type_script_setup_true_lang-e52df837.js";
|
|
10
10
|
import "./EmptyState.vue_used_vue_type_style_index_0_lang.module-f5d89366.js";
|
|
11
11
|
import "./Loading.vue_used_vue_type_style_index_0_lang.module-ef5a3bc6.js";
|
|
12
|
-
import { T as
|
|
12
|
+
import { T as I } from "./Table.keys-cf93df19.js";
|
|
13
13
|
import "./Button.vue_used_vue_type_style_index_0_lang.module-63d31dc0.js";
|
|
14
|
-
import
|
|
15
|
-
import { _ as
|
|
14
|
+
import h from "./TableHeaderCell.js";
|
|
15
|
+
import { _ as N } from "./_plugin-vue_export-helper-dad06003.js";
|
|
16
16
|
import "lodash-es/get";
|
|
17
17
|
import "@leaflink/snitch";
|
|
18
18
|
import "./Checkbox.vue_used_vue_type_style_index_0_lang.module-fa8d9c06.js";
|
|
19
19
|
import "./index-79ce320f.js";
|
|
20
20
|
import "./Icon.js";
|
|
21
|
-
const
|
|
22
|
-
class: "stash-table-header-row",
|
|
23
|
-
"data-test": "stash-table-header-row"
|
|
24
|
-
}, E = /* @__PURE__ */ f({
|
|
21
|
+
const v = /* @__PURE__ */ T({
|
|
25
22
|
__name: "TableHeaderRow",
|
|
26
23
|
props: {
|
|
27
24
|
allRowsSelected: { type: Boolean, default: !1 },
|
|
28
25
|
someRowsSelected: { type: Boolean, default: !1 }
|
|
29
26
|
},
|
|
30
27
|
emits: ["select"],
|
|
31
|
-
setup(
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
28
|
+
setup(_, { emit: b }) {
|
|
29
|
+
const s = _, c = p(I.key);
|
|
30
|
+
if (!c)
|
|
34
31
|
throw new Error("TableHeaderRow must be used within a Table component");
|
|
35
|
-
const { hasCustomExpandToggle:
|
|
36
|
-
function
|
|
37
|
-
|
|
32
|
+
const { hasCustomExpandToggle: k, isExpandable: y, isSelectable: n } = c, { hasToolbar: t } = p(f.key, f.defaults), i = u(0), m = u();
|
|
33
|
+
function d() {
|
|
34
|
+
b("select"), i.value++;
|
|
38
35
|
}
|
|
39
|
-
return (
|
|
40
|
-
|
|
36
|
+
return R(() => {
|
|
37
|
+
t != null && t.value && n.value && m.value.getElementsByTagName("th")[0].setAttribute("colspan", 2);
|
|
38
|
+
}), (o, g) => (l(), x("tr", {
|
|
39
|
+
ref_key: "headerRow",
|
|
40
|
+
ref: m,
|
|
41
|
+
class: "stash-table-header-row",
|
|
42
|
+
"data-test": "stash-table-header-row"
|
|
43
|
+
}, [
|
|
44
|
+
!e(t) && e(n) ? (l(), r(h, {
|
|
41
45
|
key: 0,
|
|
42
|
-
class:
|
|
46
|
+
class: a(["stash-table-header-row__selection-cell tw-min-w-[48px]", o.$style["row-control-cell"]])
|
|
43
47
|
}, {
|
|
44
|
-
default:
|
|
45
|
-
(
|
|
46
|
-
key:
|
|
47
|
-
class:
|
|
48
|
-
checked:
|
|
49
|
-
indeterminate:
|
|
50
|
-
title:
|
|
51
|
-
"onUpdate:indeterminate":
|
|
52
|
-
"onUpdate:checked":
|
|
48
|
+
default: C(() => [
|
|
49
|
+
(l(), r(B, {
|
|
50
|
+
key: i.value,
|
|
51
|
+
class: a(o.$style["row-selection-checkbox"]),
|
|
52
|
+
checked: s.allRowsSelected,
|
|
53
|
+
indeterminate: s.someRowsSelected && !s.allRowsSelected,
|
|
54
|
+
title: e(S)("ll.selectAll"),
|
|
55
|
+
"onUpdate:indeterminate": d,
|
|
56
|
+
"onUpdate:checked": d
|
|
53
57
|
}, null, 8, ["class", "checked", "indeterminate", "title"]))
|
|
54
58
|
]),
|
|
55
59
|
_: 1
|
|
56
|
-
}, 8, ["class"])) :
|
|
57
|
-
|
|
60
|
+
}, 8, ["class"])) : w("", !0),
|
|
61
|
+
e(y) && !e(k) ? (l(), r(h, {
|
|
58
62
|
key: 1,
|
|
59
|
-
class:
|
|
63
|
+
class: a(o.$style["row-control-cell"]),
|
|
60
64
|
"data-test": "table-row-header-expansion-cell"
|
|
61
|
-
}, null, 8, ["class"])) :
|
|
62
|
-
|
|
63
|
-
]));
|
|
65
|
+
}, null, 8, ["class"])) : w("", !0),
|
|
66
|
+
E(o.$slots, "default")
|
|
67
|
+
], 512));
|
|
64
68
|
}
|
|
65
|
-
}),
|
|
69
|
+
}), A = {
|
|
66
70
|
"row-selection-checkbox": "_row-selection-checkbox_1eq6o_2",
|
|
67
71
|
"row-control-cell": "_row-control-cell_1eq6o_8"
|
|
68
|
-
},
|
|
69
|
-
$style:
|
|
70
|
-
},
|
|
72
|
+
}, $ = {
|
|
73
|
+
$style: A
|
|
74
|
+
}, ee = /* @__PURE__ */ N(v, [["__cssModules", $]]);
|
|
71
75
|
export {
|
|
72
|
-
|
|
76
|
+
ee as default
|
|
73
77
|
};
|
|
74
78
|
//# sourceMappingURL=TableHeaderRow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableHeaderRow.js","sources":["../src/components/TableHeaderRow/TableHeaderRow.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { inject, ref } from 'vue';\n\n import { t } from '../../locale';\n import Checkbox from '../Checkbox/Checkbox.vue';\n import { TABLE_INJECTION } from '../Table/Table.vue';\n import TableHeaderCell from '../TableHeaderCell/TableHeaderCell.vue';\n\n export interface TableHeaderRowProps {\n allRowsSelected?: boolean;\n someRowsSelected?: boolean;\n }\n\n const props = withDefaults(defineProps<TableHeaderRowProps>(), {\n allRowsSelected: false,\n someRowsSelected: false,\n });\n\n const emit =\n defineEmits<{\n (e: 'select'): void;\n }>();\n\n const tableInjection = inject(TABLE_INJECTION.key);\n\n if (!tableInjection) {\n throw new Error('TableHeaderRow must be used within a Table component');\n }\n\n const { hasCustomExpandToggle, isExpandable, isSelectable } = tableInjection;\n\n const checkboxKey = ref(0);\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</script>\n\n<template>\n <tr class=\"stash-table-header-row\" data-test=\"stash-table-header-row\">\n <TableHeaderCell\n v-if=\"isSelectable\"\n class=\"stash-table-header-row__selection-cell tw-min-w-[48px]\"\n :class=\"$style['row-control-cell']\"\n >\n <Checkbox\n :key=\"checkboxKey\"\n :class=\"$style['row-selection-checkbox']\"\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 </TableHeaderCell>\n <TableHeaderCell\n v-if=\"isExpandable && !hasCustomExpandToggle\"\n :class=\"$style['row-control-cell']\"\n data-test=\"table-row-header-expansion-cell\"\n />\n <!-- @slot default -->\n <slot></slot>\n </tr>\n</template>\n\n<style module>\n .row-selection-checkbox label {\n padding: 0;\n min-height: theme('spacing.6');\n vertical-align: middle;\n }\n\n .row-control-cell {\n border-right: 0;\n }\n</style>\n"],"names":["tableInjection","inject","TABLE_INJECTION","hasCustomExpandToggle","isExpandable","isSelectable","checkboxKey","ref","onSelect","emit"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableHeaderRow.js","sources":["../src/components/TableHeaderRow/TableHeaderRow.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { inject, onMounted, ref } from 'vue';\n\n import { t } from '../../locale';\n import Checkbox from '../Checkbox/Checkbox.vue';\n import { DATA_VIEW_INJECTION } from '../DataView/DataView.keys';\n import { TABLE_INJECTION } from '../Table/Table.vue';\n import TableHeaderCell from '../TableHeaderCell/TableHeaderCell.vue';\n\n export interface TableHeaderRowProps {\n allRowsSelected?: boolean;\n someRowsSelected?: boolean;\n }\n\n const props = withDefaults(defineProps<TableHeaderRowProps>(), {\n allRowsSelected: false,\n someRowsSelected: false,\n });\n\n const emit =\n defineEmits<{\n (e: 'select'): void;\n }>();\n\n const tableInjection = inject(TABLE_INJECTION.key);\n\n if (!tableInjection) {\n throw new Error('TableHeaderRow must be used within a Table component');\n }\n\n const { hasCustomExpandToggle, isExpandable, isSelectable } = tableInjection;\n\n const { hasToolbar } = inject(DATA_VIEW_INJECTION.key, DATA_VIEW_INJECTION.defaults);\n\n const checkboxKey = ref(0);\n const headerRow = ref();\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 onMounted(() => {\n /**\n * Whenever a Table is selectable _and_ is within a DataView with a toolbar, we pick the first header cell and add a colspan=2.\n * This allows Checkboxes within each row to be rendered as a standalone cell, removing friction on the developer to add the checkbox each time.\n */\n if (hasToolbar?.value && isSelectable.value) {\n headerRow.value.getElementsByTagName('th')[0].setAttribute('colspan', 2);\n }\n });\n</script>\n\n<template>\n <tr ref=\"headerRow\" class=\"stash-table-header-row\" data-test=\"stash-table-header-row\">\n <TableHeaderCell\n v-if=\"!hasToolbar && isSelectable\"\n class=\"stash-table-header-row__selection-cell tw-min-w-[48px]\"\n :class=\"$style['row-control-cell']\"\n >\n <Checkbox\n :key=\"checkboxKey\"\n :class=\"$style['row-selection-checkbox']\"\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 </TableHeaderCell>\n <TableHeaderCell\n v-if=\"isExpandable && !hasCustomExpandToggle\"\n :class=\"$style['row-control-cell']\"\n data-test=\"table-row-header-expansion-cell\"\n />\n <!-- @slot default -->\n <slot></slot>\n </tr>\n</template>\n\n<style module>\n .row-selection-checkbox label {\n padding: 0;\n min-height: theme('spacing.6');\n vertical-align: middle;\n }\n\n .row-control-cell {\n border-right: 0;\n }\n</style>\n"],"names":["tableInjection","inject","TABLE_INJECTION","hasCustomExpandToggle","isExpandable","isSelectable","hasToolbar","DATA_VIEW_INJECTION","checkboxKey","ref","headerRow","onSelect","emit","onMounted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwBQA,IAAiBC,EAAOC,EAAgB,GAAG;AAEjD,QAAI,CAACF;AACG,YAAA,IAAI,MAAM,sDAAsD;AAGxE,UAAM,EAAE,uBAAAG,GAAuB,cAAAC,GAAc,cAAAC,EAAA,IAAiBL,GAExD,EAAE,YAAAM,EAAW,IAAIL,EAAOM,EAAoB,KAAKA,EAAoB,QAAQ,GAE7EC,IAAcC,EAAI,CAAC,GACnBC,IAAYD;AAElB,aAASE,IAAW;AAClB,MAAAC,EAAK,QAAQ,GAODJ,EAAA;AAAA,IACd;AAEA,WAAAK,EAAU,MAAM;AAKV,MAAAP,KAAA,QAAAA,EAAY,SAASD,EAAa,SAC1BK,EAAA,MAAM,qBAAqB,IAAI,EAAE,CAAC,EAAE,aAAa,WAAW,CAAC;AAAA,IACzE,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/TableRow.js
CHANGED
|
@@ -7,7 +7,7 @@ import { _ as U } from "./Expand.vue_vue_type_script_setup_true_lang-1751f4a6.js
|
|
|
7
7
|
import "lodash-es/cloneDeep";
|
|
8
8
|
import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
|
|
9
9
|
import "./Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js";
|
|
10
|
-
import "./DataView.vue_used_vue_type_style_index_0_lang.module-
|
|
10
|
+
import "./DataView.vue_used_vue_type_style_index_0_lang.module-5c180dba.js";
|
|
11
11
|
import "./Illustration.vue_vue_type_script_setup_true_lang-e52df837.js";
|
|
12
12
|
import "./EmptyState.vue_used_vue_type_style_index_0_lang.module-f5d89366.js";
|
|
13
13
|
import "./Loading.vue_used_vue_type_style_index_0_lang.module-ef5a3bc6.js";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataView.vue_used_vue_type_style_index_0_lang.module-d878ca9a.js","sources":["../src/components/DataView/DataView.constants.ts","../src/components/DataView/DataView.keys.ts"],"sourcesContent":["export const DEFAULT_PAGE_SIZE = 12;\n","import { computed } 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 isLoading: computed(() => false),\n isEmpty: computed(() => false),\n isWithinModule: computed(() => false),\n variant: computed(() => undefined),\n }),\n});\n"],"names":["DEFAULT_PAGE_SIZE","DATA_VIEW_INJECTION","computed"],"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,WAAWA,EAAS,MAAM,EAAK;AAAA,IAC/B,SAASA,EAAS,MAAM,EAAK;AAAA,IAC7B,gBAAgBA,EAAS,MAAM,EAAK;AAAA,IACpC,SAASA,EAAS,MAAM;AAAA,KAAS;AAAA,EAAA,CAClC;AACH,CAAC;;;"}
|