@kikiloaw/simple-table 1.1.17 → 1.1.19

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kikiloaw/simple-table",
3
- "version": "1.1.17",
3
+ "version": "1.1.19",
4
4
  "description": "A lightweight, dependency-light DataTable component for Vue 3 with Tailwind CSS",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -194,13 +194,18 @@ function getCacheKey(): string {
194
194
  })
195
195
  }
196
196
 
197
- function clearCache(scope: 'all' | 'current' = 'all') {
197
+ async function clearCache(scope: 'all' | 'current' = 'all') {
198
198
  if (scope === 'current') {
199
199
  const key = getCacheKey()
200
200
  responseCache.value.delete(key)
201
201
  } else {
202
202
  responseCache.value.clear()
203
203
  }
204
+
205
+ // User requested behavior: clearCache triggers fresh fetch
206
+ if (props.fetchUrl) {
207
+ await fetchData()
208
+ }
204
209
  }
205
210
 
206
211
  // Internal data state to handle both props updates and ajax updates
@@ -726,9 +731,20 @@ function handlePageChange(page: number) {
726
731
  emit('page-change', page)
727
732
  }
728
733
 
729
- async function refresh() {
734
+
735
+ // Reload (Reset): Go to page 1, clear cache, and refetch
736
+ async function reload() {
730
737
  currentPage.value = 1
731
738
  await nextTick()
739
+
740
+ // Clear cache for fresh start
741
+ if (props.enableCache) {
742
+ clearCache('current')
743
+ // Note: clearCache calls fetchData(), so we don't need to call it again explicitly here
744
+ // However, clearCache is async now.
745
+ return // clearCache already fetched
746
+ }
747
+
732
748
  fetchData()
733
749
  }
734
750
 
@@ -739,9 +755,9 @@ onMounted(() => {
739
755
  })
740
756
 
741
757
  defineExpose({
742
- refresh,
758
+ reload, // The new "Reset" function
743
759
  fetchData,
744
- clearCache
760
+ clearCache // The "Reload current page" function (effectively)
745
761
  })
746
762
 
747
763