Skip to content

Commit 71ece34

Browse files
committed
wip
1 parent 7aed80a commit 71ece34

File tree

9 files changed

+1190
-1009
lines changed

9 files changed

+1190
-1009
lines changed

demo-app/package-lock.json

Lines changed: 381 additions & 337 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

react/package-lock.json

Lines changed: 380 additions & 321 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"devDependencies": {
2828
"@headlessui/react": "^2.1.0",
2929
"@heroicons/react": "^2.1.4",
30-
"@inertiajs/react": "^1.3.0||^2.0.0",
30+
"@inertiajs/react": "^1.3.0||^2.1.11",
3131
"@vitejs/plugin-react": "^4.3.1",
3232
"axios": "^1.6.0",
3333
"clsx": "^2.1.1",
@@ -46,7 +46,7 @@
4646
"vite": "^6.1"
4747
},
4848
"peerDependencies": {
49-
"@inertiajs/react": "^1.3.0||^2.0.0",
49+
"@inertiajs/react": "^1.3.0||^2.1.11",
5050
"axios": "^1.6.0",
5151
"react": "^18.2.0||^19.0.0",
5252
"react-dom": "^18.2.0||^19.0.0"

react/src/ModalRoot.jsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createElement, useEffect, useState, useRef } from 'react'
22
import { default as Axios } from 'axios'
3-
import { except, kebabCase, generateId, sameUrlPath } from './helpers'
4-
import { router, usePage } from '@inertiajs/react'
3+
import { except, kebabCase, generateId, sameUrlPath, isInertiaV2 } from './helpers'
4+
import { router, usePage, progress } from '@inertiajs/react'
55
import { mergeDataIntoQueryString } from '@inertiajs/core'
66
import { createContext, useContext } from 'react'
77
import ModalRenderer from './ModalRenderer'
@@ -413,10 +413,12 @@ export const ModalStackProvider = ({ children }) => {
413413
})
414414
}
415415

416-
//
417-
418416
onStart?.()
419417

418+
if (isInertiaV2()) {
419+
progress.start()
420+
}
421+
420422
Axios({
421423
url,
422424
method,
@@ -431,6 +433,11 @@ export const ModalStackProvider = ({ children }) => {
431433
onError?.(...args)
432434
reject(...args)
433435
})
436+
.finally(() => {
437+
if (isInertiaV2()) {
438+
progress.finish()
439+
}
440+
})
434441
})
435442
}
436443

react/src/helpers.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
import { router } from '@inertiajs/react'
12
import { generateId, sameUrlPath, except, only, rejectNullValues, kebabCase, isStandardDomEvent } from './../../vue/src/helpers.js'
2-
export { generateId, sameUrlPath, except, only, rejectNullValues, kebabCase, isStandardDomEvent }
3+
4+
function isInertiaV2() {
5+
return router.push && typeof router.push === 'function'
6+
}
7+
8+
export { generateId, sameUrlPath, except, only, rejectNullValues, kebabCase, isStandardDomEvent, isInertiaV2 }

vue/package-lock.json

Lines changed: 389 additions & 338 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vue/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"test": "vitest"
2727
},
2828
"devDependencies": {
29-
"@inertiajs/vue3": "^1.3.0||^2.0.0",
29+
"@inertiajs/vue3": "^1.3.0||^2.1.11",
3030
"@vitejs/plugin-vue": "^5.2.0",
3131
"@vitest/coverage-v8": "^2.1.1",
3232
"@vitest/ui": "^2.1.1",
@@ -47,7 +47,7 @@
4747
"vue": "^3.4.x"
4848
},
4949
"peerDependencies": {
50-
"@inertiajs/vue3": "^1.3.0||^2.0.0",
50+
"@inertiajs/vue3": "^1.3.0||^2.1.11",
5151
"axios": "^1.6.0",
5252
"vue": "^3.4.x"
5353
},

vue/src/helpers.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { router } from '@inertiajs/vue3'
2+
13
let generateIdUsingCallback = null
24

35
function generateIdUsing(callback) {
@@ -131,4 +133,8 @@ function isStandardDomEvent(eventName) {
131133
return standardPatterns.some((pattern) => pattern.test(lowerEventName))
132134
}
133135

134-
export { generateIdUsing, sameUrlPath, generateId, except, only, rejectNullValues, kebabCase, isStandardDomEvent }
136+
function isInertiaV2() {
137+
return router.push && typeof router.push === 'function'
138+
}
139+
140+
export { generateIdUsing, sameUrlPath, generateId, except, only, rejectNullValues, kebabCase, isStandardDomEvent, isInertiaV2 }

vue/src/modalStack.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { computed, readonly, ref, markRaw, h, nextTick } from 'vue'
2-
import { generateId, except, kebabCase } from './helpers'
3-
import { router } from '@inertiajs/vue3'
4-
import { usePage } from '@inertiajs/vue3'
2+
import { generateId, except, kebabCase, isInertiaV2 } from './helpers'
3+
import { router, usePage, progress } from '@inertiajs/vue3'
54
import { mergeDataIntoQueryString } from '@inertiajs/core'
65
import { default as Axios } from 'axios'
76
import ModalRoot from './ModalRoot.vue'
@@ -346,6 +345,10 @@ function visit(
346345

347346
onStart?.()
348347

348+
if (isInertiaV2()) {
349+
progress.start()
350+
}
351+
349352
Axios({ url, method, data, headers })
350353
.then((response) => {
351354
onSuccess?.(response)
@@ -355,6 +358,11 @@ function visit(
355358
onError?.(...args)
356359
reject(...args)
357360
})
361+
.finally(() => {
362+
if (isInertiaV2()) {
363+
progress.finish()
364+
}
365+
})
358366
})
359367
}
360368

0 commit comments

Comments
 (0)