@innertia-solutions/nuxt-theme-spark 0.1.92 → 0.1.94

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
- endpoint: { type: String, required: true },
5
+ table: { type: Object, default: null },
6
+ endpoint: { type: String, default: '' },
6
7
  columns: { type: Array, required: true },
7
- name: { type: String, required: true },
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-${props.name}`)
61
+ const previewCacheKey = computed(() => `table-preview-${resolvedName.value}`)
58
62
 
59
63
  const previewFromCache = ref(false)
60
64
  const closePreview = () => { previewRow.value = null }
@@ -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="name" :columns="columns" />
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="endpoint"
274
+ :endpoint="resolvedEndpoint"
271
275
  :columns="columns"
272
- :name="name"
276
+ :name="resolvedName"
273
277
  :params="mergedParams"
274
278
  :search="search"
275
279
  :checkable="checkable"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innertia-solutions/nuxt-theme-spark",
3
- "version": "0.1.92",
3
+ "version": "0.1.94",
4
4
  "description": "Innertia Solutions — Spark theme: backoffice, landing and mobile components and layouts",
5
5
  "keywords": [
6
6
  "nuxt",
@@ -1,6 +1,10 @@
1
1
  // composables/useTable.ts
2
2
 
3
- export function useTable() {
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,