@inertiajs/react 2.3.10 → 2.3.11
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/dist/index.esm.js +24 -22
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +158 -156
- package/dist/index.js.map +4 -4
- package/package.json +8 -8
- package/types/react.d.ts +1 -0
- package/types/useForm.d.ts +1 -0
package/dist/index.esm.js
CHANGED
|
@@ -192,12 +192,21 @@ async function createInertiaApp({
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// src/Deferred.ts
|
|
195
|
-
import { useEffect as
|
|
195
|
+
import { useEffect as useEffect3, useMemo as useMemo2, useState as useState2 } from "react";
|
|
196
|
+
|
|
197
|
+
// src/usePage.ts
|
|
198
|
+
import React2 from "react";
|
|
199
|
+
|
|
200
|
+
// src/react.ts
|
|
201
|
+
import React, { useEffect as useEffect2, useLayoutEffect } from "react";
|
|
202
|
+
function useIsomorphicLayoutEffect(effect, deps) {
|
|
203
|
+
typeof window === "undefined" ? useEffect2(effect, deps) : useLayoutEffect(effect, deps);
|
|
204
|
+
}
|
|
205
|
+
var isReact19 = typeof React.use === "function";
|
|
196
206
|
|
|
197
207
|
// src/usePage.ts
|
|
198
|
-
import React from "react";
|
|
199
208
|
function usePage() {
|
|
200
|
-
const page =
|
|
209
|
+
const page = isReact19 ? React2.use(PageContext_default) : React2.useContext(PageContext_default);
|
|
201
210
|
if (!page) {
|
|
202
211
|
throw new Error("usePage must be used within the Inertia component");
|
|
203
212
|
}
|
|
@@ -220,7 +229,7 @@ var Deferred = ({ children, data, fallback }) => {
|
|
|
220
229
|
const [loaded, setLoaded] = useState2(false);
|
|
221
230
|
const pageProps = usePage().props;
|
|
222
231
|
const keys = useMemo2(() => Array.isArray(data) ? data : [data], [data]);
|
|
223
|
-
|
|
232
|
+
useEffect3(() => {
|
|
224
233
|
const removeListener = router3.on("start", (e) => {
|
|
225
234
|
const isPartialVisit = e.detail.visit.only.length > 0 || e.detail.visit.except.length > 0;
|
|
226
235
|
const isReloadingKey = e.detail.visit.only.find((key) => keys.includes(key));
|
|
@@ -232,7 +241,7 @@ var Deferred = ({ children, data, fallback }) => {
|
|
|
232
241
|
removeListener();
|
|
233
242
|
};
|
|
234
243
|
}, []);
|
|
235
|
-
|
|
244
|
+
useEffect3(() => {
|
|
236
245
|
setLoaded(keys.every((key) => pageProps[key] !== void 0));
|
|
237
246
|
}, [pageProps, keys]);
|
|
238
247
|
if (loaded) {
|
|
@@ -253,7 +262,7 @@ import {
|
|
|
253
262
|
UseFormUtils as UseFormUtils2
|
|
254
263
|
} from "@inertiajs/core";
|
|
255
264
|
import { isEqual as isEqual2 } from "lodash-es";
|
|
256
|
-
import
|
|
265
|
+
import React3, {
|
|
257
266
|
createContext as createContext3,
|
|
258
267
|
createElement as createElement3,
|
|
259
268
|
forwardRef,
|
|
@@ -278,12 +287,6 @@ import {
|
|
|
278
287
|
import { cloneDeep, get, has, isEqual, set } from "lodash-es";
|
|
279
288
|
import { useCallback, useEffect as useEffect5, useMemo as useMemo3, useRef, useState as useState4 } from "react";
|
|
280
289
|
|
|
281
|
-
// src/react.ts
|
|
282
|
-
import { useEffect as useEffect3, useLayoutEffect } from "react";
|
|
283
|
-
function useIsomorphicLayoutEffect(effect, deps) {
|
|
284
|
-
typeof window === "undefined" ? useEffect3(effect, deps) : useLayoutEffect(effect, deps);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
290
|
// src/useRemember.ts
|
|
288
291
|
import { router as router4 } from "@inertiajs/core";
|
|
289
292
|
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
@@ -668,7 +671,7 @@ function useForm(...args) {
|
|
|
668
671
|
|
|
669
672
|
// src/Form.ts
|
|
670
673
|
var deferStateUpdate = (callback) => {
|
|
671
|
-
typeof
|
|
674
|
+
typeof React3.startTransition === "function" ? React3.startTransition(callback) : setTimeout(callback, 0);
|
|
672
675
|
};
|
|
673
676
|
var noop = () => void 0;
|
|
674
677
|
var FormContext = createContext3(void 0);
|
|
@@ -860,11 +863,10 @@ var Form = forwardRef(
|
|
|
860
863
|
event.preventDefault();
|
|
861
864
|
submit(event.nativeEvent.submitter);
|
|
862
865
|
},
|
|
863
|
-
//
|
|
864
|
-
//
|
|
865
|
-
// Unfortunately, React 19 treats an empty string as `false`.
|
|
866
|
+
// React 19 supports passing a boolean to the `inert` attribute, but shows
|
|
867
|
+
// a warning when receiving a string. Earlier versions require the string 'true'.
|
|
866
868
|
// See: https://github.com/inertiajs/inertia/pull/2536
|
|
867
|
-
inert: disableWhileProcessing && form.processing && "true"
|
|
869
|
+
inert: disableWhileProcessing && form.processing && (isReact19 ? true : "true")
|
|
868
870
|
},
|
|
869
871
|
typeof children === "function" ? children(exposed) : children
|
|
870
872
|
);
|
|
@@ -879,7 +881,7 @@ var Form_default = Form;
|
|
|
879
881
|
|
|
880
882
|
// src/Head.ts
|
|
881
883
|
import { escape } from "lodash-es";
|
|
882
|
-
import
|
|
884
|
+
import React4, { useContext as useContext2, useEffect as useEffect7, useMemo as useMemo5 } from "react";
|
|
883
885
|
var Head = function({ children, title }) {
|
|
884
886
|
const headManager = useContext2(HeadContext_default);
|
|
885
887
|
const provider = useMemo5(() => headManager.createProvider(), [headManager]);
|
|
@@ -947,7 +949,7 @@ var Head = function({ children, title }) {
|
|
|
947
949
|
return html;
|
|
948
950
|
}
|
|
949
951
|
function ensureNodeHasInertiaProp(node) {
|
|
950
|
-
return
|
|
952
|
+
return React4.cloneElement(node, {
|
|
951
953
|
[provider.preferredAttribute()]: node.props["head-key"] !== void 0 ? node.props["head-key"] : ""
|
|
952
954
|
});
|
|
953
955
|
}
|
|
@@ -955,7 +957,7 @@ var Head = function({ children, title }) {
|
|
|
955
957
|
return renderTag(ensureNodeHasInertiaProp(node));
|
|
956
958
|
}
|
|
957
959
|
function renderNodes(nodes) {
|
|
958
|
-
const elements =
|
|
960
|
+
const elements = React4.Children.toArray(nodes).filter((node) => node).map((node) => renderNode(node));
|
|
959
961
|
if (title && !elements.find((tag) => tag.startsWith("<title"))) {
|
|
960
962
|
elements.push(`<title ${provider.preferredAttribute()}>${title}</title>`);
|
|
961
963
|
}
|
|
@@ -973,7 +975,7 @@ import {
|
|
|
973
975
|
getScrollableParent,
|
|
974
976
|
useInfiniteScroll
|
|
975
977
|
} from "@inertiajs/core";
|
|
976
|
-
import
|
|
978
|
+
import React5, {
|
|
977
979
|
createElement as createElement4,
|
|
978
980
|
forwardRef as forwardRef2,
|
|
979
981
|
useCallback as useCallback2,
|
|
@@ -1212,7 +1214,7 @@ var InfiniteScroll = forwardRef2(
|
|
|
1212
1214
|
)
|
|
1213
1215
|
);
|
|
1214
1216
|
}
|
|
1215
|
-
return createElement4(
|
|
1217
|
+
return createElement4(React5.Fragment, {}, ...reverse ? [...renderElements].reverse() : renderElements);
|
|
1216
1218
|
}
|
|
1217
1219
|
);
|
|
1218
1220
|
InfiniteScroll.displayName = "InertiaInfiniteScroll";
|