inertiax-svelte 2.3.2 → 2.4.0
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 +1 -1
- package/src/Frame.svelte +1 -0
- package/src/createInertiaApp.js +1 -1
- package/src/useForm.js +10 -3
package/package.json
CHANGED
package/src/Frame.svelte
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
const {children, src, hint, component, id = Math.random(), ...restProps} = $props()
|
|
8
8
|
|
|
9
9
|
setContext('inertia:frame-id', id)
|
|
10
|
+
|
|
10
11
|
const components = $derived($store.frames?.[id] && h($store.frames[id].component.default, Object.assign({}, restProps, $store.frames[id].props)))
|
|
11
12
|
|
|
12
13
|
onMount(() => {
|
package/src/createInertiaApp.js
CHANGED
|
@@ -35,7 +35,7 @@ export default async function createInertiaApp({ id = 'app', resolve, setup, pro
|
|
|
35
35
|
const targetFrame = page.target
|
|
36
36
|
if (targetFrame) store.update((current) => ({
|
|
37
37
|
...current,
|
|
38
|
-
frames: { ...current.frames, [targetFrame]: {component, props: page.props} }
|
|
38
|
+
frames: { ...current.frames, [targetFrame]: {component, props: page.props, page} }
|
|
39
39
|
}))
|
|
40
40
|
else store.update((current) => ({
|
|
41
41
|
component,
|
package/src/useForm.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { router } from 'inertiax-core'
|
|
2
2
|
import isEqual from 'lodash.isequal'
|
|
3
3
|
import cloneDeep from 'lodash.clonedeep'
|
|
4
|
-
import { writable } from 'svelte/store'
|
|
4
|
+
import { get, writable } from 'svelte/store'
|
|
5
5
|
import { getContext } from 'svelte'
|
|
6
|
+
import inertiaStore from './store'
|
|
6
7
|
|
|
7
8
|
function useForm(...args) {
|
|
8
9
|
const rememberKey = typeof args[0] === 'string' ? args[0] : null
|
|
9
10
|
const data = (typeof args[0] === 'string' ? args[1] : args[0]) || {}
|
|
10
11
|
const restored = rememberKey ? router.restore(rememberKey) : null
|
|
11
12
|
const frameId = getContext('inertia:frame-id')
|
|
12
|
-
|
|
13
|
+
|
|
14
|
+
const frameSrc = frameId && get(inertiaStore).frames[frameId].page.url
|
|
15
|
+
console.log(frameSrc)
|
|
16
|
+
|
|
13
17
|
let defaults = cloneDeep(data)
|
|
14
18
|
let cancelToken = null
|
|
15
19
|
let recentlySuccessfulTimeoutId = null
|
|
@@ -95,6 +99,9 @@ function useForm(...args) {
|
|
|
95
99
|
|
|
96
100
|
const _options = {
|
|
97
101
|
...options,
|
|
102
|
+
headers: {
|
|
103
|
+
'X-Inertia-Frame-Src': frameSrc,
|
|
104
|
+
},
|
|
98
105
|
target: typeof(options.target) !== 'undefined' ? options.target : frameId,
|
|
99
106
|
onCancelToken: (token) => {
|
|
100
107
|
cancelToken = token
|
|
@@ -107,7 +114,7 @@ function useForm(...args) {
|
|
|
107
114
|
this.setStore('wasSuccessful', false)
|
|
108
115
|
this.setStore('recentlySuccessful', false)
|
|
109
116
|
clearTimeout(recentlySuccessfulTimeoutId)
|
|
110
|
-
|
|
117
|
+
|
|
111
118
|
if (options.onBefore) {
|
|
112
119
|
return options.onBefore(visit)
|
|
113
120
|
}
|