@inertiajs/react 3.0.0-beta.2 → 3.0.0-beta.4

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.js CHANGED
@@ -8,7 +8,14 @@ import {
8
8
  normalizeLayouts,
9
9
  router
10
10
  } from "@inertiajs/core";
11
- import { createElement, useEffect, useMemo as useMemo2, useState } from "react";
11
+ import {
12
+ createElement,
13
+ isValidElement,
14
+ useEffect,
15
+ useMemo,
16
+ useState,
17
+ useSyncExternalStore
18
+ } from "react";
12
19
  import { flushSync } from "react-dom";
13
20
 
14
21
  // src/HeadContext.ts
@@ -18,8 +25,7 @@ headContext.displayName = "InertiaHeadContext";
18
25
  var HeadContext_default = headContext;
19
26
 
20
27
  // src/layoutProps.ts
21
- import { createLayoutPropsStore, mergeLayoutProps } from "@inertiajs/core";
22
- import { createContext as createContext2, useContext, useMemo, useSyncExternalStore } from "react";
28
+ import { createLayoutPropsStore } from "@inertiajs/core";
23
29
  var store = createLayoutPropsStore();
24
30
  function setLayoutProps(props) {
25
31
  store.set(props);
@@ -30,21 +36,10 @@ function setLayoutPropsFor(name, props) {
30
36
  function resetLayoutProps() {
31
37
  store.reset();
32
38
  }
33
- var LayoutPropsContext = createContext2({
34
- staticProps: {}
35
- });
36
- function useLayoutProps(defaults) {
37
- const { staticProps, name } = useContext(LayoutPropsContext);
38
- const { shared, named } = useSyncExternalStore(store.subscribe, store.get, store.get);
39
- return useMemo(() => {
40
- const dynamicProps = name ? { ...shared, ...named[name] } : shared;
41
- return mergeLayoutProps(defaults, staticProps, dynamicProps);
42
- }, [defaults, staticProps, name, shared, named]);
43
- }
44
39
 
45
40
  // src/PageContext.ts
46
- import { createContext as createContext3 } from "react";
47
- var pageContext = createContext3(null);
41
+ import { createContext as createContext2 } from "react";
42
+ var pageContext = createContext2(null);
48
43
  pageContext.displayName = "InertiaPageContext";
49
44
  var PageContext_default = pageContext;
50
45
 
@@ -74,6 +69,10 @@ var routerIsInitialized = false;
74
69
  var swapComponent = async () => {
75
70
  currentIsInitialPage = false;
76
71
  };
72
+ var emptySnapshot = {
73
+ shared: {},
74
+ named: {}
75
+ };
77
76
  function App({
78
77
  children,
79
78
  initialPage,
@@ -88,7 +87,7 @@ function App({
88
87
  page: { ...initialPage, flash: initialPage.flash ?? {} },
89
88
  key: null
90
89
  });
91
- const headManager = useMemo2(() => {
90
+ const headManager = useMemo(() => {
92
91
  return createHeadManager(
93
92
  typeof window === "undefined",
94
93
  titleCallback || ((title) => title),
@@ -96,6 +95,7 @@ function App({
96
95
  })
97
96
  );
98
97
  }, []);
98
+ const dynamicLayoutProps = useSyncExternalStore(store.subscribe, store.get, () => emptySnapshot);
99
99
  if (!routerIsInitialized) {
100
100
  router.init({
101
101
  initialPage,
@@ -139,16 +139,40 @@ function App({
139
139
  const renderChildren = children || (({ Component, props, key }) => {
140
140
  const child = createElement(Component, { key, ...props });
141
141
  if (Component.layout && isRenderFunction(Component.layout)) {
142
- return Component.layout(child);
142
+ const result = Component.layout(props);
143
+ if (isValidElement(result)) {
144
+ return Component.layout(child);
145
+ }
146
+ const layouts2 = normalizeLayouts(result, isComponent);
147
+ if (layouts2.length > 0) {
148
+ return layouts2.reduceRight((childNode, layout) => {
149
+ return createElement(
150
+ layout.component,
151
+ {
152
+ ...props,
153
+ ...layout.props,
154
+ ...dynamicLayoutProps.shared,
155
+ ...layout.name ? dynamicLayoutProps.named[layout.name] || {} : {}
156
+ },
157
+ childNode
158
+ );
159
+ }, child);
160
+ }
161
+ return child;
143
162
  }
144
163
  const effectiveLayout = Component.layout ?? defaultLayout?.(current.page.component, current.page);
145
164
  const layouts = normalizeLayouts(effectiveLayout, isComponent, Component.layout ? isRenderFunction : void 0);
146
165
  if (layouts.length > 0) {
147
166
  return layouts.reduceRight((childNode, layout) => {
148
167
  return createElement(
149
- LayoutPropsContext.Provider,
150
- { value: { staticProps: { ...props, ...layout.props }, name: layout.name } },
151
- createElement(layout.component, { ...props, ...layout.props }, childNode)
168
+ layout.component,
169
+ {
170
+ ...props,
171
+ ...layout.props,
172
+ ...dynamicLayoutProps.shared,
173
+ ...layout.name ? dynamicLayoutProps.named[layout.name] || {} : {}
174
+ },
175
+ childNode
152
176
  );
153
177
  }, child);
154
178
  }
@@ -191,7 +215,8 @@ async function createInertiaApp({
191
215
  defaults = {},
192
216
  http: http3,
193
217
  layout,
194
- strictMode = false
218
+ strictMode = false,
219
+ withApp
195
220
  } = {}) {
196
221
  config.replace(defaults);
197
222
  if (http3) {
@@ -225,6 +250,9 @@ async function createInertiaApp({
225
250
  });
226
251
  } else {
227
252
  reactApp2 = wrapWithStrictMode(createElement2(App, props));
253
+ if (withApp) {
254
+ reactApp2 = withApp(reactApp2, { ssr: true });
255
+ }
228
256
  }
229
257
  const html = renderToString(reactApp2);
230
258
  const body = buildSSRBody(id, page2, html);
@@ -261,7 +289,10 @@ async function createInertiaApp({
261
289
  props
262
290
  });
263
291
  }
264
- const appElement = wrapWithStrictMode(createElement2(App, props));
292
+ let appElement = wrapWithStrictMode(createElement2(App, props));
293
+ if (withApp) {
294
+ appElement = withApp(appElement, { ssr: false });
295
+ }
265
296
  if (el.hasAttribute("data-server-rendered")) {
266
297
  hydrateRoot(el, appElement);
267
298
  } else {
@@ -280,8 +311,8 @@ async function createInertiaApp({
280
311
 
281
312
  // src/Deferred.ts
282
313
  import { isSameUrlWithoutQueryOrHash } from "@inertiajs/core";
283
- import { get } from "lodash-es";
284
- import { useEffect as useEffect2, useMemo as useMemo3, useRef, useState as useState2 } from "react";
314
+ import { get } from "es-toolkit/compat";
315
+ import { useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
285
316
 
286
317
  // src/usePage.ts
287
318
  import { use } from "react";
@@ -311,7 +342,7 @@ var Deferred = ({ children, data, fallback }) => {
311
342
  const [reloading, setReloading] = useState2(false);
312
343
  const activeReloads = useRef(/* @__PURE__ */ new Set());
313
344
  const pageProps = usePage().props;
314
- const keys = useMemo3(() => Array.isArray(data) ? data : [data], [data]);
345
+ const keys = useMemo2(() => Array.isArray(data) ? data : [data], [data]);
315
346
  useEffect2(() => {
316
347
  const removeStartListener = router3.on("start", (e) => {
317
348
  const visit = e.detail.visit;
@@ -336,7 +367,7 @@ var Deferred = ({ children, data, fallback }) => {
336
367
  useEffect2(() => {
337
368
  setLoaded(keys.every((key) => get(pageProps, key) !== void 0));
338
369
  }, [pageProps, keys]);
339
- const propsAreDefined = useMemo3(() => keys.every((key) => get(pageProps, key) !== void 0), [keys, pageProps]);
370
+ const propsAreDefined = useMemo2(() => keys.every((key) => get(pageProps, key) !== void 0), [keys, pageProps]);
340
371
  if (loaded && propsAreDefined) {
341
372
  if (typeof children === "function") {
342
373
  return children({ reloading });
@@ -359,15 +390,15 @@ import {
359
390
  resolveUrlMethodPairComponent,
360
391
  UseFormUtils as UseFormUtils3
361
392
  } from "@inertiajs/core";
362
- import { isEqual as isEqual2 } from "lodash-es";
393
+ import { isEqual as isEqual2 } from "es-toolkit";
363
394
  import React, {
364
- createContext as createContext4,
395
+ createContext as createContext3,
365
396
  createElement as createElement3,
366
397
  forwardRef,
367
398
  use as use2,
368
399
  useEffect as useEffect6,
369
400
  useImperativeHandle,
370
- useMemo as useMemo5,
401
+ useMemo as useMemo4,
371
402
  useRef as useRef4,
372
403
  useState as useState6
373
404
  } from "react";
@@ -377,7 +408,7 @@ import {
377
408
  router as router5,
378
409
  UseFormUtils as UseFormUtils2
379
410
  } from "@inertiajs/core";
380
- import { cloneDeep as cloneDeep2 } from "lodash-es";
411
+ import { cloneDeep as cloneDeep2 } from "es-toolkit";
381
412
  import { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
382
413
 
383
414
  // src/react.ts
@@ -390,13 +421,14 @@ function useIsomorphicLayoutEffect(effect, deps) {
390
421
  import {
391
422
  UseFormUtils
392
423
  } from "@inertiajs/core";
424
+ import { cloneDeep, isEqual } from "es-toolkit";
425
+ import { get as get2, has, set } from "es-toolkit/compat";
393
426
  import {
394
427
  createValidator,
395
428
  resolveName,
396
429
  toSimpleValidationErrors
397
430
  } from "laravel-precognition";
398
- import { cloneDeep, get as get2, has, isEqual, set } from "lodash-es";
399
- import { useCallback, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef2, useState as useState3 } from "react";
431
+ import { useCallback, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef2, useState as useState3 } from "react";
400
432
  function useFormState(options) {
401
433
  const { data: dataOption, useDataState, useErrorsState } = options;
402
434
  const isDataFunction = typeof dataOption === "function";
@@ -407,14 +439,12 @@ function useFormState(options) {
407
439
  const [defaults, setDefaultsState] = useState3(cloneDeep(initialData));
408
440
  const [data, setData] = useDataState ? useDataState() : useState3(cloneDeep(initialData));
409
441
  const [errors, setErrors] = useErrorsState ? useErrorsState() : useState3({});
410
- const [hasErrors, setHasErrors] = useState3(false);
411
- const [processing, setProcessing] = useState3(false);
412
- const [progress2, setProgress] = useState3(null);
442
+ const [processing, _setProcessing] = useState3(false);
443
+ const [progress2, _setProgress] = useState3(null);
413
444
  const [wasSuccessful, setWasSuccessful] = useState3(false);
414
445
  const [recentlySuccessful, setRecentlySuccessful] = useState3(false);
415
446
  const recentlySuccessfulTimeoutId = useRef2(void 0);
416
447
  const transformRef = useRef2((data2) => data2);
417
- const isDirty = useMemo4(() => !isEqual(data, defaults), [data, defaults]);
418
448
  const defaultsCalledInOnSuccessRef = useRef2(false);
419
449
  const validatorRef = useRef2(null);
420
450
  const [validating, setValidating] = useState3(false);
@@ -432,6 +462,38 @@ function useFormState(options) {
432
462
  isMounted.current = false;
433
463
  };
434
464
  }, []);
465
+ const snapshotRef = useRef2({
466
+ data,
467
+ defaults,
468
+ errors,
469
+ processing,
470
+ progress: progress2,
471
+ wasSuccessful,
472
+ recentlySuccessful,
473
+ validating,
474
+ touchedFields,
475
+ validFields
476
+ });
477
+ snapshotRef.current = {
478
+ data,
479
+ defaults,
480
+ errors,
481
+ processing,
482
+ progress: progress2,
483
+ wasSuccessful,
484
+ recentlySuccessful,
485
+ validating,
486
+ touchedFields,
487
+ validFields
488
+ };
489
+ const setProcessing = useCallback((value) => {
490
+ _setProcessing(value);
491
+ snapshotRef.current.processing = value;
492
+ }, []);
493
+ const setProgress = useCallback((value) => {
494
+ _setProgress(value);
495
+ snapshotRef.current.progress = value;
496
+ }, []);
435
497
  const setDataFunction = useCallback(
436
498
  (keyOrData, maybeValue) => {
437
499
  if (typeof keyOrData === "string") {
@@ -503,12 +565,12 @@ function useFormState(options) {
503
565
  ...errors2,
504
566
  ...typeof fieldOrFields === "string" ? { [fieldOrFields]: maybeValue } : fieldOrFields
505
567
  };
506
- setHasErrors(Object.keys(newErrors).length > 0);
568
+ snapshotRef.current.errors = newErrors;
507
569
  validatorRef.current?.setErrors(newErrors);
508
570
  return newErrors;
509
571
  });
510
572
  },
511
- [setErrors, setHasErrors]
573
+ [setErrors]
512
574
  );
513
575
  const clearErrors = useCallback(
514
576
  (...fields) => {
@@ -520,7 +582,7 @@ function useFormState(options) {
520
582
  }),
521
583
  {}
522
584
  );
523
- setHasErrors(Object.keys(newErrors).length > 0);
585
+ snapshotRef.current.errors = newErrors;
524
586
  if (validatorRef.current) {
525
587
  if (fields.length === 0) {
526
588
  validatorRef.current.setErrors({});
@@ -531,7 +593,7 @@ function useFormState(options) {
531
593
  return newErrors;
532
594
  });
533
595
  },
534
- [setErrors, setHasErrors]
596
+ [setErrors]
535
597
  );
536
598
  const resetAndClearErrors = useCallback(
537
599
  (...fields) => {
@@ -540,21 +602,29 @@ function useFormState(options) {
540
602
  },
541
603
  [reset, clearErrors]
542
604
  );
605
+ const setWasSuccessfulWithSnapshot = useCallback((value) => {
606
+ setWasSuccessful(value);
607
+ snapshotRef.current.wasSuccessful = value;
608
+ }, []);
609
+ const setRecentlySuccessfulWithSnapshot = useCallback((value) => {
610
+ setRecentlySuccessful(value);
611
+ snapshotRef.current.recentlySuccessful = value;
612
+ }, []);
543
613
  const markAsSuccessful = useCallback(() => {
544
614
  clearErrors();
545
- setWasSuccessful(true);
546
- setRecentlySuccessful(true);
615
+ setWasSuccessfulWithSnapshot(true);
616
+ setRecentlySuccessfulWithSnapshot(true);
547
617
  recentlySuccessfulTimeoutId.current = window.setTimeout(() => {
548
618
  if (isMounted.current) {
549
- setRecentlySuccessful(false);
619
+ setRecentlySuccessfulWithSnapshot(false);
550
620
  }
551
621
  }, config.get("form.recentlySuccessfulDuration"));
552
- }, [clearErrors, setWasSuccessful, setRecentlySuccessful]);
622
+ }, [clearErrors, setWasSuccessfulWithSnapshot, setRecentlySuccessfulWithSnapshot]);
553
623
  const resetBeforeSubmit = useCallback(() => {
554
- setWasSuccessful(false);
555
- setRecentlySuccessful(false);
624
+ setWasSuccessfulWithSnapshot(false);
625
+ setRecentlySuccessfulWithSnapshot(false);
556
626
  clearTimeout(recentlySuccessfulTimeoutId.current);
557
- }, [setWasSuccessful, setRecentlySuccessful]);
627
+ }, [setWasSuccessfulWithSnapshot, setRecentlySuccessfulWithSnapshot]);
558
628
  const finishProcessing = useCallback(() => {
559
629
  setProcessing(false);
560
630
  setProgress(null);
@@ -575,23 +645,43 @@ function useFormState(options) {
575
645
  (field) => typeof field === "string" ? touchedFields.includes(field) : touchedFields.length > 0,
576
646
  [touchedFields]
577
647
  );
578
- const form = {
579
- data,
648
+ const form = useMemo3(() => {
649
+ return {
650
+ get data() {
651
+ return snapshotRef.current.data;
652
+ },
653
+ get isDirty() {
654
+ return !isEqual(snapshotRef.current.data, snapshotRef.current.defaults);
655
+ },
656
+ get errors() {
657
+ return snapshotRef.current.errors;
658
+ },
659
+ get hasErrors() {
660
+ return Object.keys(snapshotRef.current.errors).length > 0;
661
+ },
662
+ get processing() {
663
+ return snapshotRef.current.processing;
664
+ },
665
+ get progress() {
666
+ return snapshotRef.current.progress;
667
+ },
668
+ get wasSuccessful() {
669
+ return snapshotRef.current.wasSuccessful;
670
+ },
671
+ get recentlySuccessful() {
672
+ return snapshotRef.current.recentlySuccessful;
673
+ }
674
+ };
675
+ }, []);
676
+ Object.assign(form, {
580
677
  setData: setDataFunction,
581
- isDirty,
582
- errors,
583
- hasErrors,
584
- processing,
585
- progress: progress2,
586
- wasSuccessful,
587
- recentlySuccessful,
588
678
  transform: transformFunction,
589
679
  setDefaults: setDefaultsFunction,
590
680
  reset,
591
681
  setError,
592
682
  clearErrors,
593
683
  resetAndClearErrors
594
- };
684
+ });
595
685
  const validate = (field, config3) => {
596
686
  if (typeof field === "object" && !("target" in field)) {
597
687
  config3 = field;
@@ -628,12 +718,14 @@ function useFormState(options) {
628
718
  }).on("errorsChanged", () => {
629
719
  const validationErrors = withAllErrorsEnabled() ? validator.errors() : toSimpleValidationErrors(validator.errors());
630
720
  setErrors(validationErrors);
631
- setHasErrors(Object.keys(validationErrors).length > 0);
721
+ snapshotRef.current.errors = validationErrors;
632
722
  setValidFields(validator.valid());
633
723
  });
634
724
  }
635
725
  const precognitiveForm = Object.assign(form, {
636
- validating,
726
+ get validating() {
727
+ return snapshotRef.current.validating;
728
+ },
637
729
  validator: () => validatorRef.current,
638
730
  valid,
639
731
  invalid,
@@ -862,7 +954,7 @@ var deferStateUpdate = (callback) => {
862
954
  typeof React.startTransition === "function" ? React.startTransition(callback) : setTimeout(callback, 0);
863
955
  };
864
956
  var noop = () => void 0;
865
- var FormContext = createContext4(void 0);
957
+ var FormContext = createContext3(void 0);
866
958
  var Form = forwardRef(
867
959
  ({
868
960
  action = "",
@@ -912,10 +1004,10 @@ var Form = forwardRef(
912
1004
  }
913
1005
  form.transform(getTransformedData);
914
1006
  const formElement = useRef4(void 0);
915
- const resolvedMethod = useMemo5(() => {
1007
+ const resolvedMethod = useMemo4(() => {
916
1008
  return isUrlMethodPair(action) ? action.method : method.toLowerCase();
917
1009
  }, [action, method]);
918
- const resolvedComponent = useMemo5(() => {
1010
+ const resolvedComponent = useMemo4(() => {
919
1011
  if (component) {
920
1012
  return component;
921
1013
  }
@@ -1084,11 +1176,11 @@ function useFormContext() {
1084
1176
  var Form_default = Form;
1085
1177
 
1086
1178
  // src/Head.ts
1087
- import { escape } from "lodash-es";
1088
- import React2, { use as use3, useEffect as useEffect7, useMemo as useMemo6 } from "react";
1179
+ import { escape } from "es-toolkit/compat";
1180
+ import React2, { use as use3, useEffect as useEffect7, useMemo as useMemo5 } from "react";
1089
1181
  var Head = function({ children, title }) {
1090
1182
  const headManager = use3(HeadContext_default);
1091
- const provider = useMemo6(() => headManager.createProvider(), [headManager]);
1183
+ const provider = useMemo5(() => headManager.createProvider(), [headManager]);
1092
1184
  const isServer = typeof window === "undefined";
1093
1185
  useEffect7(() => {
1094
1186
  provider.reconnect();
@@ -1185,7 +1277,7 @@ import React3, {
1185
1277
  useCallback as useCallback3,
1186
1278
  useEffect as useEffect8,
1187
1279
  useImperativeHandle as useImperativeHandle2,
1188
- useMemo as useMemo7,
1280
+ useMemo as useMemo6,
1189
1281
  useRef as useRef5,
1190
1282
  useState as useState7
1191
1283
  } from "react";
@@ -1235,11 +1327,12 @@ var InfiniteScroll = forwardRef2(
1235
1327
  const endElementRef = useCallback3((node) => setEndElementFromRef(node), []);
1236
1328
  const [itemsElementFromRef, setItemsElementFromRef] = useState7(null);
1237
1329
  const itemsElementRef = useCallback3((node) => setItemsElementFromRef(node), []);
1330
+ const scrollProp = usePage().scrollProps?.[data];
1238
1331
  const [loadingPrevious, setLoadingPrevious] = useState7(false);
1239
1332
  const [loadingNext, setLoadingNext] = useState7(false);
1240
1333
  const [requestCount, setRequestCount] = useState7(0);
1241
- const [hasPreviousPage, setHasPreviousPage] = useState7(false);
1242
- const [hasNextPage, setHasNextPage] = useState7(false);
1334
+ const [hasPreviousPage, setHasPreviousPage] = useState7(!!scrollProp?.previousPage);
1335
+ const [hasNextPage, setHasNextPage] = useState7(!!scrollProp?.nextPage);
1243
1336
  const [resolvedStartElement, setResolvedStartElement] = useState7(null);
1244
1337
  const [resolvedEndElement, setResolvedEndElement] = useState7(null);
1245
1338
  const [resolvedItemsElement, setResolvedItemsElement] = useState7(null);
@@ -1255,7 +1348,7 @@ var InfiniteScroll = forwardRef2(
1255
1348
  const element = itemsElement ? resolveHTMLElement(itemsElement, itemsElementFromRef) : itemsElementFromRef;
1256
1349
  setResolvedItemsElement(element);
1257
1350
  }, [itemsElement, itemsElementFromRef]);
1258
- const scrollableParent = useMemo7(() => getScrollableParent(resolvedItemsElement), [resolvedItemsElement]);
1351
+ const scrollableParent = useMemo6(() => getScrollableParent(resolvedItemsElement), [resolvedItemsElement]);
1259
1352
  const callbackPropsRef = useRef5({
1260
1353
  buffer,
1261
1354
  onlyNext,
@@ -1273,8 +1366,8 @@ var InfiniteScroll = forwardRef2(
1273
1366
  params
1274
1367
  };
1275
1368
  const [infiniteScroll, setInfiniteScroll] = useState7(null);
1276
- const dataManager = useMemo7(() => infiniteScroll?.dataManager, [infiniteScroll]);
1277
- const elementManager = useMemo7(() => infiniteScroll?.elementManager, [infiniteScroll]);
1369
+ const dataManager = useMemo6(() => infiniteScroll?.dataManager, [infiniteScroll]);
1370
+ const elementManager = useMemo6(() => infiniteScroll?.elementManager, [infiniteScroll]);
1278
1371
  const scrollToBottom = useCallback3(() => {
1279
1372
  if (scrollableParent) {
1280
1373
  scrollableParent.scrollTo({
@@ -1337,11 +1430,11 @@ var InfiniteScroll = forwardRef2(
1337
1430
  setInfiniteScroll(null);
1338
1431
  };
1339
1432
  }, [data, resolvedItemsElement, resolvedStartElement, resolvedEndElement, scrollableParent]);
1340
- const manualMode = useMemo7(
1433
+ const manualMode = useMemo6(
1341
1434
  () => manual || manualAfter > 0 && requestCount >= manualAfter,
1342
1435
  [manual, manualAfter, requestCount]
1343
1436
  );
1344
- const autoLoad = useMemo7(() => !manualMode, [manualMode]);
1437
+ const autoLoad = useMemo6(() => !manualMode, [manualMode]);
1345
1438
  useEffect8(() => {
1346
1439
  autoLoad ? elementManager?.enableTriggers() : elementManager?.disableTriggers();
1347
1440
  }, [autoLoad, onlyNext, onlyPrevious, resolvedStartElement, resolvedEndElement]);
@@ -1437,7 +1530,7 @@ import {
1437
1530
  shouldIntercept,
1438
1531
  shouldNavigate
1439
1532
  } from "@inertiajs/core";
1440
- import { createElement as createElement5, forwardRef as forwardRef3, useEffect as useEffect9, useMemo as useMemo8, useRef as useRef6, useState as useState8 } from "react";
1533
+ import { createElement as createElement5, forwardRef as forwardRef3, useEffect as useEffect9, useMemo as useMemo7, useRef as useRef6, useState as useState8 } from "react";
1441
1534
  var noop2 = () => void 0;
1442
1535
  var Link = forwardRef3(
1443
1536
  ({
@@ -1477,10 +1570,10 @@ var Link = forwardRef3(
1477
1570
  }, ref) => {
1478
1571
  const [inFlightCount, setInFlightCount] = useState8(0);
1479
1572
  const hoverTimeout = useRef6(void 0);
1480
- const _method = useMemo8(() => {
1573
+ const _method = useMemo7(() => {
1481
1574
  return isUrlMethodPair2(href) ? href.method : method.toLowerCase();
1482
1575
  }, [href, method]);
1483
- const resolvedComponent = useMemo8(() => {
1576
+ const resolvedComponent = useMemo7(() => {
1484
1577
  if (component) {
1485
1578
  return component;
1486
1579
  }
@@ -1489,19 +1582,19 @@ var Link = forwardRef3(
1489
1582
  }
1490
1583
  return null;
1491
1584
  }, [component, instant, href]);
1492
- const _as = useMemo8(() => {
1585
+ const _as = useMemo7(() => {
1493
1586
  if (typeof as !== "string" || as.toLowerCase() !== "a") {
1494
1587
  return as;
1495
1588
  }
1496
1589
  return _method !== "get" ? "button" : as.toLowerCase();
1497
1590
  }, [as, _method]);
1498
- const mergeDataArray = useMemo8(
1591
+ const mergeDataArray = useMemo7(
1499
1592
  () => mergeDataIntoQueryString2(_method, isUrlMethodPair2(href) ? href.url : href, data, queryStringArrayFormat),
1500
1593
  [href, _method, data, queryStringArrayFormat]
1501
1594
  );
1502
- const url = useMemo8(() => mergeDataArray[0], [mergeDataArray]);
1503
- const _data = useMemo8(() => mergeDataArray[1], [mergeDataArray]);
1504
- const baseParams = useMemo8(
1595
+ const url = useMemo7(() => mergeDataArray[0], [mergeDataArray]);
1596
+ const _data = useMemo7(() => mergeDataArray[1], [mergeDataArray]);
1597
+ const baseParams = useMemo7(
1505
1598
  () => ({
1506
1599
  data: _data,
1507
1600
  method: _method,
@@ -1531,7 +1624,7 @@ var Link = forwardRef3(
1531
1624
  pageProps
1532
1625
  ]
1533
1626
  );
1534
- const visitParams = useMemo8(
1627
+ const visitParams = useMemo7(
1535
1628
  () => ({
1536
1629
  ...baseParams,
1537
1630
  viewTransition,
@@ -1563,7 +1656,7 @@ var Link = forwardRef3(
1563
1656
  onError
1564
1657
  ]
1565
1658
  );
1566
- const prefetchModes = useMemo8(
1659
+ const prefetchModes = useMemo7(
1567
1660
  () => {
1568
1661
  if (prefetch === true) {
1569
1662
  return ["hover"];
@@ -1578,7 +1671,7 @@ var Link = forwardRef3(
1578
1671
  },
1579
1672
  Array.isArray(prefetch) ? prefetch : [prefetch]
1580
1673
  );
1581
- const cacheForValue = useMemo8(() => {
1674
+ const cacheForValue = useMemo7(() => {
1582
1675
  if (cacheFor !== 0) {
1583
1676
  return cacheFor;
1584
1677
  }
@@ -1587,7 +1680,7 @@ var Link = forwardRef3(
1587
1680
  }
1588
1681
  return config.get("prefetch.cacheFor");
1589
1682
  }, [cacheFor, prefetchModes]);
1590
- const doPrefetch = useMemo8(() => {
1683
+ const doPrefetch = useMemo7(() => {
1591
1684
  return () => {
1592
1685
  router6.prefetch(
1593
1686
  url,
@@ -1662,7 +1755,7 @@ var Link = forwardRef3(
1662
1755
  }
1663
1756
  }
1664
1757
  };
1665
- const elProps = useMemo8(() => {
1758
+ const elProps = useMemo7(() => {
1666
1759
  if (_as === "button") {
1667
1760
  return { type: "button" };
1668
1761
  }
@@ -1705,8 +1798,8 @@ import {
1705
1798
  objectToFormData,
1706
1799
  UseFormUtils as UseFormUtils4
1707
1800
  } from "@inertiajs/core";
1801
+ import { cloneDeep as cloneDeep3 } from "es-toolkit";
1708
1802
  import { toSimpleValidationErrors as toSimpleValidationErrors2 } from "laravel-precognition";
1709
- import { cloneDeep as cloneDeep3 } from "lodash-es";
1710
1803
  import { useCallback as useCallback4, useRef as useRef7, useState as useState9 } from "react";
1711
1804
  function useHttp(...args) {
1712
1805
  const { rememberKey, data, precognitionEndpoint } = UseFormUtils4.parseUseFormArguments(...args);
@@ -1804,7 +1897,7 @@ function useHttp(...args) {
1804
1897
  options.onProgress?.(event);
1805
1898
  }
1806
1899
  });
1807
- const responseData = JSON.parse(httpResponse.data);
1900
+ const responseData = httpResponse.data ? JSON.parse(httpResponse.data) : null;
1808
1901
  if (httpResponse.status >= 200 && httpResponse.status < 300) {
1809
1902
  if (isMounted.current) {
1810
1903
  markAsSuccessful();
@@ -1960,14 +2053,14 @@ function usePrefetch(options = {}) {
1960
2053
 
1961
2054
  // src/WhenVisible.ts
1962
2055
  import { router as router9 } from "@inertiajs/core";
1963
- import { get as get3 } from "lodash-es";
1964
- import { createElement as createElement6, useCallback as useCallback5, useEffect as useEffect12, useMemo as useMemo9, useRef as useRef9, useState as useState11 } from "react";
2056
+ import { get as get3 } from "es-toolkit/compat";
2057
+ import { createElement as createElement6, useCallback as useCallback5, useEffect as useEffect12, useMemo as useMemo8, useRef as useRef9, useState as useState11 } from "react";
1965
2058
  var WhenVisible = ({ children, data, params, buffer, as, always, fallback }) => {
1966
2059
  always = always ?? false;
1967
2060
  as = as ?? "div";
1968
2061
  fallback = fallback ?? null;
1969
2062
  const pageProps = usePage().props;
1970
- const keys = useMemo9(() => data ? Array.isArray(data) ? data : [data] : [], [data]);
2063
+ const keys = useMemo8(() => data ? Array.isArray(data) ? data : [data] : [], [data]);
1971
2064
  const [loaded, setLoaded] = useState11(() => keys.length > 0 && keys.every((key) => get3(pageProps, key) !== void 0));
1972
2065
  const [isFetching, setIsFetching] = useState11(false);
1973
2066
  const fetching = useRef9(false);
@@ -2077,7 +2170,6 @@ export {
2077
2170
  useForm,
2078
2171
  useFormContext,
2079
2172
  useHttp,
2080
- useLayoutProps,
2081
2173
  usePage,
2082
2174
  usePoll,
2083
2175
  usePrefetch,