@innertia-solutions/nuxt-theme-spark 0.1.91 → 0.1.93
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.
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { IconSearch, IconAdjustmentsHorizontal, IconLayoutColumns, IconGripVertical } from '@tabler/icons-vue'
|
|
3
3
|
|
|
4
4
|
const props = defineProps({
|
|
5
|
-
|
|
5
|
+
table: { type: Object, default: null },
|
|
6
|
+
endpoint: { type: String, default: '' },
|
|
6
7
|
columns: { type: Array, required: true },
|
|
7
|
-
name: { type: String,
|
|
8
|
+
name: { type: String, default: '' },
|
|
8
9
|
params: { type: Object, default: () => ({}) },
|
|
9
10
|
checkable: { type: Boolean, default: false },
|
|
10
11
|
cached: { type: Boolean, default: true },
|
|
@@ -18,6 +19,9 @@ const props = defineProps({
|
|
|
18
19
|
splitRatio: { type: Number, default: 60 },
|
|
19
20
|
})
|
|
20
21
|
|
|
22
|
+
const resolvedEndpoint = computed(() => props.table?.endpoint ?? props.endpoint)
|
|
23
|
+
const resolvedName = computed(() => props.table?.name ?? props.name)
|
|
24
|
+
|
|
21
25
|
const emit = defineEmits(['row-click', 'loaded'])
|
|
22
26
|
const slots = useSlots()
|
|
23
27
|
const forwardedSlots = computed(() => {
|
|
@@ -54,7 +58,7 @@ const containerRef = ref(null)
|
|
|
54
58
|
const previewEnabled = ref(false)
|
|
55
59
|
const paginationHeight = ref(0)
|
|
56
60
|
|
|
57
|
-
const previewCacheKey = computed(() => `table-preview-${
|
|
61
|
+
const previewCacheKey = computed(() => `table-preview-${resolvedName.value}`)
|
|
58
62
|
|
|
59
63
|
const previewFromCache = ref(false)
|
|
60
64
|
const closePreview = () => { previewRow.value = null }
|
|
@@ -114,7 +118,7 @@ const startResize = (e) => {
|
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
const onEsc = (e) => { if (e.key === 'Escape' && previewRow.value) closePreview() }
|
|
117
|
-
onMounted(() => {
|
|
121
|
+
onMounted(async () => {
|
|
118
122
|
previewEnabled.value = !!slots.preview
|
|
119
123
|
window.addEventListener('keydown', onEsc)
|
|
120
124
|
// Restore preview from session cache — mark as from-cache to skip enter animation
|
|
@@ -258,7 +262,7 @@ defineExpose({ getSelectedRows, reload, clearCache, exportTable, tableRef })
|
|
|
258
262
|
Columnas
|
|
259
263
|
</button>
|
|
260
264
|
|
|
261
|
-
<TableExportable v-if="showExport" :table-ref="tableRef" :name="
|
|
265
|
+
<TableExportable v-if="showExport" :table-ref="tableRef" :name="resolvedName" :columns="columns" />
|
|
262
266
|
</div>
|
|
263
267
|
|
|
264
268
|
<!-- Contenido: tabla siempre full width + preview overlay -->
|
|
@@ -267,9 +271,9 @@ defineExpose({ getSelectedRows, reload, clearCache, exportTable, tableRef })
|
|
|
267
271
|
<!-- Tabla -->
|
|
268
272
|
<Table
|
|
269
273
|
ref="tableRef"
|
|
270
|
-
:endpoint="
|
|
274
|
+
:endpoint="resolvedEndpoint"
|
|
271
275
|
:columns="columns"
|
|
272
|
-
:name="
|
|
276
|
+
:name="resolvedName"
|
|
273
277
|
:params="mergedParams"
|
|
274
278
|
:search="search"
|
|
275
279
|
:checkable="checkable"
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// composables/useTable.ts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type TableConfig = { name: string; endpoint: string } | string
|
|
4
|
+
|
|
5
|
+
export function useTable(tableOrName?: TableConfig) {
|
|
6
|
+
const resolvedName = typeof tableOrName === 'object' ? tableOrName?.name : tableOrName
|
|
7
|
+
|
|
4
8
|
const invalidateCache = (tableName: string) => {
|
|
5
9
|
if (!tableName) {
|
|
6
10
|
console.warn('[useTable] No table name provided');
|
|
@@ -72,7 +76,13 @@ export function useTable() {
|
|
|
72
76
|
return { filters, resetFilters };
|
|
73
77
|
};
|
|
74
78
|
|
|
79
|
+
const invalidate = () => {
|
|
80
|
+
if (resolvedName) invalidateCache(resolvedName)
|
|
81
|
+
else console.warn('[useTable] No table name to invalidate')
|
|
82
|
+
}
|
|
83
|
+
|
|
75
84
|
return {
|
|
85
|
+
invalidate,
|
|
76
86
|
invalidateCache,
|
|
77
87
|
invalidateMultiple,
|
|
78
88
|
clearAllCache,
|