@soft-stech/bootsman-ui-shadcn 1.2.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,21 +1,21 @@
1
- import { defineComponent as V, mergeModels as D, useModel as S, computed as _, openBlock as n, createBlock as s, unref as t, withCtx as a, renderSlot as E, createCommentVNode as b, createVNode as g, createElementBlock as d, Fragment as m, renderList as f, createElementVNode as L, createTextVNode as y, toDisplayString as w } from "vue";
2
- import { _ as U } from "./BuiCollapsible.vue_vue_type_script_setup_true_lang-BfgRYJts.js";
3
- import { _ as F } from "./BuiCollapsibleTrigger.vue_vue_type_script_setup_true_lang-DJ8YMCCp.js";
4
- import { _ as O } from "./BuiCollapsibleContent.vue_vue_type_script_setup_true_lang-eieHE5yV.js";
5
- import { _ as T } from "./BuiPaginationCommon.vue_vue_type_script_setup_true_lang-6BhiWgI6.js";
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 h, createCommentVNode as w, createVNode as g, createElementBlock as d, Fragment as m, renderList as f, createElementVNode as U, createTextVNode as y, toDisplayString as v } 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-6BhiWgI6.js";
6
6
  import { v as C } from "./utils-DPuEjrVV.js";
7
- import { _ as h } from "./BuiTableRowSubrow.vue_vue_type_script_setup_true_lang-Ch5gemw2.js";
8
- import { useVueTable as G, getCoreRowModel as j, getPaginationRowModel as H, getSortedRowModel as K, FlexRender as Y } from "@tanstack/vue-table";
9
- import { _ as q } from "./BuiTable.vue_vue_type_script_setup_true_lang-CUPSwE5z.js";
10
- import { _ as A } from "./BuiTableBody.vue_vue_type_script_setup_true_lang-CWT4u-Ma.js";
11
- import { _ as z } from "./BuiTableCell.vue_vue_type_script_setup_true_lang-BrTQJCiZ.js";
12
- import { _ as J } from "./BuiTableHead.vue_vue_type_script_setup_true_lang-bRr43VQ9.js";
13
- import { _ as Q } from "./BuiTableHeader.vue_vue_type_script_setup_true_lang-DZOqi3dp.js";
14
- import { _ as v } from "./BuiTableRow.vue_vue_type_script_setup_true_lang-CpEilJsW.js";
15
- import { _ as W } from "./BuiTableCaption.vue_vue_type_script_setup_true_lang-053YvtXp.js";
16
- import { _ as X } from "./BuiTableEmpty.vue_vue_type_script_setup_true_lang-BJDYHpRG.js";
17
- import { _ as Z } from "./BuiTableFooter.vue_vue_type_script_setup_true_lang-Cfxlxsbh.js";
18
- const ee = { class: "inline-block rounded-t bg-background px-4 py-3" }, x = "#UNDEFINED#", be = /* @__PURE__ */ V({
7
+ import { _ as z } 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 x } 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" }, N = "#UNDEFINED#", we = /* @__PURE__ */ V({
19
19
  __name: "BuiDataTable",
20
20
  props: /* @__PURE__ */ D({
21
21
  columns: {},
@@ -39,9 +39,9 @@ const ee = { class: "inline-block rounded-t bg-background px-4 py-3" }, x = "#UN
39
39
  }),
40
40
  emits: ["update:sorting", "update:pagination", "update:selection"],
41
41
  setup(c) {
42
- const o = c, k = S(c, "sorting"), p = S(c, "pagination"), P = S(c, "selection"), N = _(
42
+ const o = c, R = b(c, "sorting"), p = b(c, "pagination"), $ = b(c, "selection"), E = S(
43
43
  () => o.manualPagination ? o.totalItems : o.data.length
44
- ), u = G({
44
+ ), l = j({
45
45
  initialState: { pagination: { pageSize: o.pageSize } },
46
46
  get data() {
47
47
  return o.data;
@@ -49,76 +49,82 @@ const ee = { class: "inline-block rounded-t bg-background px-4 py-3" }, x = "#UN
49
49
  get columns() {
50
50
  return o.columns;
51
51
  },
52
- getCoreRowModel: j(),
53
- getPaginationRowModel: H(),
54
- getSortedRowModel: K(),
52
+ getCoreRowModel: H(),
53
+ getPaginationRowModel: K(),
54
+ getSortedRowModel: Y(),
55
55
  onSortingChange: (e) => {
56
- C(e, k);
56
+ C(e, R);
57
57
  },
58
58
  onPaginationChange: (e) => {
59
59
  C(e, p);
60
60
  },
61
61
  onRowSelectionChange: (e) => {
62
- C(e, P);
62
+ C(e, $);
63
63
  },
64
+ autoResetPageIndex: !1,
64
65
  manualPagination: o.manualPagination,
65
66
  // set to false to enable client-side pagination
66
67
  manualSorting: o.manualSorting,
67
68
  state: {
68
69
  get sorting() {
69
- return k.value;
70
+ return R.value;
70
71
  },
71
72
  get pagination() {
72
73
  return p.value;
73
74
  },
74
75
  get rowSelection() {
75
- return P.value;
76
+ return $.value;
76
77
  }
77
78
  },
78
79
  getRowId: o.getRowId
79
- }), R = _({
80
+ }), k = S({
80
81
  get() {
81
- return u.getState().pagination.pageSize;
82
+ return l.getState().pagination.pageSize;
82
83
  },
83
84
  set(e) {
84
- p.value && (p.value.pageSize = e, u.setPageSize(e), u.setPageIndex(0));
85
+ p.value && (p.value.pageSize = e, l.setPageSize(e), l.setPageIndex(0));
85
86
  }
86
- }), $ = _({
87
+ }), _ = S({
87
88
  get() {
88
- return u.getState().pagination.pageIndex + 1;
89
+ return l.getState().pagination.pageIndex + 1;
89
90
  },
90
91
  set(e) {
91
- p.value && (p.value.pageIndex = e - 1, u.setPageIndex(e - 1));
92
+ p.value && (p.value.pageIndex = e - 1, l.setPageIndex(e - 1));
92
93
  }
93
- }), I = _(() => o.groupBy ? u.getRowModel().rows.reduce((e, i) => {
94
- const l = i.getValue(o.groupBy) ?? x;
95
- return e[l] = e[l] || [], e[l].push(i), e;
94
+ });
95
+ L(() => {
96
+ const e = l.getPageCount();
97
+ e && e < _.value && (_.value = e);
98
+ });
99
+ const I = S(() => o.groupBy ? l.getRowModel().rows.reduce((e, s) => {
100
+ const u = s.getValue(o.groupBy) ?? N;
101
+ return e[u] = e[u] || [], e[u].push(s), e;
96
102
  }, /* @__PURE__ */ Object.create(null)) : null);
97
103
  function M(e) {
98
104
  return (o.groupBy && o.groupLabels ? o.groupLabels[o.groupBy] || [] : [])[e];
99
105
  }
100
- return (e, i) => (n(), s(t(q), null, {
106
+ return (e, s) => (n(), i(t(A), null, {
101
107
  default: a(() => [
102
- e.$slots.caption ? (n(), s(t(W), { key: 0 }, {
108
+ e.$slots.caption ? (n(), i(t(X), { key: 0 }, {
103
109
  default: a(() => [
104
- E(e.$slots, "caption", { table: t(u) })
110
+ h(e.$slots, "caption", { table: t(l) })
105
111
  ]),
106
112
  _: 3
107
- })) : b("", !0),
108
- g(t(Q), null, {
113
+ })) : w("", !0),
114
+ g(t(W), null, {
109
115
  default: a(() => [
110
- (n(!0), d(m, null, f(t(u).getHeaderGroups(), (r) => (n(), s(t(v), {
116
+ (n(!0), d(m, null, f(t(l).getHeaderGroups(), (r) => (n(), i(t(P), {
111
117
  key: r.id
112
118
  }, {
113
119
  default: a(() => [
114
- (n(!0), d(m, null, f(r.headers, (l) => (n(), s(t(J), {
115
- key: l.id
120
+ (n(!0), d(m, null, f(r.headers, (u) => (n(), i(t(Q), {
121
+ key: u.id
116
122
  }, {
117
123
  default: a(() => [
118
- l.isPlaceholder ? b("", !0) : (n(), s(t(Y), {
124
+ u.isPlaceholder ? w("", !0) : (n(), i(t(q), {
119
125
  key: 0,
120
- render: l.column.columnDef.header,
121
- props: l.getContext()
126
+ render: u.column.columnDef.header,
127
+ props: u.getContext()
122
128
  }, null, 8, ["render", "props"]))
123
129
  ]),
124
130
  _: 2
@@ -129,29 +135,29 @@ const ee = { class: "inline-block rounded-t bg-background px-4 py-3" }, x = "#UN
129
135
  ]),
130
136
  _: 1
131
137
  }),
132
- g(t(A), null, {
138
+ g(t(J), null, {
133
139
  default: a(() => [
134
- t(u).getRowModel().rows?.length ? (n(), d(m, { key: 0 }, [
135
- o.groupBy && I.value ? (n(!0), d(m, { key: 0 }, f(I.value, (r, l) => (n(), s(t(U), {
140
+ t(l).getRowModel().rows?.length ? (n(), d(m, { key: 0 }, [
141
+ o.groupBy && I.value ? (n(!0), d(m, { key: 0 }, f(I.value, (r, u) => (n(), i(t(F), {
136
142
  asChild: "",
137
- key: l,
143
+ key: u,
138
144
  open: !0
139
145
  }, {
140
146
  default: a(() => [
141
- g(t(F), { asChild: "" }, {
147
+ g(t(O), { asChild: "" }, {
142
148
  default: a(() => [
143
- g(t(v), { class: "bg-foreground/[0.04]" }, {
149
+ g(t(P), { class: "bg-foreground/[0.04]" }, {
144
150
  default: a(() => [
145
- g(t(z), {
151
+ g(t(x), {
146
152
  colspan: e.columns.length,
147
153
  class: "!pb-0"
148
154
  }, {
149
155
  default: a(() => [
150
- L("div", ee, [
151
- l === x ? (n(), d(m, { key: 0 }, [
152
- y(w(M(1)), 1)
156
+ U("div", te, [
157
+ u === N ? (n(), d(m, { key: 0 }, [
158
+ y(v(M(1)), 1)
153
159
  ], 64)) : (n(), d(m, { key: 1 }, [
154
- y(w(M(0)) + ": " + w(l), 1)
160
+ y(v(M(0)) + ": " + v(u), 1)
155
161
  ], 64))
156
162
  ])
157
163
  ]),
@@ -163,9 +169,9 @@ const ee = { class: "inline-block rounded-t bg-background px-4 py-3" }, x = "#UN
163
169
  ]),
164
170
  _: 2
165
171
  }, 1024),
166
- g(t(O), { asChild: "" }, {
172
+ g(t(T), { asChild: "" }, {
167
173
  default: a(() => [
168
- (n(!0), d(m, null, f(r, (B) => (n(), s(h, {
174
+ (n(!0), d(m, null, f(r, (B) => (n(), i(z, {
169
175
  key: B.id,
170
176
  columns: o.columns,
171
177
  row: B,
@@ -176,39 +182,41 @@ const ee = { class: "inline-block rounded-t bg-background px-4 py-3" }, x = "#UN
176
182
  }, 1024)
177
183
  ]),
178
184
  _: 2
179
- }, 1024))), 128)) : (n(!0), d(m, { key: 1 }, f(t(u).getRowModel().rows, (r) => (n(), s(h, {
185
+ }, 1024))), 128)) : (n(!0), d(m, { key: 1 }, f(t(l).getRowModel().rows, (r) => (n(), i(z, {
180
186
  key: r.id,
181
187
  columns: o.columns,
182
188
  row: r,
183
189
  renderSubComponent: o.renderSubComponent
184
190
  }, null, 8, ["columns", "row", "renderSubComponent"]))), 128))
185
- ], 64)) : (n(), s(t(X), {
191
+ ], 64)) : (n(), i(t(Z), {
186
192
  key: 1,
187
193
  colspan: e.columns.length
188
194
  }, {
189
- default: a(() => i[2] || (i[2] = [
190
- y("No data")
191
- ])),
192
- _: 1
195
+ default: a(() => [
196
+ h(e.$slots, "nodata", {}, () => [
197
+ s[2] || (s[2] = y("No data"))
198
+ ])
199
+ ]),
200
+ _: 3
193
201
  }, 8, ["colspan"]))
194
202
  ]),
195
- _: 1
203
+ _: 3
196
204
  }),
197
- e.showPagination && t(u).getPageCount() > 1 ? (n(), s(t(Z), { key: 1 }, {
205
+ e.showPagination && t(l).getPageCount() > 1 ? (n(), i(t(ee), { key: 1 }, {
198
206
  default: a(() => [
199
- g(t(v), null, {
207
+ g(t(P), null, {
200
208
  default: a(() => [
201
- g(t(z), {
209
+ g(t(x), {
202
210
  colspan: e.columns.length
203
211
  }, {
204
212
  default: a(() => [
205
- g(t(T), {
213
+ g(t(G), {
206
214
  class: "float-right",
207
- total: N.value,
208
- pageIndex: $.value,
209
- "onUpdate:pageIndex": i[0] || (i[0] = (r) => $.value = r),
210
- pageSize: R.value,
211
- "onUpdate:pageSize": i[1] || (i[1] = (r) => R.value = r)
215
+ total: E.value,
216
+ pageIndex: _.value,
217
+ "onUpdate:pageIndex": s[0] || (s[0] = (r) => _.value = r),
218
+ pageSize: k.value,
219
+ "onUpdate:pageSize": s[1] || (s[1] = (r) => k.value = r)
212
220
  }, null, 8, ["total", "pageIndex", "pageSize"])
213
221
  ]),
214
222
  _: 1
@@ -218,12 +226,12 @@ const ee = { class: "inline-block rounded-t bg-background px-4 py-3" }, x = "#UN
218
226
  })
219
227
  ]),
220
228
  _: 1
221
- })) : b("", !0)
229
+ })) : w("", !0)
222
230
  ]),
223
231
  _: 3
224
232
  }));
225
233
  }
226
234
  });
227
235
  export {
228
- be as _
236
+ we as _
229
237
  };
@@ -1,4 +1,4 @@
1
- import { _ as f } from "../../../BuiDataTable.vue_vue_type_script_setup_true_lang-B9r03KU3.js";
1
+ import { _ as f } from "../../../BuiDataTable.vue_vue_type_script_setup_true_lang-CBCScilf.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -31,6 +31,7 @@ declare const _default: <TData, TValue>(__VLS_props: NonNullable<Awaited<typeof
31
31
  caption?(_: {
32
32
  table: import('@tanstack/vue-table').Table<TData>;
33
33
  }): any;
34
+ nodata?(_: {}): any;
34
35
  };
35
36
  emit: {
36
37
  'update:sorting': [sorting: SortingState];
@@ -8,7 +8,7 @@ import { _ as x } from "../../../BuiTableRowSubrow.vue_vue_type_script_setup_tru
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-B9r03KU3.js";
11
+ import { _ as R } from "../../../BuiDataTable.vue_vue_type_script_setup_true_lang-CBCScilf.js";
12
12
  export {
13
13
  R as BuiDataTable,
14
14
  e as BuiTable,
package/dist/index.js CHANGED
@@ -116,7 +116,7 @@ import { _ as Et } from "./BuiTableRowSubrow.vue_vue_type_script_setup_true_lang
116
116
  import { _ as Nt } from "./BuiTableCaption.vue_vue_type_script_setup_true_lang-053YvtXp.js";
117
117
  import { _ as Ut } from "./BuiTableEmpty.vue_vue_type_script_setup_true_lang-BJDYHpRG.js";
118
118
  import { _ as zt } from "./BuiTableFooter.vue_vue_type_script_setup_true_lang-Cfxlxsbh.js";
119
- import { _ as Kt } from "./BuiDataTable.vue_vue_type_script_setup_true_lang-B9r03KU3.js";
119
+ import { _ as Kt } from "./BuiDataTable.vue_vue_type_script_setup_true_lang-CBCScilf.js";
120
120
  import { BuiTabsList as Wt, BuiTabsTrigger as Xt, tabsListVariants as Yt, tabsTriggerVariants as Zt } from "./components/ui/tabs/index.js";
121
121
  import { BuiTextarea as oa, textareaVariants as ra } from "./components/ui/textarea/index.js";
122
122
  import { BuiToast as ta, BuiToaster as aa, toastVariants as ia } 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.2.0",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "peerDependencies": {
18
18
  "vue": "^3.5.6",
19
- "zod": "^3.23.8",
19
+ "zod": "^3.23.6",
20
20
  "vee-validate": "^4.13.2",
21
21
  "@tanstack/vue-table": "8.20.5",
22
22
  "@vee-validate/zod": "4.13.2",
@@ -112,6 +112,13 @@ function renderSubComponent(row: Row<Task>) {
112
112
  return undefined
113
113
  }
114
114
  }
115
+
116
+ function deleteRow() {
117
+ data.value = data.value.map((a) => a)
118
+ }
119
+ function updateRows() {
120
+ data.value.shift()
121
+ }
115
122
  </script>
116
123
 
117
124
  <template>
@@ -134,6 +141,8 @@ function renderSubComponent(row: Row<Task>) {
134
141
  <template #caption="{ table }">
135
142
  <div class="flex justify-between">
136
143
  <BuiButton variant="outline">Download YAML</BuiButton>
144
+ <BuiButton variant="outline" @click="updateRows"> Delete row </BuiButton>
145
+ <BuiButton variant="outline" @click="deleteRow"> Update rows </BuiButton>
137
146
 
138
147
  <BuiTabs v-model="groupBy">
139
148
  <BuiTabsList class="grid w-full grid-cols-2" :variant="'default'">
@@ -152,6 +161,7 @@ function renderSubComponent(row: Row<Task>) {
152
161
  </span>
153
162
  </div>
154
163
  </template>
164
+ <template #nodata>Нет данных</template>
155
165
  </BuiDataTable>
156
166
  </Variant>
157
167
  </Story>
@@ -21,7 +21,7 @@ import {
21
21
  getSortedRowModel,
22
22
  useVueTable
23
23
  } from '@tanstack/vue-table'
24
- import { computed } from 'vue'
24
+ import { computed, watchEffect } from 'vue'
25
25
  import {
26
26
  BuiTable,
27
27
  BuiTableBody,
@@ -79,6 +79,7 @@ const table = useVueTable({
79
79
  onRowSelectionChange: (updaterOrValue) => {
80
80
  valueUpdater(updaterOrValue, rowSelection)
81
81
  },
82
+ autoResetPageIndex: false,
82
83
  manualPagination: props.manualPagination, // set to false to enable client-side pagination
83
84
  manualSorting: props.manualSorting,
84
85
  state: {
@@ -117,6 +118,13 @@ const pageIndex = computed({
117
118
  }
118
119
  })
119
120
 
121
+ watchEffect(() => {
122
+ const totalPages = table.getPageCount()
123
+ if (totalPages && totalPages < pageIndex.value) {
124
+ pageIndex.value = totalPages
125
+ }
126
+ })
127
+
120
128
  const groupedRows = computed<{ [key: string]: Row<TData>[] }>(() => {
121
129
  if (!props.groupBy) return null
122
130
 
@@ -188,7 +196,9 @@ function getGroupLabel(index: number) {
188
196
  </template>
189
197
  </template>
190
198
  <template v-else>
191
- <BuiTableEmpty :colspan="columns.length">No data</BuiTableEmpty>
199
+ <BuiTableEmpty :colspan="columns.length">
200
+ <slot name="nodata">No data</slot>
201
+ </BuiTableEmpty>
192
202
  </template>
193
203
  </BuiTableBody>
194
204
  <BuiTableFooter v-if="showPagination && table.getPageCount() > 1">