@inertiajs/svelte
Advanced tools
@@ -194,2 +194,5 @@ <script>import { | ||
| } | ||
| if (withAllErrors ?? config.get("form.withAllErrors")) { | ||
| form.withAllErrors(); | ||
| } | ||
| } | ||
@@ -196,0 +199,0 @@ $: slotErrors = $form.errors; |
@@ -6,2 +6,4 @@ <script>import { | ||
| import { onDestroy, onMount } from "svelte"; | ||
| import { usePage } from "../page"; | ||
| const page = usePage(); | ||
| export let data; | ||
@@ -26,4 +28,5 @@ export let buffer = 0; | ||
| let requestCount = 0; | ||
| let hasPreviousPage = false; | ||
| let hasNextPage = false; | ||
| const scrollProp = $page.scrollProps?.[data]; | ||
| let hasPreviousPage = !!scrollProp?.previousPage; | ||
| let hasNextPage = !!scrollProp?.nextPage; | ||
| $: resolvedItemsElement = resolveHTMLElement(itemsElement, itemsElementRef); | ||
@@ -30,0 +33,0 @@ $: scrollableParent = resolvedItemsElement ? getScrollableParent(resolvedItemsElement) : null; |
+3
-3
| { | ||
| "name": "@inertiajs/svelte", | ||
| "version": "2.3.18", | ||
| "version": "2.3.21", | ||
| "license": "MIT", | ||
@@ -58,4 +58,4 @@ "description": "The Svelte adapter for Inertia.js", | ||
| "laravel-precognition": "^1.0.2", | ||
| "lodash-es": "^4.17.23", | ||
| "@inertiajs/core": "2.3.18" | ||
| "lodash-es": "^4.18.1", | ||
| "@inertiajs/core": "2.3.21" | ||
| }, | ||
@@ -62,0 +62,0 @@ "scripts": { |
@@ -306,21 +306,36 @@ --- | ||
| Automatically refresh data at intervals: | ||
| Use the `usePoll` hook to automatically refresh data at intervals. It handles cleanup on unmount and throttles polling when the tab is inactive. | ||
| @boostsnippet("Polling Example", "svelte") | ||
| @boostsnippet("Basic Polling", "svelte") | ||
| <script> | ||
| import { router } from '@inertiajs/svelte' | ||
| import { onMount, onDestroy } from 'svelte' | ||
| import { usePoll } from '@inertiajs/svelte' | ||
| export let stats | ||
| let interval | ||
| usePoll(5000) | ||
| </script> | ||
| onMount(() => { | ||
| interval = setInterval(() => { | ||
| router.reload({ only: ['stats'] }) | ||
| }, 5000) // Poll every 5 seconds | ||
| }) | ||
| <div> | ||
| <h1>Dashboard</h1> | ||
| <div>Active Users: {stats.activeUsers}</div> | ||
| </div> | ||
| @endboostsnippet | ||
| onDestroy(() => { | ||
| clearInterval(interval) | ||
| @boostsnippet("Polling With Request Options and Manual Control", "svelte") | ||
| <script> | ||
| import { usePoll } from '@inertiajs/svelte' | ||
| export let stats | ||
| const { start, stop } = usePoll(5000, { | ||
| only: ['stats'], | ||
| onStart() { | ||
| console.log('Polling request started') | ||
| }, | ||
| onFinish() { | ||
| console.log('Polling request finished') | ||
| }, | ||
| }, { | ||
| autoStart: false, | ||
| keepAlive: true, | ||
| }) | ||
@@ -332,5 +347,10 @@ </script> | ||
| <div>Active Users: {stats.activeUsers}</div> | ||
| <button on:click={start}>Start Polling</button> | ||
| <button on:click={stop}>Stop Polling</button> | ||
| </div> | ||
| @endboostsnippet | ||
| - `autoStart` (default `true`) — set to `false` to start polling manually via the returned `start()` function | ||
| - `keepAlive` (default `false`) — set to `true` to prevent throttling when the browser tab is inactive | ||
| ### WhenVisible | ||
@@ -350,3 +370,2 @@ | ||
| <!-- stats prop is loaded only when this section scrolls into view --> | ||
| <WhenVisible data="stats" buffer={200}> | ||
@@ -365,2 +384,22 @@ <div> | ||
| ### InfiniteScroll | ||
| Automatically load additional pages of paginated data as users scroll: | ||
| @boostsnippet("InfiniteScroll Example", "svelte") | ||
| <script> | ||
| import { InfiniteScroll } from '@inertiajs/svelte' | ||
| export let users | ||
| </script> | ||
| <InfiniteScroll data="users"> | ||
| {#each users.data as user (user.id)} | ||
| <div>{user.name}</div> | ||
| {/each} | ||
| </InfiniteScroll> | ||
| @endboostsnippet | ||
| The server must use `Inertia::scroll()` to configure the paginated data. Use the `search-docs` tool with a query of `infinite scroll` for detailed guidance on buffers, manual loading, reverse mode, and custom trigger elements. | ||
| ## Server-Side Patterns | ||
@@ -367,0 +406,0 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
89598
1.67%+ Added
- Removed
Updated
Updated