@soft-stech/bootsman-ui-shadcn 1.3.2 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,243 @@
1
+ import { defineComponent as D, mergeModels as L, useModel as b, computed as S, watchEffect as U, openBlock as n, createElementBlock as s, Fragment as d, renderSlot as V, unref as o, createCommentVNode as y, createVNode as g, withCtx as a, renderList as f, createBlock as m, createElementVNode as F, createTextVNode as v, toDisplayString as w } from "vue";
2
+ import { _ as O } from "./BuiCollapsible.vue_vue_type_script_setup_true_lang-BfgRYJts.js";
3
+ import { _ as T } from "./BuiCollapsibleTrigger.vue_vue_type_script_setup_true_lang-DJ8YMCCp.js";
4
+ import { _ as G } from "./BuiCollapsibleContent.vue_vue_type_script_setup_true_lang-eieHE5yV.js";
5
+ import { _ as j } from "./BuiPaginationCommon.vue_vue_type_script_setup_true_lang-DjLAqoa-.js";
6
+ import { v as C } from "./utils-DPuEjrVV.js";
7
+ import { _ as z } from "./BuiTableRowSubrow.vue_vue_type_script_setup_true_lang-Ch5gemw2.js";
8
+ import { useVueTable as H, getCoreRowModel as K, getPaginationRowModel as Y, getSortedRowModel as q, FlexRender as A } from "@tanstack/vue-table";
9
+ import { _ as J } from "./BuiTable.vue_vue_type_script_setup_true_lang-CUPSwE5z.js";
10
+ import { _ as Q } from "./BuiTableBody.vue_vue_type_script_setup_true_lang-CWT4u-Ma.js";
11
+ import { _ as x } from "./BuiTableCell.vue_vue_type_script_setup_true_lang-BrTQJCiZ.js";
12
+ import { _ as W } from "./BuiTableHead.vue_vue_type_script_setup_true_lang-CCXONmtG.js";
13
+ import { _ as X } from "./BuiTableHeader.vue_vue_type_script_setup_true_lang-DZOqi3dp.js";
14
+ import { _ as P } from "./BuiTableRow.vue_vue_type_script_setup_true_lang-CpEilJsW.js";
15
+ import { _ as Z } from "./BuiTableEmpty.vue_vue_type_script_setup_true_lang-BJDYHpRG.js";
16
+ import { _ as ee } from "./BuiTableFooter.vue_vue_type_script_setup_true_lang-Cfxlxsbh.js";
17
+ const te = {
18
+ key: 0,
19
+ class: "w-full py-4"
20
+ }, oe = { class: "inline-block rounded-t bg-background px-4 py-3" }, N = "#UNDEFINED#", ye = /* @__PURE__ */ D({
21
+ __name: "BuiDataTable",
22
+ props: /* @__PURE__ */ L({
23
+ columns: {},
24
+ data: {},
25
+ pageSize: { default: 10 },
26
+ showPagination: { type: Boolean, default: !0 },
27
+ totalItems: { default: 0 },
28
+ manualPagination: { type: Boolean, default: !0 },
29
+ manualSorting: { type: Boolean, default: !0 },
30
+ groupBy: {},
31
+ groupLabels: {},
32
+ getRowId: {},
33
+ renderSubComponent: {}
34
+ }, {
35
+ sorting: {},
36
+ sortingModifiers: {},
37
+ pagination: {},
38
+ paginationModifiers: {},
39
+ selection: {},
40
+ selectionModifiers: {},
41
+ columnVisibility: {},
42
+ columnVisibilityModifiers: {}
43
+ }),
44
+ emits: ["update:sorting", "update:pagination", "update:selection", "update:columnVisibility"],
45
+ setup(c) {
46
+ const t = c, R = b(c, "sorting"), p = b(c, "pagination"), k = b(c, "selection"), E = b(c, "columnVisibility"), I = S(
47
+ () => t.manualPagination ? t.totalItems : t.data.length
48
+ ), i = H({
49
+ initialState: { pagination: { pageSize: t.pageSize } },
50
+ get data() {
51
+ return t.data;
52
+ },
53
+ get columns() {
54
+ return t.columns;
55
+ },
56
+ getCoreRowModel: K(),
57
+ getPaginationRowModel: Y(),
58
+ getSortedRowModel: q(),
59
+ onSortingChange: (e) => {
60
+ C(e, R);
61
+ },
62
+ onPaginationChange: (e) => {
63
+ C(e, p);
64
+ },
65
+ onRowSelectionChange: (e) => {
66
+ C(e, k);
67
+ },
68
+ autoResetPageIndex: !1,
69
+ manualPagination: t.manualPagination,
70
+ // set to false to enable client-side pagination
71
+ manualSorting: t.manualSorting,
72
+ state: {
73
+ get sorting() {
74
+ return R.value;
75
+ },
76
+ get pagination() {
77
+ return p.value;
78
+ },
79
+ get rowSelection() {
80
+ return k.value;
81
+ },
82
+ get columnVisibility() {
83
+ return E.value;
84
+ }
85
+ },
86
+ getRowId: t.getRowId
87
+ }), $ = S({
88
+ get() {
89
+ return i.getState().pagination.pageSize;
90
+ },
91
+ set(e) {
92
+ p.value && (p.value.pageSize = e, i.setPageSize(e), i.setPageIndex(0));
93
+ }
94
+ }), _ = S({
95
+ get() {
96
+ return i.getState().pagination.pageIndex + 1;
97
+ },
98
+ set(e) {
99
+ p.value && (p.value.pageIndex = e - 1, i.setPageIndex(e - 1));
100
+ }
101
+ });
102
+ U(() => {
103
+ const e = i.getPageCount();
104
+ e && e < _.value && (_.value = e);
105
+ });
106
+ const M = S(() => t.groupBy ? i.getRowModel().rows.reduce((e, u) => {
107
+ const r = u.getValue(t.groupBy) ?? N;
108
+ return e[r] = e[r] || [], e[r].push(u), e;
109
+ }, /* @__PURE__ */ Object.create(null)) : null);
110
+ function h(e) {
111
+ return (t.groupBy && t.groupLabels ? t.groupLabels[t.groupBy] || [] : [])[e];
112
+ }
113
+ return (e, u) => (n(), s(d, null, [
114
+ e.$slots.caption ? (n(), s("div", te, [
115
+ V(e.$slots, "caption", { table: o(i) })
116
+ ])) : y("", !0),
117
+ g(o(J), null, {
118
+ default: a(() => [
119
+ g(o(X), null, {
120
+ default: a(() => [
121
+ (n(!0), s(d, null, f(o(i).getHeaderGroups(), (l) => (n(), m(o(P), {
122
+ key: l.id
123
+ }, {
124
+ default: a(() => [
125
+ (n(!0), s(d, null, f(l.headers, (r) => (n(), m(o(W), {
126
+ key: r.id
127
+ }, {
128
+ default: a(() => [
129
+ r.isPlaceholder ? y("", !0) : (n(), m(o(A), {
130
+ key: 0,
131
+ render: r.column.columnDef.header,
132
+ props: r.getContext()
133
+ }, null, 8, ["render", "props"]))
134
+ ]),
135
+ _: 2
136
+ }, 1024))), 128))
137
+ ]),
138
+ _: 2
139
+ }, 1024))), 128))
140
+ ]),
141
+ _: 1
142
+ }),
143
+ g(o(Q), null, {
144
+ default: a(() => [
145
+ o(i).getRowModel().rows?.length ? (n(), s(d, { key: 0 }, [
146
+ t.groupBy && M.value ? (n(!0), s(d, { key: 0 }, f(M.value, (l, r) => (n(), m(o(O), {
147
+ asChild: "",
148
+ key: r,
149
+ open: !0
150
+ }, {
151
+ default: a(() => [
152
+ g(o(T), { asChild: "" }, {
153
+ default: a(() => [
154
+ g(o(P), { class: "bg-foreground/[0.04]" }, {
155
+ default: a(() => [
156
+ g(o(x), {
157
+ colspan: e.columns.length,
158
+ class: "!pb-0"
159
+ }, {
160
+ default: a(() => [
161
+ F("div", oe, [
162
+ r === N ? (n(), s(d, { key: 0 }, [
163
+ v(w(h(1)), 1)
164
+ ], 64)) : (n(), s(d, { key: 1 }, [
165
+ v(w(h(0)) + ": " + w(r), 1)
166
+ ], 64))
167
+ ])
168
+ ]),
169
+ _: 2
170
+ }, 1032, ["colspan"])
171
+ ]),
172
+ _: 2
173
+ }, 1024)
174
+ ]),
175
+ _: 2
176
+ }, 1024),
177
+ g(o(G), { asChild: "" }, {
178
+ default: a(() => [
179
+ (n(!0), s(d, null, f(l, (B) => (n(), m(z, {
180
+ key: B.id,
181
+ columns: t.columns,
182
+ row: B,
183
+ renderSubComponent: t.renderSubComponent
184
+ }, null, 8, ["columns", "row", "renderSubComponent"]))), 128))
185
+ ]),
186
+ _: 2
187
+ }, 1024)
188
+ ]),
189
+ _: 2
190
+ }, 1024))), 128)) : (n(!0), s(d, { key: 1 }, f(o(i).getRowModel().rows, (l) => (n(), m(z, {
191
+ key: l.id,
192
+ columns: t.columns,
193
+ row: l,
194
+ renderSubComponent: t.renderSubComponent
195
+ }, null, 8, ["columns", "row", "renderSubComponent"]))), 128))
196
+ ], 64)) : (n(), m(o(Z), {
197
+ key: 1,
198
+ colspan: e.columns.length
199
+ }, {
200
+ default: a(() => [
201
+ V(e.$slots, "nodata", {}, () => [
202
+ u[2] || (u[2] = v("No data"))
203
+ ])
204
+ ]),
205
+ _: 3
206
+ }, 8, ["colspan"]))
207
+ ]),
208
+ _: 3
209
+ }),
210
+ e.showPagination && I.value > 0 ? (n(), m(o(ee), { key: 0 }, {
211
+ default: a(() => [
212
+ g(o(P), null, {
213
+ default: a(() => [
214
+ g(o(x), {
215
+ colspan: e.columns.length
216
+ }, {
217
+ default: a(() => [
218
+ g(o(j), {
219
+ class: "float-right",
220
+ total: I.value,
221
+ pageIndex: _.value,
222
+ "onUpdate:pageIndex": u[0] || (u[0] = (l) => _.value = l),
223
+ pageSize: $.value,
224
+ "onUpdate:pageSize": u[1] || (u[1] = (l) => $.value = l)
225
+ }, null, 8, ["total", "pageIndex", "pageSize"])
226
+ ]),
227
+ _: 1
228
+ }, 8, ["colspan"])
229
+ ]),
230
+ _: 1
231
+ })
232
+ ]),
233
+ _: 1
234
+ })) : y("", !0)
235
+ ]),
236
+ _: 3
237
+ })
238
+ ], 64));
239
+ }
240
+ });
241
+ export {
242
+ ye as _
243
+ };
@@ -1,26 +1,26 @@
1
- import { defineComponent as t, openBlock as s, createElementBlock as n, normalizeClass as l, unref as a, createElementVNode as c, renderSlot as d } from "vue";
2
- import { c as m } from "./utils-DPuEjrVV.js";
3
- const i = { class: "flex h-10 items-center border-r border-border/[0.16] p-4" }, u = /* @__PURE__ */ t({
1
+ import { defineComponent as t, openBlock as s, createElementBlock as n, normalizeClass as a, unref as c, createElementVNode as l, renderSlot as d } from "vue";
2
+ import { c as p } from "./utils-DPuEjrVV.js";
3
+ const i = { class: "flex h-10 items-center whitespace-nowrap border-r border-border/[0.16] p-4" }, h = /* @__PURE__ */ t({
4
4
  __name: "BuiTableHead",
5
5
  props: {
6
6
  class: {}
7
7
  },
8
8
  setup(e) {
9
9
  const o = e;
10
- return (r, p) => (s(), n("th", {
11
- class: l(
12
- a(m)(
10
+ return (r, m) => (s(), n("th", {
11
+ class: a(
12
+ c(p)(
13
13
  "h-14 bg-foreground/[0.04] text-left align-middle text-base font-semibold text-foreground [&:has([role=checkbox])]:pr-0 ",
14
14
  o.class
15
15
  )
16
16
  )
17
17
  }, [
18
- c("div", i, [
18
+ l("div", i, [
19
19
  d(r.$slots, "default")
20
20
  ])
21
21
  ], 2));
22
22
  }
23
23
  });
24
24
  export {
25
- u as _
25
+ h as _
26
26
  };
@@ -1,4 +1,4 @@
1
- import { _ as f } from "../../../BuiDataTable.vue_vue_type_script_setup_true_lang-BBdRXWLA.js";
1
+ import { _ as f } from "../../../BuiDataTable.vue_vue_type_script_setup_true_lang-D2QvMzcY.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,17 +1,20 @@
1
- import { ColumnDef, PaginationState, Row, RowSelectionState, SortingState } from '@tanstack/vue-table';
1
+ import { ColumnDef, PaginationState, Row, RowSelectionState, SortingState, VisibilityState } from '@tanstack/vue-table';
2
2
  declare const _default: <TData, TValue>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
3
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
4
  readonly "onUpdate:sorting"?: ((sorting: SortingState) => any) | undefined;
5
5
  readonly "onUpdate:pagination"?: ((pagination: PaginationState) => any) | undefined;
6
6
  readonly "onUpdate:selection"?: ((selection: RowSelectionState) => any) | undefined;
7
+ readonly "onUpdate:columnVisibility"?: ((columnVisibility: VisibilityState) => any) | undefined;
7
8
  } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Readonly<{}> & Readonly<{
8
9
  "onUpdate:sorting"?: ((sorting: SortingState) => any) | undefined;
9
10
  "onUpdate:pagination"?: ((pagination: PaginationState) => any) | undefined;
10
11
  "onUpdate:selection"?: ((selection: RowSelectionState) => any) | undefined;
11
- }>, never>, "onUpdate:sorting" | "onUpdate:pagination" | "onUpdate:selection"> & ({
12
+ "onUpdate:columnVisibility"?: ((columnVisibility: VisibilityState) => any) | undefined;
13
+ }>, never>, "onUpdate:sorting" | "onUpdate:pagination" | "onUpdate:selection" | "onUpdate:columnVisibility"> & ({
12
14
  sorting?: SortingState;
13
15
  pagination?: PaginationState;
14
16
  selection?: RowSelectionState;
17
+ columnVisibility?: VisibilityState;
15
18
  } & {
16
19
  columns: ColumnDef<TData, TValue>[];
17
20
  data: TData[];
@@ -37,6 +40,7 @@ declare const _default: <TData, TValue>(__VLS_props: NonNullable<Awaited<typeof
37
40
  'update:sorting': [sorting: SortingState];
38
41
  'update:pagination': [pagination: PaginationState];
39
42
  'update:selection': [selection: RowSelectionState];
43
+ 'update:columnVisibility': [columnVisibility: VisibilityState];
40
44
  };
41
45
  }>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
42
46
  [key: string]: any;
@@ -1,4 +1,4 @@
1
- import { _ as f } from "../../../BuiTableHead.vue_vue_type_script_setup_true_lang-bRr43VQ9.js";
1
+ import { _ as f } from "../../../BuiTableHead.vue_vue_type_script_setup_true_lang-CCXONmtG.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,14 +1,14 @@
1
1
  import { _ as e } from "../../../BuiTable.vue_vue_type_script_setup_true_lang-CUPSwE5z.js";
2
2
  import { _ as t } from "../../../BuiTableBody.vue_vue_type_script_setup_true_lang-CWT4u-Ma.js";
3
3
  import { _ as p } from "../../../BuiTableCell.vue_vue_type_script_setup_true_lang-BrTQJCiZ.js";
4
- import { _ as i } from "../../../BuiTableHead.vue_vue_type_script_setup_true_lang-bRr43VQ9.js";
4
+ import { _ as i } from "../../../BuiTableHead.vue_vue_type_script_setup_true_lang-CCXONmtG.js";
5
5
  import { _ as u } from "../../../BuiTableHeader.vue_vue_type_script_setup_true_lang-DZOqi3dp.js";
6
6
  import { _ as f } from "../../../BuiTableRow.vue_vue_type_script_setup_true_lang-CpEilJsW.js";
7
7
  import { _ as x } from "../../../BuiTableRowSubrow.vue_vue_type_script_setup_true_lang-Ch5gemw2.js";
8
8
  import { _ } from "../../../BuiTableCaption.vue_vue_type_script_setup_true_lang-053YvtXp.js";
9
9
  import { _ as w } from "../../../BuiTableEmpty.vue_vue_type_script_setup_true_lang-BJDYHpRG.js";
10
10
  import { _ as C } from "../../../BuiTableFooter.vue_vue_type_script_setup_true_lang-Cfxlxsbh.js";
11
- import { _ as R } from "../../../BuiDataTable.vue_vue_type_script_setup_true_lang-BBdRXWLA.js";
11
+ import { _ as R } from "../../../BuiDataTable.vue_vue_type_script_setup_true_lang-D2QvMzcY.js";
12
12
  export {
13
13
  R as BuiDataTable,
14
14
  e as BuiTable,
package/dist/index.js CHANGED
@@ -109,14 +109,14 @@ import { _ as Mt } from "./BuiSwitch.vue_vue_type_script_setup_true_lang-VtywyEj
109
109
  import { _ as It } from "./BuiTable.vue_vue_type_script_setup_true_lang-CUPSwE5z.js";
110
110
  import { _ as Vt } from "./BuiTableBody.vue_vue_type_script_setup_true_lang-CWT4u-Ma.js";
111
111
  import { _ as ht } from "./BuiTableCell.vue_vue_type_script_setup_true_lang-BrTQJCiZ.js";
112
- import { _ as yt } from "./BuiTableHead.vue_vue_type_script_setup_true_lang-bRr43VQ9.js";
112
+ import { _ as yt } from "./BuiTableHead.vue_vue_type_script_setup_true_lang-CCXONmtG.js";
113
113
  import { _ as Ht } from "./BuiTableHeader.vue_vue_type_script_setup_true_lang-DZOqi3dp.js";
114
114
  import { _ as kt } from "./BuiTableRow.vue_vue_type_script_setup_true_lang-CpEilJsW.js";
115
115
  import { _ as jt } from "./BuiTableRowSubrow.vue_vue_type_script_setup_true_lang-Ch5gemw2.js";
116
116
  import { _ as Ot } from "./BuiTableCaption.vue_vue_type_script_setup_true_lang-053YvtXp.js";
117
117
  import { _ as qt } from "./BuiTableEmpty.vue_vue_type_script_setup_true_lang-BJDYHpRG.js";
118
118
  import { _ as Jt } from "./BuiTableFooter.vue_vue_type_script_setup_true_lang-Cfxlxsbh.js";
119
- import { _ as Qt } from "./BuiDataTable.vue_vue_type_script_setup_true_lang-BBdRXWLA.js";
119
+ import { _ as Qt } from "./BuiDataTable.vue_vue_type_script_setup_true_lang-D2QvMzcY.js";
120
120
  import { BuiTabsList as Xt, BuiTabsTrigger as Yt, tabsListVariants as Zt, tabsTriggerVariants as $t } from "./components/ui/tabs/index.js";
121
121
  import { BuiTextarea as ra, textareaVariants as ea } from "./components/ui/textarea/index.js";
122
122
  import { BuiToast as aa, BuiToaster as ia, toastVariants as ua } from "./components/ui/toast/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soft-stech/bootsman-ui-shadcn",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -53,7 +53,8 @@ const columns: ColumnDef<Task>[] = [
53
53
  {
54
54
  accessorKey: 'priority',
55
55
  header: ({ column }) => tableColumnSortCommon(column, 'Priorities')
56
- }
56
+ },
57
+ { id: 'hiddenColumn', header: 'Hidden Column', cell: 'secret info' }
57
58
  ]
58
59
  const data = ref<Task[]>(tasks)
59
60
 
@@ -137,6 +138,7 @@ function updateRows() {
137
138
  :groupBy="groupBy === 'none' ? undefined : groupBy"
138
139
  :groupLabels="groupLabels"
139
140
  :renderSubComponent="renderSubComponent"
141
+ :columnVisibility="{ hiddenColumn: false }"
140
142
  >
141
143
  <template #caption="{ table }">
142
144
  <div class="flex justify-between">
@@ -12,7 +12,8 @@ import type {
12
12
  PaginationState,
13
13
  Row,
14
14
  RowSelectionState,
15
- SortingState
15
+ SortingState,
16
+ VisibilityState
16
17
  } from '@tanstack/vue-table'
17
18
  import {
18
19
  FlexRender,
@@ -25,7 +26,6 @@ import { computed, watchEffect } from 'vue'
25
26
  import {
26
27
  BuiTable,
27
28
  BuiTableBody,
28
- BuiTableCaption,
29
29
  BuiTableCell,
30
30
  BuiTableEmpty,
31
31
  BuiTableFooter,
@@ -56,6 +56,7 @@ const props = withDefaults(
56
56
  const sorting = defineModel<SortingState>('sorting')
57
57
  const pagination = defineModel<PaginationState>('pagination')
58
58
  const rowSelection = defineModel<RowSelectionState>('selection')
59
+ const columnVisibility = defineModel<VisibilityState>('columnVisibility')
59
60
  const computedItems = computed(() =>
60
61
  props.manualPagination ? props.totalItems : props.data.length
61
62
  )
@@ -91,6 +92,9 @@ const table = useVueTable({
91
92
  },
92
93
  get rowSelection() {
93
94
  return rowSelection.value
95
+ },
96
+ get columnVisibility() {
97
+ return columnVisibility.value
94
98
  }
95
99
  },
96
100
  getRowId: props.getRowId
@@ -144,8 +148,10 @@ function getGroupLabel(index: number) {
144
148
  </script>
145
149
 
146
150
  <template>
151
+ <div v-if="$slots.caption" class="w-full py-4">
152
+ <slot name="caption" :table="table" />
153
+ </div>
147
154
  <BuiTable>
148
- <BuiTableCaption v-if="$slots.caption"><slot name="caption" :table="table" /></BuiTableCaption>
149
155
  <BuiTableHeader>
150
156
  <BuiTableRow v-for="headerGroup in table.getHeaderGroups()" :key="headerGroup.id">
151
157
  <BuiTableHead v-for="header in headerGroup.headers" :key="header.id">
@@ -13,7 +13,7 @@ const props = defineProps<{ class?: string }>()
13
13
  )
14
14
  "
15
15
  >
16
- <div class="flex h-10 items-center border-r border-border/[0.16] p-4">
16
+ <div class="flex h-10 items-center whitespace-nowrap border-r border-border/[0.16] p-4">
17
17
  <slot />
18
18
  </div>
19
19
  </th>
@@ -1,237 +0,0 @@
1
- import { defineComponent as V, mergeModels as D, useModel as b, computed as S, watchEffect as L, openBlock as n, createBlock as i, unref as t, withCtx as a, renderSlot as z, createCommentVNode as v, createVNode as g, createElementBlock as d, Fragment as m, renderList as f, createElementVNode as U, createTextVNode as w, toDisplayString as y } from "vue";
2
- import { _ as F } from "./BuiCollapsible.vue_vue_type_script_setup_true_lang-BfgRYJts.js";
3
- import { _ as O } from "./BuiCollapsibleTrigger.vue_vue_type_script_setup_true_lang-DJ8YMCCp.js";
4
- import { _ as T } from "./BuiCollapsibleContent.vue_vue_type_script_setup_true_lang-eieHE5yV.js";
5
- import { _ as G } from "./BuiPaginationCommon.vue_vue_type_script_setup_true_lang-DjLAqoa-.js";
6
- import { v as C } from "./utils-DPuEjrVV.js";
7
- import { _ as x } from "./BuiTableRowSubrow.vue_vue_type_script_setup_true_lang-Ch5gemw2.js";
8
- import { useVueTable as j, getCoreRowModel as H, getPaginationRowModel as K, getSortedRowModel as Y, FlexRender as q } from "@tanstack/vue-table";
9
- import { _ as A } from "./BuiTable.vue_vue_type_script_setup_true_lang-CUPSwE5z.js";
10
- import { _ as J } from "./BuiTableBody.vue_vue_type_script_setup_true_lang-CWT4u-Ma.js";
11
- import { _ as N } from "./BuiTableCell.vue_vue_type_script_setup_true_lang-BrTQJCiZ.js";
12
- import { _ as Q } from "./BuiTableHead.vue_vue_type_script_setup_true_lang-bRr43VQ9.js";
13
- import { _ as W } from "./BuiTableHeader.vue_vue_type_script_setup_true_lang-DZOqi3dp.js";
14
- import { _ as P } from "./BuiTableRow.vue_vue_type_script_setup_true_lang-CpEilJsW.js";
15
- import { _ as X } from "./BuiTableCaption.vue_vue_type_script_setup_true_lang-053YvtXp.js";
16
- import { _ as Z } from "./BuiTableEmpty.vue_vue_type_script_setup_true_lang-BJDYHpRG.js";
17
- import { _ as ee } from "./BuiTableFooter.vue_vue_type_script_setup_true_lang-Cfxlxsbh.js";
18
- const te = { class: "inline-block rounded-t bg-background px-4 py-3" }, E = "#UNDEFINED#", ve = /* @__PURE__ */ V({
19
- __name: "BuiDataTable",
20
- props: /* @__PURE__ */ D({
21
- columns: {},
22
- data: {},
23
- pageSize: { default: 10 },
24
- showPagination: { type: Boolean, default: !0 },
25
- totalItems: { default: 0 },
26
- manualPagination: { type: Boolean, default: !0 },
27
- manualSorting: { type: Boolean, default: !0 },
28
- groupBy: {},
29
- groupLabels: {},
30
- getRowId: {},
31
- renderSubComponent: {}
32
- }, {
33
- sorting: {},
34
- sortingModifiers: {},
35
- pagination: {},
36
- paginationModifiers: {},
37
- selection: {},
38
- selectionModifiers: {}
39
- }),
40
- emits: ["update:sorting", "update:pagination", "update:selection"],
41
- setup(c) {
42
- const o = c, R = b(c, "sorting"), p = b(c, "pagination"), $ = b(c, "selection"), k = S(
43
- () => o.manualPagination ? o.totalItems : o.data.length
44
- ), u = j({
45
- initialState: { pagination: { pageSize: o.pageSize } },
46
- get data() {
47
- return o.data;
48
- },
49
- get columns() {
50
- return o.columns;
51
- },
52
- getCoreRowModel: H(),
53
- getPaginationRowModel: K(),
54
- getSortedRowModel: Y(),
55
- onSortingChange: (e) => {
56
- C(e, R);
57
- },
58
- onPaginationChange: (e) => {
59
- C(e, p);
60
- },
61
- onRowSelectionChange: (e) => {
62
- C(e, $);
63
- },
64
- autoResetPageIndex: !1,
65
- manualPagination: o.manualPagination,
66
- // set to false to enable client-side pagination
67
- manualSorting: o.manualSorting,
68
- state: {
69
- get sorting() {
70
- return R.value;
71
- },
72
- get pagination() {
73
- return p.value;
74
- },
75
- get rowSelection() {
76
- return $.value;
77
- }
78
- },
79
- getRowId: o.getRowId
80
- }), I = S({
81
- get() {
82
- return u.getState().pagination.pageSize;
83
- },
84
- set(e) {
85
- p.value && (p.value.pageSize = e, u.setPageSize(e), u.setPageIndex(0));
86
- }
87
- }), _ = S({
88
- get() {
89
- return u.getState().pagination.pageIndex + 1;
90
- },
91
- set(e) {
92
- p.value && (p.value.pageIndex = e - 1, u.setPageIndex(e - 1));
93
- }
94
- });
95
- L(() => {
96
- const e = u.getPageCount();
97
- e && e < _.value && (_.value = e);
98
- });
99
- const M = S(() => o.groupBy ? u.getRowModel().rows.reduce((e, s) => {
100
- const r = s.getValue(o.groupBy) ?? E;
101
- return e[r] = e[r] || [], e[r].push(s), e;
102
- }, /* @__PURE__ */ Object.create(null)) : null);
103
- function B(e) {
104
- return (o.groupBy && o.groupLabels ? o.groupLabels[o.groupBy] || [] : [])[e];
105
- }
106
- return (e, s) => (n(), i(t(A), null, {
107
- default: a(() => [
108
- e.$slots.caption ? (n(), i(t(X), { key: 0 }, {
109
- default: a(() => [
110
- z(e.$slots, "caption", { table: t(u) })
111
- ]),
112
- _: 3
113
- })) : v("", !0),
114
- g(t(W), null, {
115
- default: a(() => [
116
- (n(!0), d(m, null, f(t(u).getHeaderGroups(), (l) => (n(), i(t(P), {
117
- key: l.id
118
- }, {
119
- default: a(() => [
120
- (n(!0), d(m, null, f(l.headers, (r) => (n(), i(t(Q), {
121
- key: r.id
122
- }, {
123
- default: a(() => [
124
- r.isPlaceholder ? v("", !0) : (n(), i(t(q), {
125
- key: 0,
126
- render: r.column.columnDef.header,
127
- props: r.getContext()
128
- }, null, 8, ["render", "props"]))
129
- ]),
130
- _: 2
131
- }, 1024))), 128))
132
- ]),
133
- _: 2
134
- }, 1024))), 128))
135
- ]),
136
- _: 1
137
- }),
138
- g(t(J), null, {
139
- default: a(() => [
140
- t(u).getRowModel().rows?.length ? (n(), d(m, { key: 0 }, [
141
- o.groupBy && M.value ? (n(!0), d(m, { key: 0 }, f(M.value, (l, r) => (n(), i(t(F), {
142
- asChild: "",
143
- key: r,
144
- open: !0
145
- }, {
146
- default: a(() => [
147
- g(t(O), { asChild: "" }, {
148
- default: a(() => [
149
- g(t(P), { class: "bg-foreground/[0.04]" }, {
150
- default: a(() => [
151
- g(t(N), {
152
- colspan: e.columns.length,
153
- class: "!pb-0"
154
- }, {
155
- default: a(() => [
156
- U("div", te, [
157
- r === E ? (n(), d(m, { key: 0 }, [
158
- w(y(B(1)), 1)
159
- ], 64)) : (n(), d(m, { key: 1 }, [
160
- w(y(B(0)) + ": " + y(r), 1)
161
- ], 64))
162
- ])
163
- ]),
164
- _: 2
165
- }, 1032, ["colspan"])
166
- ]),
167
- _: 2
168
- }, 1024)
169
- ]),
170
- _: 2
171
- }, 1024),
172
- g(t(T), { asChild: "" }, {
173
- default: a(() => [
174
- (n(!0), d(m, null, f(l, (h) => (n(), i(x, {
175
- key: h.id,
176
- columns: o.columns,
177
- row: h,
178
- renderSubComponent: o.renderSubComponent
179
- }, null, 8, ["columns", "row", "renderSubComponent"]))), 128))
180
- ]),
181
- _: 2
182
- }, 1024)
183
- ]),
184
- _: 2
185
- }, 1024))), 128)) : (n(!0), d(m, { key: 1 }, f(t(u).getRowModel().rows, (l) => (n(), i(x, {
186
- key: l.id,
187
- columns: o.columns,
188
- row: l,
189
- renderSubComponent: o.renderSubComponent
190
- }, null, 8, ["columns", "row", "renderSubComponent"]))), 128))
191
- ], 64)) : (n(), i(t(Z), {
192
- key: 1,
193
- colspan: e.columns.length
194
- }, {
195
- default: a(() => [
196
- z(e.$slots, "nodata", {}, () => [
197
- s[2] || (s[2] = w("No data"))
198
- ])
199
- ]),
200
- _: 3
201
- }, 8, ["colspan"]))
202
- ]),
203
- _: 3
204
- }),
205
- e.showPagination && k.value > 0 ? (n(), i(t(ee), { key: 1 }, {
206
- default: a(() => [
207
- g(t(P), null, {
208
- default: a(() => [
209
- g(t(N), {
210
- colspan: e.columns.length
211
- }, {
212
- default: a(() => [
213
- g(t(G), {
214
- class: "float-right",
215
- total: k.value,
216
- pageIndex: _.value,
217
- "onUpdate:pageIndex": s[0] || (s[0] = (l) => _.value = l),
218
- pageSize: I.value,
219
- "onUpdate:pageSize": s[1] || (s[1] = (l) => I.value = l)
220
- }, null, 8, ["total", "pageIndex", "pageSize"])
221
- ]),
222
- _: 1
223
- }, 8, ["colspan"])
224
- ]),
225
- _: 1
226
- })
227
- ]),
228
- _: 1
229
- })) : v("", !0)
230
- ]),
231
- _: 3
232
- }));
233
- }
234
- });
235
- export {
236
- ve as _
237
- };