@bjj/nuxt-layer-shadcn-ui 0.15.5 → 0.15.7

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.
@@ -1,6 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3'
2
2
  import type { AsyncDataTableBatchAction, AsyncDataTableFetchParams, AsyncDataTableFetchResult } from './types'
3
3
  import type { DataTableColumn } from '../DataTable/types'
4
+ import { useArgsModel } from '#storybook/argsModel'
4
5
  import AsyncDataTable from './index.vue'
5
6
 
6
7
  interface User {
@@ -33,12 +34,18 @@ const columns: DataTableColumn[] = [
33
34
  { field: 'createdAt', title: 'Created', width: '140px', type: 'date' },
34
35
  ]
35
36
 
36
- /** Simulated async fetch with sorting support */
37
+ const sortableFields = columns.filter(column => column.sortable).map(column => column.field)
38
+
39
+ /** Simulated async fetch with filtering and sorting support */
37
40
  function mockFetch (params: AsyncDataTableFetchParams): Promise<AsyncDataTableFetchResult<User>> {
38
41
  return new Promise(resolve => {
39
42
  setTimeout(() => {
40
43
  const data = [ ...allUsers ]
41
44
 
45
+ if (params.role) {
46
+ data.splice(0, data.length, ...data.filter(u => u.role === params.role))
47
+ }
48
+
42
49
  if (params.sortBy) {
43
50
  const order = params.sortOrder ?? 1
44
51
  data.sort((a, b) => {
@@ -103,11 +110,14 @@ const meta = {
103
110
  batchActions: [],
104
111
  selection: [],
105
112
  },
106
- render: args => ({
107
- components: { AsyncDataTable },
108
- setup: () => ({ args }),
109
- template: '<AsyncDataTable v-bind="args" />',
110
- }),
113
+ render: args => {
114
+ const onUpdateFilters = useArgsModel('filters')
115
+ return {
116
+ components: { AsyncDataTable },
117
+ setup: () => ({ args, onUpdateFilters }),
118
+ template: '<AsyncDataTable v-bind="args" @update:filters="onUpdateFilters" />',
119
+ }
120
+ },
111
121
  } satisfies Meta<typeof AsyncDataTable>
112
122
 
113
123
  export default meta
@@ -159,6 +169,107 @@ export const WithBatchActions: Story = {
159
169
  }),
160
170
  }
161
171
 
172
+ /** `v-model:filters` holds the whole query state: `page` / `size` / `sortBy` / `sortOrder` live in the same bag as the caller's own filters, so an external panel drives sorting while the table writes its paging and header sorting back. */
173
+ export const FiltersModel: Story = {
174
+ parameters: {
175
+ ...noControls,
176
+ docs: {
177
+ source: {
178
+ code: `
179
+ <template>
180
+ <select v-model="filters.role">
181
+ <option value="">All</option>
182
+ <option value="Admin">Admin</option>
183
+ <option value="Editor">Editor</option>
184
+ <option value="User">User</option>
185
+ </select>
186
+ <select v-model="filters.sortBy">
187
+ <option :value="null">none</option>
188
+ <option v-for="f in sortableFields" :key="f" :value="f">{{ f }}</option>
189
+ </select>
190
+ <select v-model="filters.sortOrder">
191
+ <option :value="null">none</option>
192
+ <option :value="1">asc</option>
193
+ <option :value="-1">desc</option>
194
+ </select>
195
+ <input v-model="filters.page" type="number" min="1">
196
+ <AsyncDataTable
197
+ :columns="columns"
198
+ :fetchMethod="mockFetch"
199
+ v-model:filters="filters"
200
+ />
201
+ </template>
202
+
203
+ <script setup>
204
+ const filters = ref({ role: '', sortBy: null, sortOrder: null })
205
+ </script>
206
+ `.trim(),
207
+ },
208
+ },
209
+ },
210
+ render: () => ({
211
+ components: { AsyncDataTable },
212
+ setup () {
213
+ const filters = ref<Record<string, any>>({ role: '', sortBy: null, sortOrder: null })
214
+ return { columns, mockFetch, sortableFields, filters }
215
+ },
216
+ template: `
217
+ <div class="space-y-3">
218
+ <div class="gap-3 text-sm flex flex-wrap items-center">
219
+ <label class="gap-2 flex items-center">
220
+ Role:
221
+ <select
222
+ v-model="filters.role"
223
+ class="px-2 py-1 border rounded"
224
+ >
225
+ <option value="">All</option>
226
+ <option value="Admin">Admin</option>
227
+ <option value="Editor">Editor</option>
228
+ <option value="User">User</option>
229
+ </select>
230
+ </label>
231
+ <label class="gap-2 flex items-center">
232
+ Sort by:
233
+ <select
234
+ v-model="filters.sortBy"
235
+ class="px-2 py-1 border rounded"
236
+ >
237
+ <option :value="null">none</option>
238
+ <option v-for="f in sortableFields" :key="f" :value="f">{{ f }}</option>
239
+ </select>
240
+ </label>
241
+ <label class="gap-2 flex items-center">
242
+ Order:
243
+ <select
244
+ v-model="filters.sortOrder"
245
+ class="px-2 py-1 border rounded"
246
+ >
247
+ <option :value="null">none</option>
248
+ <option :value="1">asc</option>
249
+ <option :value="-1">desc</option>
250
+ </select>
251
+ </label>
252
+ <label class="gap-2 flex items-center">
253
+ Page:
254
+ <input
255
+ v-model="filters.page"
256
+ type="number"
257
+ min="1"
258
+ class="px-2 py-1 w-16 border rounded"
259
+ >
260
+ </label>
261
+ </div>
262
+ <AsyncDataTable
263
+ :columns="columns"
264
+ :fetchMethod="mockFetch"
265
+ v-model:filters="filters"
266
+ />
267
+ <pre class="text-xs text-muted-foreground">{{ filters }}</pre>
268
+ </div>
269
+ `,
270
+ }),
271
+ }
272
+
162
273
  /** Custom toolbar slot with action button */
163
274
  export const WithCustomToolbar: Story = {
164
275
  parameters: {
@@ -46,6 +46,14 @@ function onSelectionChange (value: TData | TData[] | null) {
46
46
  emit('update:selection', Array.isArray(value) ? value : value ? [ value ] : [])
47
47
  }
48
48
 
49
+ // A fetch replaces the rows on screen — a different page, a different filter,
50
+ // or fresh objects for the same records — so nothing picked before it can
51
+ // still be pointed at. Cleared alongside the rows, in the same tick, so the
52
+ // checkboxes and the batch-action count never disagree about what's selected.
53
+ function clearSelection () {
54
+ if (selectionValue.value.length) emit('update:selection', [])
55
+ }
56
+
49
57
  // -- Internal state --
50
58
 
51
59
  const loading = ref(false)
@@ -62,8 +70,8 @@ const pagination = ref<AsyncDataTablePagination>({
62
70
  })
63
71
 
64
72
  const sortState = ref<{ sortBy: string | null, sortOrder: number | null }>({
65
- sortBy: props.filters?.sortBy ? String(props.filters.sortBy) : null,
66
- sortOrder: props.filters?.sortOrder ? Number(props.filters.sortOrder) : null,
73
+ sortBy: normalizeSortBy(props.filters?.sortBy),
74
+ sortOrder: normalizeSortOrder(props.filters?.sortOrder),
67
75
  })
68
76
 
69
77
  // -- Computed --
@@ -109,13 +117,38 @@ function getFilters (overrides?: Record<string, any>): Record<string, any> {
109
117
  }
110
118
  }
111
119
 
112
- // Strip component-owned fields so v-model:filters round-trips don't refire the watcher.
120
+ // Isolate the caller-owned part of `filters`; the component-owned keys are
121
+ // compared by value instead (see the filters watcher).
113
122
  function getExternalFilters (filters: Record<string, any> | undefined) {
114
123
  if (!filters) return {}
115
124
  const { page, size, sortBy, sortOrder, ...rest } = filters
116
125
  return rest
117
126
  }
118
127
 
128
+ function normalizeSortBy (value: unknown): string | null {
129
+ return value ? String(value) : null
130
+ }
131
+
132
+ function normalizeSortOrder (value: unknown): number | null {
133
+ return value ? Number(value) : null
134
+ }
135
+
136
+ // Incoming shape of the component-owned keys. A query string hands numbers back
137
+ // as strings and drops null keys, so values are coerced before they're compared:
138
+ // that's what keeps our own emits inert when they return through v-model.
139
+ // An absent key means "unspecified — keep what we have"; `sortBy: null` clears
140
+ // the sort, while a missing `page` / `size` has no such meaning.
141
+ function normalizeFilters (filters: Record<string, any> | undefined) {
142
+ const bag = filters ?? {}
143
+ return {
144
+ page: bag.page == null ? pagination.value.page : Number(bag.page) || 1,
145
+ size: bag.size == null ? pagination.value.size : Number(bag.size) || pagination.value.size,
146
+ sortBy: bag.sortBy === undefined ? sortState.value.sortBy : normalizeSortBy(bag.sortBy),
147
+ sortOrder: bag.sortOrder === undefined ? sortState.value.sortOrder : normalizeSortOrder(bag.sortOrder),
148
+ external: JSON.stringify(getExternalFilters(bag)),
149
+ }
150
+ }
151
+
119
152
  function buildFetchParams (): AsyncDataTableFetchParams {
120
153
  const filters = getFilters()
121
154
  const { page, size, ...rest } = filters
@@ -146,6 +179,7 @@ async function fetchData (page?: number, forceRefresh = false) {
146
179
 
147
180
  internalData.value = result.items as TData[]
148
181
  pagination.value.total = result.total
182
+ clearSelection()
149
183
  } catch (error) {
150
184
  if (currentVersion !== requestVersion.value) return
151
185
  console.error('AsyncDataTable fetchData failed:', error)
@@ -153,6 +187,7 @@ async function fetchData (page?: number, forceRefresh = false) {
153
187
  // previous page's rows on screen while the pagination already moved on.
154
188
  errored.value = true
155
189
  internalData.value = []
190
+ clearSelection()
156
191
  } finally {
157
192
  if (currentVersion === requestVersion.value) loading.value = false
158
193
  }
@@ -206,11 +241,34 @@ function scheduleAfterSort () {
206
241
  })
207
242
  }
208
243
 
209
- // -- External filters: any change resets to page 1 and reloads --
244
+ // -- External filters --
245
+ // `filters` carries the whole query state, so incoming page / size / sort are
246
+ // adopted as well — that's what lets a toolbar panel drive sorting or paging.
247
+
248
+ let lastExternalFilters = JSON.stringify(getExternalFilters(props.filters))
249
+
250
+ watch(() => normalizeFilters(props.filters), incoming => {
251
+ const externalChanged = incoming.external !== lastExternalFilters
252
+ lastExternalFilters = incoming.external
210
253
 
211
- watch(() => JSON.stringify(getExternalFilters(props.filters)), () => {
254
+ const pageChanged = incoming.page !== pagination.value.page
255
+ const sizeChanged = incoming.size !== pagination.value.size
256
+ const sortChanged = incoming.sortBy !== sortState.value.sortBy
257
+ || incoming.sortOrder !== sortState.value.sortOrder
258
+ if (!externalChanged && !pageChanged && !sizeChanged && !sortChanged) return
259
+
260
+ // A different row set restarts at page 1, unless the same change also asked
261
+ // for a specific page — restoring a bookmarked query, say.
262
+ const rowSetChanged = externalChanged || sizeChanged || sortChanged
263
+ if (sortChanged) sortState.value = { sortBy: incoming.sortBy, sortOrder: incoming.sortOrder }
264
+ if (sizeChanged) pagination.value.size = incoming.size
265
+ if (pageChanged) pagination.value.page = incoming.page
266
+ else if (rowSetChanged) pagination.value.page = 1
267
+ if (rowSetChanged) pagination.value.total = 0
268
+
269
+ emit('update:filters', getFilters())
212
270
  if (!started.value) return
213
- resetPagination()
271
+ fetchData(undefined, true)
214
272
  })
215
273
 
216
274
  // -- Expose --
@@ -24,7 +24,13 @@ export interface AsyncDataTableProps<T = Record<string, any>> {
24
24
  autoFetch?: boolean
25
25
  /** Column definitions */
26
26
  columns?: DataTableColumn[]
27
- /** External filter state */
27
+ /**
28
+ * Whole query state (v-model:filters): the caller's own filter fields plus the
29
+ * component-owned `page` / `size` / `sortBy` / `sortOrder`. Incoming changes to
30
+ * the owned keys are adopted too, so an external panel can drive sorting and
31
+ * paging. An absent owned key keeps the current value; `sortBy: null` clears
32
+ * the sort. Changing anything else restarts at page 1.
33
+ */
28
34
  filters?: Record<string, any>
29
35
  /** Whether to show top toolbar (undefined = auto when page size >= `topToolbarThreshold`) */
30
36
  showTopToolbar?: boolean
@@ -42,6 +48,6 @@ export interface AsyncDataTableProps<T = Record<string, any>> {
42
48
  clickable?: boolean
43
49
  /** Batch action definitions for selected rows */
44
50
  batchActions?: AsyncDataTableBatchAction<T>[]
45
- /** Selected rows (v-model:selection) */
51
+ /** Selected rows (v-model:selection). Cleared whenever a fetch replaces the rows — paging, sorting, filtering, refresh. */
46
52
  selection?: T[]
47
53
  }
@@ -59,13 +59,15 @@ const selectedSet = computed(() => {
59
59
  return new Set(selection.value.map(r => toRaw(r) as TData))
60
60
  })
61
61
 
62
- // Header "select all" checkbox
62
+ // Header "select all" checkbox. Derived from the rows on screen rather than
63
+ // from the selection size, so a selection still holding rows from elsewhere
64
+ // can't read as "all selected".
63
65
  const allChecked = computed({
64
66
  get () {
65
67
  if (!props.data?.length) return false
66
- const size = selectedSet.value.size
67
- if (size === props.data.length) return true
68
- if (size > 0) return 'indeterminate' as const
68
+ const selectedOnPage = props.data.filter(row => selectedSet.value.has(toRaw(row) as TData)).length
69
+ if (selectedOnPage === props.data.length) return true
70
+ if (selectedOnPage > 0) return 'indeterminate' as const
69
71
  return false
70
72
  },
71
73
  set (val: boolean | 'indeterminate') {
@@ -1,6 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3'
2
2
  import type { DataTableColumn } from '../DataTable/types'
3
3
  import type { InfiniteDataTableFetchParams, InfiniteDataTableFetchResult } from './types'
4
+ import { useArgsModel } from '#storybook/argsModel'
4
5
  import InfiniteDataTable from './index.vue'
5
6
 
6
7
  interface User {
@@ -32,6 +33,8 @@ const columns: DataTableColumn[] = [
32
33
  { field: 'createdAt', title: 'Created', width: '140px', type: 'date' },
33
34
  ]
34
35
 
36
+ const sortableFields = columns.filter(column => column.sortable).map(column => column.field)
37
+
35
38
  /** Mock fetch using offset as the opaque cursor */
36
39
  function mockFetch (params: InfiniteDataTableFetchParams): Promise<InfiniteDataTableFetchResult<User>> {
37
40
  return new Promise(resolve => {
@@ -86,11 +89,14 @@ const meta = {
86
89
  height: '360px',
87
90
  clickable: false,
88
91
  },
89
- render: args => ({
90
- components: { InfiniteDataTable: InfiniteDataTable as any },
91
- setup: () => ({ args }),
92
- template: '<InfiniteDataTable v-bind="args" />',
93
- }),
92
+ render: args => {
93
+ const onUpdateFilters = useArgsModel('filters')
94
+ return {
95
+ components: { InfiniteDataTable: InfiniteDataTable as any },
96
+ setup: () => ({ args, onUpdateFilters }),
97
+ template: '<InfiniteDataTable v-bind="args" @update:filters="onUpdateFilters" />',
98
+ }
99
+ },
94
100
  } satisfies Meta<typeof InfiniteDataTable>
95
101
 
96
102
  export default meta
@@ -158,6 +164,81 @@ export const WithFilters: Story = {
158
164
  }),
159
165
  }
160
166
 
167
+ /** `v-model:filters` holds the whole query state: `sortBy` / `sortOrder` live in the same bag as the caller's own filters, so an external panel drives sorting while the table writes its header sorting back. */
168
+ export const FiltersModel: Story = {
169
+ parameters: {
170
+ ...noControls,
171
+ docs: {
172
+ source: {
173
+ code: `
174
+ <template>
175
+ <select v-model="filters.sortBy">
176
+ <option :value="null">none</option>
177
+ <option v-for="f in sortableFields" :key="f" :value="f">{{ f }}</option>
178
+ </select>
179
+ <select v-model="filters.sortOrder">
180
+ <option :value="null">none</option>
181
+ <option :value="1">asc</option>
182
+ <option :value="-1">desc</option>
183
+ </select>
184
+ <InfiniteDataTable
185
+ :columns="columns"
186
+ :fetchMethod="mockFetch"
187
+ v-model:filters="filters"
188
+ height="360px"
189
+ />
190
+ </template>
191
+
192
+ <script setup>
193
+ const filters = ref({ sortBy: null, sortOrder: null })
194
+ </script>
195
+ `.trim(),
196
+ },
197
+ },
198
+ },
199
+ render: () => ({
200
+ components: { InfiniteDataTable: InfiniteDataTable as any },
201
+ setup () {
202
+ const filters = ref<Record<string, any>>({ sortBy: null, sortOrder: null })
203
+ return { columns, mockFetch, sortableFields, filters }
204
+ },
205
+ template: `
206
+ <div class="space-y-3">
207
+ <div class="gap-3 text-sm flex flex-wrap items-center">
208
+ <label class="gap-2 flex items-center">
209
+ Sort by:
210
+ <select
211
+ v-model="filters.sortBy"
212
+ class="px-2 py-1 border rounded"
213
+ >
214
+ <option :value="null">none</option>
215
+ <option v-for="f in sortableFields" :key="f" :value="f">{{ f }}</option>
216
+ </select>
217
+ </label>
218
+ <label class="gap-2 flex items-center">
219
+ Order:
220
+ <select
221
+ v-model="filters.sortOrder"
222
+ class="px-2 py-1 border rounded"
223
+ >
224
+ <option :value="null">none</option>
225
+ <option :value="1">asc</option>
226
+ <option :value="-1">desc</option>
227
+ </select>
228
+ </label>
229
+ </div>
230
+ <InfiniteDataTable
231
+ :columns="columns"
232
+ :fetchMethod="mockFetch"
233
+ v-model:filters="filters"
234
+ height="360px"
235
+ />
236
+ <pre class="text-xs text-muted-foreground">{{ filters }}</pre>
237
+ </div>
238
+ `,
239
+ }),
240
+ }
241
+
161
242
  /** No fixed height — the page scrolls and triggers loading at the bottom */
162
243
  export const PageScroll: Story = {
163
244
  parameters: noControls,
@@ -38,8 +38,8 @@ const requestVersion = ref(0)
38
38
  const started = ref(false)
39
39
 
40
40
  const sortState = ref<{ sortBy: string | null, sortOrder: number | null }>({
41
- sortBy: props.filters?.sortBy ? String(props.filters.sortBy) : null,
42
- sortOrder: props.filters?.sortOrder ? Number(props.filters.sortOrder) : null,
41
+ sortBy: normalizeSortBy(props.filters?.sortBy),
42
+ sortOrder: normalizeSortOrder(props.filters?.sortOrder),
43
43
  })
44
44
 
45
45
  const isInitialLoad = computed(() => loading.value && internalData.value.length === 0)
@@ -89,13 +89,36 @@ function getFilters (): Record<string, any> {
89
89
  }
90
90
  }
91
91
 
92
- // Strip component-owned fields so v-model:filters round-trips don't refire the watcher.
92
+ // Isolate the caller-owned part of `filters`; the component-owned keys are
93
+ // compared by value instead (see the filters watcher).
93
94
  function getExternalFilters (filters: Record<string, any> | undefined) {
94
95
  if (!filters) return {}
95
96
  const { sortBy, sortOrder, ...rest } = filters
96
97
  return rest
97
98
  }
98
99
 
100
+ function normalizeSortBy (value: unknown): string | null {
101
+ return value ? String(value) : null
102
+ }
103
+
104
+ function normalizeSortOrder (value: unknown): number | null {
105
+ return value ? Number(value) : null
106
+ }
107
+
108
+ // Incoming shape of the component-owned keys. A query string hands numbers back
109
+ // as strings and drops null keys, so values are coerced before they're compared:
110
+ // that's what keeps our own emits inert when they return through v-model.
111
+ // An absent key means "unspecified — keep what we have"; `sortBy: null` clears
112
+ // the sort.
113
+ function normalizeFilters (filters: Record<string, any> | undefined) {
114
+ const bag = filters ?? {}
115
+ return {
116
+ sortBy: bag.sortBy === undefined ? sortState.value.sortBy : normalizeSortBy(bag.sortBy),
117
+ sortOrder: bag.sortOrder === undefined ? sortState.value.sortOrder : normalizeSortOrder(bag.sortOrder),
118
+ external: JSON.stringify(getExternalFilters(bag)),
119
+ }
120
+ }
121
+
99
122
  function buildFetchParams (): InfiniteDataTableFetchParams {
100
123
  return {
101
124
  ...getFilters(),
@@ -184,10 +207,25 @@ function scheduleAfterSort () {
184
207
  })
185
208
  }
186
209
 
187
- // -- External filters: any change resets and reloads --
210
+ // -- External filters --
211
+ // `filters` carries the whole query state, so an incoming sort is adopted as
212
+ // well — that's what lets a toolbar panel drive sorting.
213
+
214
+ let lastExternalFilters = JSON.stringify(getExternalFilters(props.filters))
188
215
 
189
- watch(() => JSON.stringify(getExternalFilters(props.filters)), () => {
190
- if (!started.value) return
216
+ watch(() => normalizeFilters(props.filters), incoming => {
217
+ const externalChanged = incoming.external !== lastExternalFilters
218
+ lastExternalFilters = incoming.external
219
+
220
+ const sortChanged = incoming.sortBy !== sortState.value.sortBy
221
+ || incoming.sortOrder !== sortState.value.sortOrder
222
+ if (!externalChanged && !sortChanged) return
223
+
224
+ if (sortChanged) sortState.value = { sortBy: incoming.sortBy, sortOrder: incoming.sortOrder }
225
+ if (!started.value) {
226
+ emit('update:filters', getFilters())
227
+ return
228
+ }
191
229
  refresh()
192
230
  })
193
231
 
@@ -24,7 +24,13 @@ export interface InfiniteDataTableProps<T = Record<string, any>> {
24
24
  columns?: DataTableColumn[]
25
25
  /** Whether to fetch the first page on mount (default: true) */
26
26
  autoFetch?: boolean
27
- /** External filter state — changing this resets and reloads */
27
+ /**
28
+ * Whole query state (v-model:filters): the caller's own filter fields plus the
29
+ * component-owned `sortBy` / `sortOrder`. Incoming changes to the owned keys
30
+ * are adopted too, so an external panel can drive sorting. An absent owned key
31
+ * keeps the current value; `sortBy: null` clears the sort. Any change resets
32
+ * and reloads.
33
+ */
28
34
  filters?: Record<string, any>
29
35
  /** Number of rows per page (default: 30) */
30
36
  pageSize?: number
@@ -42,6 +42,12 @@ function onSelectionChange (value: TData | TData[] | null) {
42
42
  emit('update:selection', Array.isArray(value) ? value : value ? [ value ] : [])
43
43
  }
44
44
 
45
+ // Whatever swaps the visible rows also drops what was picked from them, so the
46
+ // checkboxes and the batch-action count never disagree about what's selected.
47
+ function clearSelection () {
48
+ if (selectionValue.value.length) emit('update:selection', [])
49
+ }
50
+
45
51
  // -- Internal state --
46
52
 
47
53
  const pagination = ref<StaticDataTablePagination>({
@@ -91,6 +97,7 @@ watch(
91
97
  [ () => props.data, () => sortState.value.sortBy, () => sortState.value.sortOrder ],
92
98
  () => {
93
99
  pagination.value.page = 1
100
+ clearSelection()
94
101
  },
95
102
  )
96
103
 
@@ -129,12 +136,14 @@ const batchMenuItems = computed<DropdownItem[]>(() =>
129
136
  function onPageChange (newPage: number) {
130
137
  if (newPage === pagination.value.page) return
131
138
  pagination.value.page = newPage
139
+ clearSelection()
132
140
  }
133
141
 
134
142
  function onPageSizeChange (newSize: number) {
135
143
  if (newSize === pagination.value.size) return
136
144
  pagination.value.size = newSize
137
145
  pagination.value.page = 1
146
+ clearSelection()
138
147
  }
139
148
 
140
149
  function onSortByUpdate (value: string | null) {
@@ -32,6 +32,6 @@ export interface StaticDataTableProps<T = Record<string, any>> {
32
32
  clickable?: boolean
33
33
  /** Batch action definitions for selected rows */
34
34
  batchActions?: StaticDataTableBatchAction<T>[]
35
- /** Selected rows (v-model:selection) */
35
+ /** Selected rows (v-model:selection). Cleared whenever the visible rows are swapped — paging, sorting, new data. */
36
36
  selection?: T[]
37
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bjj/nuxt-layer-shadcn-ui",
3
- "version": "0.15.5",
3
+ "version": "0.15.7",
4
4
  "description": "Nuxt layer providing shadcn-vue based UI components",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -42,5 +42,5 @@
42
42
  "vue-i18n": "^11",
43
43
  "vue-router": "^4 || ^5"
44
44
  },
45
- "gitHead": "9014a25cfd667901888b509609282d77c9dc0d21"
45
+ "gitHead": "f9c5a4ca3f0fa3ab4cdfb8f950487d3142031058"
46
46
  }