@inertiajs/react 2.3.9 → 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 +33 -25
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +166 -159
- 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) {
|
|
@@ -245,6 +254,7 @@ var Deferred_default = Deferred;
|
|
|
245
254
|
|
|
246
255
|
// src/Form.ts
|
|
247
256
|
import {
|
|
257
|
+
FormComponentResetSymbol,
|
|
248
258
|
formDataToObject,
|
|
249
259
|
isUrlMethodPair,
|
|
250
260
|
mergeDataIntoQueryString,
|
|
@@ -252,7 +262,7 @@ import {
|
|
|
252
262
|
UseFormUtils as UseFormUtils2
|
|
253
263
|
} from "@inertiajs/core";
|
|
254
264
|
import { isEqual as isEqual2 } from "lodash-es";
|
|
255
|
-
import
|
|
265
|
+
import React3, {
|
|
256
266
|
createContext as createContext3,
|
|
257
267
|
createElement as createElement3,
|
|
258
268
|
forwardRef,
|
|
@@ -277,12 +287,6 @@ import {
|
|
|
277
287
|
import { cloneDeep, get, has, isEqual, set } from "lodash-es";
|
|
278
288
|
import { useCallback, useEffect as useEffect5, useMemo as useMemo3, useRef, useState as useState4 } from "react";
|
|
279
289
|
|
|
280
|
-
// src/react.ts
|
|
281
|
-
import { useEffect as useEffect3, useLayoutEffect } from "react";
|
|
282
|
-
function useIsomorphicLayoutEffect(effect, deps) {
|
|
283
|
-
typeof window === "undefined" ? useEffect3(effect, deps) : useLayoutEffect(effect, deps);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
290
|
// src/useRemember.ts
|
|
287
291
|
import { router as router4 } from "@inertiajs/core";
|
|
288
292
|
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
@@ -667,7 +671,7 @@ function useForm(...args) {
|
|
|
667
671
|
|
|
668
672
|
// src/Form.ts
|
|
669
673
|
var deferStateUpdate = (callback) => {
|
|
670
|
-
typeof
|
|
674
|
+
typeof React3.startTransition === "function" ? React3.startTransition(callback) : setTimeout(callback, 0);
|
|
671
675
|
};
|
|
672
676
|
var noop = () => void 0;
|
|
673
677
|
var FormContext = createContext3(void 0);
|
|
@@ -732,9 +736,14 @@ var Form = forwardRef(
|
|
|
732
736
|
queryStringArrayFormat
|
|
733
737
|
);
|
|
734
738
|
};
|
|
735
|
-
const updateDirtyState = (event) =>
|
|
736
|
-
|
|
737
|
-
|
|
739
|
+
const updateDirtyState = (event) => {
|
|
740
|
+
if (event.type === "reset" && event.detail?.[FormComponentResetSymbol]) {
|
|
741
|
+
event.preventDefault();
|
|
742
|
+
}
|
|
743
|
+
deferStateUpdate(
|
|
744
|
+
() => setIsDirty(event.type === "reset" ? false : !isEqual2(getData(), formDataToObject(defaultData.current)))
|
|
745
|
+
);
|
|
746
|
+
};
|
|
738
747
|
const clearErrors = (...names) => {
|
|
739
748
|
form.clearErrors(...names);
|
|
740
749
|
return form;
|
|
@@ -854,11 +863,10 @@ var Form = forwardRef(
|
|
|
854
863
|
event.preventDefault();
|
|
855
864
|
submit(event.nativeEvent.submitter);
|
|
856
865
|
},
|
|
857
|
-
//
|
|
858
|
-
//
|
|
859
|
-
// 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'.
|
|
860
868
|
// See: https://github.com/inertiajs/inertia/pull/2536
|
|
861
|
-
inert: disableWhileProcessing && form.processing && "true"
|
|
869
|
+
inert: disableWhileProcessing && form.processing && (isReact19 ? true : "true")
|
|
862
870
|
},
|
|
863
871
|
typeof children === "function" ? children(exposed) : children
|
|
864
872
|
);
|
|
@@ -873,7 +881,7 @@ var Form_default = Form;
|
|
|
873
881
|
|
|
874
882
|
// src/Head.ts
|
|
875
883
|
import { escape } from "lodash-es";
|
|
876
|
-
import
|
|
884
|
+
import React4, { useContext as useContext2, useEffect as useEffect7, useMemo as useMemo5 } from "react";
|
|
877
885
|
var Head = function({ children, title }) {
|
|
878
886
|
const headManager = useContext2(HeadContext_default);
|
|
879
887
|
const provider = useMemo5(() => headManager.createProvider(), [headManager]);
|
|
@@ -941,7 +949,7 @@ var Head = function({ children, title }) {
|
|
|
941
949
|
return html;
|
|
942
950
|
}
|
|
943
951
|
function ensureNodeHasInertiaProp(node) {
|
|
944
|
-
return
|
|
952
|
+
return React4.cloneElement(node, {
|
|
945
953
|
[provider.preferredAttribute()]: node.props["head-key"] !== void 0 ? node.props["head-key"] : ""
|
|
946
954
|
});
|
|
947
955
|
}
|
|
@@ -949,7 +957,7 @@ var Head = function({ children, title }) {
|
|
|
949
957
|
return renderTag(ensureNodeHasInertiaProp(node));
|
|
950
958
|
}
|
|
951
959
|
function renderNodes(nodes) {
|
|
952
|
-
const elements =
|
|
960
|
+
const elements = React4.Children.toArray(nodes).filter((node) => node).map((node) => renderNode(node));
|
|
953
961
|
if (title && !elements.find((tag) => tag.startsWith("<title"))) {
|
|
954
962
|
elements.push(`<title ${provider.preferredAttribute()}>${title}</title>`);
|
|
955
963
|
}
|
|
@@ -967,7 +975,7 @@ import {
|
|
|
967
975
|
getScrollableParent,
|
|
968
976
|
useInfiniteScroll
|
|
969
977
|
} from "@inertiajs/core";
|
|
970
|
-
import
|
|
978
|
+
import React5, {
|
|
971
979
|
createElement as createElement4,
|
|
972
980
|
forwardRef as forwardRef2,
|
|
973
981
|
useCallback as useCallback2,
|
|
@@ -1206,7 +1214,7 @@ var InfiniteScroll = forwardRef2(
|
|
|
1206
1214
|
)
|
|
1207
1215
|
);
|
|
1208
1216
|
}
|
|
1209
|
-
return createElement4(
|
|
1217
|
+
return createElement4(React5.Fragment, {}, ...reverse ? [...renderElements].reverse() : renderElements);
|
|
1210
1218
|
}
|
|
1211
1219
|
);
|
|
1212
1220
|
InfiniteScroll.displayName = "InertiaInfiniteScroll";
|