@inertiajs/vue3 2.3.17 → 3.0.0-beta.2
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 +900 -408
- package/dist/index.js.map +4 -4
- package/dist/server.js +4 -35
- package/dist/server.js.map +2 -2
- package/package.json +7 -9
- package/resources/boost/skills/inertia-vue-development/SKILL.blade.php +135 -7
- package/types/app.d.ts +2 -1
- package/types/createInertiaApp.d.ts +9 -2
- package/types/deferred.d.ts +16 -2
- package/types/form.d.ts +42 -4
- package/types/index.d.ts +5 -3
- package/types/infiniteScroll.d.ts +10 -1
- package/types/layoutProps.d.ts +13 -0
- package/types/useForm.d.ts +2 -1
- package/types/useFormState.d.ts +80 -0
- package/types/useHttp.d.ts +63 -0
- package/dist/index.esm.js +0 -1802
- package/dist/index.esm.js.map +0 -7
- package/dist/server.esm.js +0 -6
- package/dist/server.esm.js.map +0 -7
package/dist/index.js
CHANGED
|
@@ -1,54 +1,64 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key2 of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
14
|
-
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
1
|
// src/index.ts
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
App: () => app_default,
|
|
24
|
-
Deferred: () => deferred_default,
|
|
25
|
-
Form: () => form_default,
|
|
26
|
-
Head: () => head_default,
|
|
27
|
-
InfiniteScroll: () => infiniteScroll_default,
|
|
28
|
-
Link: () => link_default,
|
|
29
|
-
WhenVisible: () => whenVisible_default,
|
|
30
|
-
config: () => config,
|
|
31
|
-
createInertiaApp: () => createInertiaApp,
|
|
32
|
-
progress: () => import_core13.progress,
|
|
33
|
-
router: () => import_core13.router,
|
|
34
|
-
useForm: () => useForm,
|
|
35
|
-
useFormContext: () => useFormContext,
|
|
36
|
-
usePage: () => usePage,
|
|
37
|
-
usePoll: () => usePoll,
|
|
38
|
-
usePrefetch: () => usePrefetch,
|
|
39
|
-
useRemember: () => useRemember
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(index_exports);
|
|
42
|
-
var import_core12 = require("@inertiajs/core");
|
|
43
|
-
var import_core13 = require("@inertiajs/core");
|
|
2
|
+
import { config as coreConfig } from "@inertiajs/core";
|
|
3
|
+
import { http as http2, progress, router as router12 } from "@inertiajs/core";
|
|
44
4
|
|
|
45
5
|
// src/app.ts
|
|
46
|
-
|
|
47
|
-
|
|
6
|
+
import {
|
|
7
|
+
createHeadManager,
|
|
8
|
+
normalizeLayouts,
|
|
9
|
+
router as router4
|
|
10
|
+
} from "@inertiajs/core";
|
|
11
|
+
import {
|
|
12
|
+
computed as computed2,
|
|
13
|
+
defineComponent as defineComponent2,
|
|
14
|
+
h,
|
|
15
|
+
markRaw,
|
|
16
|
+
reactive as reactive2,
|
|
17
|
+
ref as ref2,
|
|
18
|
+
shallowRef
|
|
19
|
+
} from "vue";
|
|
20
|
+
|
|
21
|
+
// src/layoutProps.ts
|
|
22
|
+
import { createLayoutPropsStore, mergeLayoutProps } from "@inertiajs/core";
|
|
23
|
+
import { computed, defineComponent, inject, provide, ref, useAttrs } from "vue";
|
|
24
|
+
var store = createLayoutPropsStore();
|
|
25
|
+
var state = ref(store.get());
|
|
26
|
+
store.subscribe(() => {
|
|
27
|
+
state.value = store.get();
|
|
28
|
+
});
|
|
29
|
+
function setLayoutProps(props) {
|
|
30
|
+
store.set(props);
|
|
31
|
+
}
|
|
32
|
+
function setLayoutPropsFor(name, props) {
|
|
33
|
+
store.setFor(name, props);
|
|
34
|
+
}
|
|
35
|
+
function resetLayoutProps() {
|
|
36
|
+
store.reset();
|
|
37
|
+
}
|
|
38
|
+
var LAYOUT_CONTEXT_KEY = /* @__PURE__ */ Symbol("inertia-layout");
|
|
39
|
+
var LayoutProvider = defineComponent({
|
|
40
|
+
inheritAttrs: false,
|
|
41
|
+
props: {
|
|
42
|
+
layoutName: String
|
|
43
|
+
},
|
|
44
|
+
setup(props, { slots }) {
|
|
45
|
+
provide(LAYOUT_CONTEXT_KEY, props.layoutName);
|
|
46
|
+
return () => slots.default?.();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
function useLayoutProps(defaults) {
|
|
50
|
+
const attrs = useAttrs();
|
|
51
|
+
const name = inject(LAYOUT_CONTEXT_KEY, void 0);
|
|
52
|
+
return computed(() => {
|
|
53
|
+
const { shared, named } = state.value;
|
|
54
|
+
const dynamicProps = name ? { ...shared, ...named[name] } : shared;
|
|
55
|
+
return mergeLayoutProps(defaults, attrs, dynamicProps);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
48
58
|
|
|
49
59
|
// src/remember.ts
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
import { router } from "@inertiajs/core";
|
|
61
|
+
import { cloneDeep } from "lodash-es";
|
|
52
62
|
var remember = {
|
|
53
63
|
created() {
|
|
54
64
|
if (!this.$options.remember) {
|
|
@@ -64,7 +74,7 @@ var remember = {
|
|
|
64
74
|
this.$options.remember = { data: [this.$options.remember.data] };
|
|
65
75
|
}
|
|
66
76
|
const rememberKey = this.$options.remember.key instanceof Function ? this.$options.remember.key.call(this) : this.$options.remember.key;
|
|
67
|
-
const restored =
|
|
77
|
+
const restored = router.restore(rememberKey);
|
|
68
78
|
const rememberable = this.$options.remember.data.filter((key2) => {
|
|
69
79
|
return !(this[key2] !== null && typeof this[key2] === "object" && this[key2].__rememberable === false);
|
|
70
80
|
});
|
|
@@ -78,11 +88,11 @@ var remember = {
|
|
|
78
88
|
this.$watch(
|
|
79
89
|
key2,
|
|
80
90
|
() => {
|
|
81
|
-
|
|
91
|
+
router.remember(
|
|
82
92
|
rememberable.reduce(
|
|
83
93
|
(data, key3) => ({
|
|
84
94
|
...data,
|
|
85
|
-
[key3]:
|
|
95
|
+
[key3]: cloneDeep(hasCallbacks(key3) ? this[key3].__remember() : this[key3])
|
|
86
96
|
}),
|
|
87
97
|
{}
|
|
88
98
|
),
|
|
@@ -97,57 +107,59 @@ var remember = {
|
|
|
97
107
|
var remember_default = remember;
|
|
98
108
|
|
|
99
109
|
// src/useForm.ts
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
let defaults =
|
|
126
|
-
|
|
127
|
-
let cancelToken = null;
|
|
128
|
-
let recentlySuccessfulTimeoutId;
|
|
129
|
-
let transform = (data2) => data2;
|
|
110
|
+
import {
|
|
111
|
+
router as router3,
|
|
112
|
+
UseFormUtils as UseFormUtils2
|
|
113
|
+
} from "@inertiajs/core";
|
|
114
|
+
import { cloneDeep as cloneDeep3 } from "lodash-es";
|
|
115
|
+
|
|
116
|
+
// src/useFormState.ts
|
|
117
|
+
import {
|
|
118
|
+
router as router2,
|
|
119
|
+
UseFormUtils
|
|
120
|
+
} from "@inertiajs/core";
|
|
121
|
+
import {
|
|
122
|
+
createValidator,
|
|
123
|
+
resolveName,
|
|
124
|
+
toSimpleValidationErrors
|
|
125
|
+
} from "laravel-precognition";
|
|
126
|
+
import { cloneDeep as cloneDeep2, get, has, isEqual, set } from "lodash-es";
|
|
127
|
+
import { reactive, watch } from "vue";
|
|
128
|
+
function useFormState(options) {
|
|
129
|
+
const { data: dataOption, rememberKey } = options;
|
|
130
|
+
let { precognitionEndpoint } = options;
|
|
131
|
+
const isDataFunction = typeof dataOption === "function";
|
|
132
|
+
const resolveData = () => isDataFunction ? dataOption() : dataOption;
|
|
133
|
+
const restored = rememberKey ? router2.restore(rememberKey) : null;
|
|
134
|
+
const initialData = restored?.data ?? cloneDeep2(resolveData());
|
|
135
|
+
let defaults = cloneDeep2(initialData);
|
|
136
|
+
let transform = (data) => data;
|
|
130
137
|
let validatorRef = null;
|
|
131
|
-
let
|
|
138
|
+
let withAllErrors = null;
|
|
139
|
+
const withAllErrorsEnabled = () => withAllErrors ?? config.get("form.withAllErrors");
|
|
140
|
+
let recentlySuccessfulTimeoutId;
|
|
132
141
|
let defaultsCalledInOnSuccess = false;
|
|
133
|
-
|
|
134
|
-
|
|
142
|
+
let rememberExcludeKeys = [];
|
|
143
|
+
const form = reactive({
|
|
144
|
+
...cloneDeep2(defaults),
|
|
135
145
|
isDirty: false,
|
|
136
|
-
errors:
|
|
146
|
+
errors: {},
|
|
137
147
|
hasErrors: false,
|
|
138
148
|
processing: false,
|
|
139
149
|
progress: null,
|
|
140
150
|
wasSuccessful: false,
|
|
141
151
|
recentlySuccessful: false,
|
|
142
|
-
withPrecognition(...
|
|
143
|
-
precognitionEndpoint =
|
|
152
|
+
withPrecognition(...args) {
|
|
153
|
+
precognitionEndpoint = UseFormUtils.createWayfinderCallback(...args);
|
|
144
154
|
const formWithPrecognition = this;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
155
|
+
const validator = createValidator(
|
|
156
|
+
(client) => {
|
|
157
|
+
const { method, url } = precognitionEndpoint();
|
|
158
|
+
const transformedData = cloneDeep2(transform(this.data()));
|
|
159
|
+
return client[method](url, transformedData);
|
|
160
|
+
},
|
|
161
|
+
cloneDeep2(defaults)
|
|
162
|
+
);
|
|
151
163
|
validatorRef = validator;
|
|
152
164
|
validator.on("validatingChanged", () => {
|
|
153
165
|
formWithPrecognition.validating = validator.validating();
|
|
@@ -156,7 +168,7 @@ function useForm(...args) {
|
|
|
156
168
|
}).on("touchedChanged", () => {
|
|
157
169
|
formWithPrecognition.__touched = validator.touched();
|
|
158
170
|
}).on("errorsChanged", () => {
|
|
159
|
-
const validationErrors =
|
|
171
|
+
const validationErrors = withAllErrorsEnabled() ? validator.errors() : toSimpleValidationErrors(validator.errors());
|
|
160
172
|
this.errors = {};
|
|
161
173
|
this.setError(validationErrors);
|
|
162
174
|
formWithPrecognition.__valid = validator.valid();
|
|
@@ -195,23 +207,23 @@ function useForm(...args) {
|
|
|
195
207
|
if (field === void 0) {
|
|
196
208
|
validator.validate(config3);
|
|
197
209
|
} else {
|
|
198
|
-
const fieldName =
|
|
210
|
+
const fieldName = resolveName(field);
|
|
199
211
|
const transformedData = transform(this.data());
|
|
200
|
-
validator.validate(fieldName,
|
|
212
|
+
validator.validate(fieldName, get(transformedData, fieldName), config3);
|
|
201
213
|
}
|
|
202
214
|
return formWithPrecognition;
|
|
203
215
|
},
|
|
204
216
|
setErrors: (errors) => tap(formWithPrecognition, () => this.setError(errors)),
|
|
205
217
|
forgetError: (field) => tap(
|
|
206
218
|
formWithPrecognition,
|
|
207
|
-
() => this.clearErrors(
|
|
219
|
+
() => this.clearErrors(resolveName(field))
|
|
208
220
|
)
|
|
209
221
|
});
|
|
210
222
|
return formWithPrecognition;
|
|
211
223
|
},
|
|
212
224
|
data() {
|
|
213
225
|
return Object.keys(defaults).reduce((carry, key2) => {
|
|
214
|
-
return
|
|
226
|
+
return set(carry, key2, get(this, key2));
|
|
215
227
|
}, {});
|
|
216
228
|
},
|
|
217
229
|
transform(callback) {
|
|
@@ -219,30 +231,34 @@ function useForm(...args) {
|
|
|
219
231
|
return this;
|
|
220
232
|
},
|
|
221
233
|
defaults(fieldOrFields, maybeValue) {
|
|
222
|
-
if (
|
|
234
|
+
if (isDataFunction) {
|
|
223
235
|
throw new Error("You cannot call `defaults()` when using a function to define your form data.");
|
|
224
236
|
}
|
|
225
237
|
defaultsCalledInOnSuccess = true;
|
|
226
238
|
if (typeof fieldOrFields === "undefined") {
|
|
227
|
-
defaults = (
|
|
239
|
+
defaults = cloneDeep2(this.data());
|
|
228
240
|
this.isDirty = false;
|
|
229
241
|
} else {
|
|
230
|
-
defaults = typeof fieldOrFields === "string" ?
|
|
242
|
+
defaults = typeof fieldOrFields === "string" ? set(cloneDeep2(defaults), fieldOrFields, maybeValue) : Object.assign({}, cloneDeep2(defaults), fieldOrFields);
|
|
231
243
|
}
|
|
232
244
|
validatorRef?.defaults(defaults);
|
|
233
245
|
return this;
|
|
234
246
|
},
|
|
235
247
|
reset(...fields) {
|
|
236
|
-
const resolvedData =
|
|
237
|
-
const clonedData = (
|
|
248
|
+
const resolvedData = isDataFunction ? cloneDeep2(resolveData()) : defaults;
|
|
249
|
+
const clonedData = cloneDeep2(resolvedData);
|
|
238
250
|
if (fields.length === 0) {
|
|
239
|
-
|
|
240
|
-
|
|
251
|
+
if (isDataFunction) {
|
|
252
|
+
defaults = clonedData;
|
|
253
|
+
}
|
|
254
|
+
Object.assign(this, clonedData);
|
|
241
255
|
} else {
|
|
242
256
|
;
|
|
243
|
-
fields.filter((key2) =>
|
|
244
|
-
|
|
245
|
-
|
|
257
|
+
fields.filter((key2) => has(clonedData, key2)).forEach((key2) => {
|
|
258
|
+
if (isDataFunction) {
|
|
259
|
+
set(defaults, key2, get(clonedData, key2));
|
|
260
|
+
}
|
|
261
|
+
set(this, key2, get(clonedData, key2));
|
|
246
262
|
});
|
|
247
263
|
}
|
|
248
264
|
validatorRef?.reset(...fields);
|
|
@@ -278,147 +294,238 @@ function useForm(...args) {
|
|
|
278
294
|
this.clearErrors(...fields);
|
|
279
295
|
return this;
|
|
280
296
|
},
|
|
281
|
-
|
|
282
|
-
|
|
297
|
+
__rememberable: rememberKey === null,
|
|
298
|
+
__remember() {
|
|
299
|
+
const formData = this.data();
|
|
300
|
+
if (rememberExcludeKeys.length > 0) {
|
|
301
|
+
const filtered = { ...formData };
|
|
302
|
+
rememberExcludeKeys.forEach((k) => delete filtered[k]);
|
|
303
|
+
return { data: filtered, errors: this.errors };
|
|
304
|
+
}
|
|
305
|
+
return { data: formData, errors: this.errors };
|
|
306
|
+
},
|
|
307
|
+
__restore(restored2) {
|
|
308
|
+
Object.assign(this, restored2.data);
|
|
309
|
+
this.setError(restored2.errors);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
const typedForm = form;
|
|
313
|
+
if (restored?.errors) {
|
|
314
|
+
typedForm.setError(restored.errors);
|
|
315
|
+
}
|
|
316
|
+
watch(
|
|
317
|
+
typedForm,
|
|
318
|
+
() => {
|
|
319
|
+
typedForm.isDirty = !isEqual(typedForm.data(), defaults);
|
|
320
|
+
},
|
|
321
|
+
{ immediate: true, deep: true }
|
|
322
|
+
);
|
|
323
|
+
watch(
|
|
324
|
+
typedForm,
|
|
325
|
+
(newValue) => {
|
|
326
|
+
if (!rememberKey) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const storedData = router2.restore(rememberKey);
|
|
330
|
+
const newData = cloneDeep2(newValue.__remember());
|
|
331
|
+
if (!isEqual(storedData, newData)) {
|
|
332
|
+
router2.remember(newData, rememberKey);
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
{ immediate: true, deep: true }
|
|
336
|
+
);
|
|
337
|
+
if (precognitionEndpoint) {
|
|
338
|
+
typedForm.withPrecognition(precognitionEndpoint);
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
form: typedForm,
|
|
342
|
+
setDefaults: (newDefaults) => {
|
|
343
|
+
defaults = newDefaults;
|
|
344
|
+
},
|
|
345
|
+
getTransform: () => transform,
|
|
346
|
+
getPrecognitionEndpoint: () => precognitionEndpoint ?? null,
|
|
347
|
+
markAsSuccessful: () => {
|
|
348
|
+
typedForm.clearErrors();
|
|
349
|
+
typedForm.wasSuccessful = true;
|
|
350
|
+
typedForm.recentlySuccessful = true;
|
|
351
|
+
recentlySuccessfulTimeoutId = setTimeout(
|
|
352
|
+
() => typedForm.recentlySuccessful = false,
|
|
353
|
+
config.get("form.recentlySuccessfulDuration")
|
|
354
|
+
);
|
|
355
|
+
},
|
|
356
|
+
wasDefaultsCalledInOnSuccess: () => defaultsCalledInOnSuccess,
|
|
357
|
+
resetDefaultsCalledInOnSuccess: () => {
|
|
283
358
|
defaultsCalledInOnSuccess = false;
|
|
359
|
+
},
|
|
360
|
+
setRememberExcludeKeys: (keys) => {
|
|
361
|
+
rememberExcludeKeys = keys;
|
|
362
|
+
},
|
|
363
|
+
resetBeforeSubmit: () => {
|
|
364
|
+
typedForm.wasSuccessful = false;
|
|
365
|
+
typedForm.recentlySuccessful = false;
|
|
366
|
+
clearTimeout(recentlySuccessfulTimeoutId);
|
|
367
|
+
},
|
|
368
|
+
finishProcessing: () => {
|
|
369
|
+
typedForm.processing = false;
|
|
370
|
+
typedForm.progress = null;
|
|
371
|
+
},
|
|
372
|
+
withAllErrors: {
|
|
373
|
+
enabled: withAllErrorsEnabled,
|
|
374
|
+
enable: () => {
|
|
375
|
+
withAllErrors = true;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// src/useForm.ts
|
|
382
|
+
var reservedFormKeys = null;
|
|
383
|
+
var bootstrapping = false;
|
|
384
|
+
function validateFormDataKeys(data) {
|
|
385
|
+
if (bootstrapping) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (reservedFormKeys === null) {
|
|
389
|
+
bootstrapping = true;
|
|
390
|
+
reservedFormKeys = new Set(Object.keys(useForm({})));
|
|
391
|
+
bootstrapping = false;
|
|
392
|
+
}
|
|
393
|
+
const conflicts = Object.keys(data).filter((key2) => reservedFormKeys.has(key2));
|
|
394
|
+
if (conflicts.length > 0) {
|
|
395
|
+
console.error(
|
|
396
|
+
`[Inertia] useForm() data contains field(s) that conflict with form properties: ${conflicts.map((k) => `"${k}"`).join(", ")}. These fields will be overwritten by form methods/properties. Please rename these fields.`
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function useForm(...args) {
|
|
401
|
+
const { rememberKey, data, precognitionEndpoint } = UseFormUtils2.parseUseFormArguments(...args);
|
|
402
|
+
const initialDefaults = typeof data === "function" ? cloneDeep3(data()) : cloneDeep3(data);
|
|
403
|
+
validateFormDataKeys(initialDefaults);
|
|
404
|
+
let cancelToken = null;
|
|
405
|
+
let pendingOptimisticCallback = null;
|
|
406
|
+
const {
|
|
407
|
+
form: baseForm,
|
|
408
|
+
setDefaults,
|
|
409
|
+
getTransform,
|
|
410
|
+
getPrecognitionEndpoint,
|
|
411
|
+
markAsSuccessful,
|
|
412
|
+
wasDefaultsCalledInOnSuccess,
|
|
413
|
+
resetDefaultsCalledInOnSuccess,
|
|
414
|
+
setRememberExcludeKeys,
|
|
415
|
+
resetBeforeSubmit,
|
|
416
|
+
finishProcessing
|
|
417
|
+
} = useFormState({
|
|
418
|
+
data,
|
|
419
|
+
rememberKey,
|
|
420
|
+
precognitionEndpoint
|
|
421
|
+
});
|
|
422
|
+
const form = baseForm;
|
|
423
|
+
const createSubmitMethod = (method) => (url, options = {}) => {
|
|
424
|
+
form.submit(method, url, options);
|
|
425
|
+
};
|
|
426
|
+
Object.assign(form, {
|
|
427
|
+
submit(...args2) {
|
|
428
|
+
const { method, url, options } = UseFormUtils2.parseSubmitArguments(args2, getPrecognitionEndpoint());
|
|
429
|
+
resetDefaultsCalledInOnSuccess();
|
|
284
430
|
const _options = {
|
|
285
431
|
...options,
|
|
286
432
|
onCancelToken: (token) => {
|
|
287
433
|
cancelToken = token;
|
|
288
|
-
|
|
289
|
-
return options.onCancelToken(token);
|
|
290
|
-
}
|
|
434
|
+
return options.onCancelToken?.(token);
|
|
291
435
|
},
|
|
292
436
|
onBefore: (visit) => {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
clearTimeout(recentlySuccessfulTimeoutId);
|
|
296
|
-
if (options.onBefore) {
|
|
297
|
-
return options.onBefore(visit);
|
|
298
|
-
}
|
|
437
|
+
resetBeforeSubmit();
|
|
438
|
+
return options.onBefore?.(visit);
|
|
299
439
|
},
|
|
300
440
|
onStart: (visit) => {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
return options.onStart(visit);
|
|
304
|
-
}
|
|
441
|
+
form.processing = true;
|
|
442
|
+
return options.onStart?.(visit);
|
|
305
443
|
},
|
|
306
444
|
onProgress: (event) => {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
return options.onProgress(event);
|
|
310
|
-
}
|
|
445
|
+
form.progress = event ?? null;
|
|
446
|
+
return options.onProgress?.(event);
|
|
311
447
|
},
|
|
312
448
|
onSuccess: async (page2) => {
|
|
313
|
-
|
|
314
|
-
this.progress = null;
|
|
315
|
-
this.clearErrors();
|
|
316
|
-
this.wasSuccessful = true;
|
|
317
|
-
this.recentlySuccessful = true;
|
|
318
|
-
recentlySuccessfulTimeoutId = setTimeout(
|
|
319
|
-
() => this.recentlySuccessful = false,
|
|
320
|
-
config.get("form.recentlySuccessfulDuration")
|
|
321
|
-
);
|
|
449
|
+
markAsSuccessful();
|
|
322
450
|
const onSuccess = options.onSuccess ? await options.onSuccess(page2) : null;
|
|
323
|
-
if (!
|
|
324
|
-
|
|
325
|
-
|
|
451
|
+
if (!wasDefaultsCalledInOnSuccess()) {
|
|
452
|
+
setDefaults(cloneDeep3(form.data()));
|
|
453
|
+
form.isDirty = false;
|
|
326
454
|
}
|
|
327
455
|
return onSuccess;
|
|
328
456
|
},
|
|
329
457
|
onError: (errors) => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
this.clearErrors().setError(errors);
|
|
333
|
-
if (options.onError) {
|
|
334
|
-
return options.onError(errors);
|
|
335
|
-
}
|
|
458
|
+
form.clearErrors().setError(errors);
|
|
459
|
+
return options.onError?.(errors);
|
|
336
460
|
},
|
|
337
461
|
onCancel: () => {
|
|
338
|
-
|
|
339
|
-
this.progress = null;
|
|
340
|
-
if (options.onCancel) {
|
|
341
|
-
return options.onCancel();
|
|
342
|
-
}
|
|
462
|
+
return options.onCancel?.();
|
|
343
463
|
},
|
|
344
464
|
onFinish: (visit) => {
|
|
345
|
-
|
|
346
|
-
this.progress = null;
|
|
465
|
+
finishProcessing();
|
|
347
466
|
cancelToken = null;
|
|
348
|
-
|
|
349
|
-
return options.onFinish(visit);
|
|
350
|
-
}
|
|
467
|
+
return options.onFinish?.(visit);
|
|
351
468
|
}
|
|
352
469
|
};
|
|
353
|
-
|
|
470
|
+
_options.optimistic = _options.optimistic ?? pendingOptimisticCallback ?? void 0;
|
|
471
|
+
pendingOptimisticCallback = null;
|
|
472
|
+
const transformedData = getTransform()(form.data());
|
|
354
473
|
if (method === "delete") {
|
|
355
|
-
|
|
474
|
+
router3.delete(url, { ..._options, data: transformedData });
|
|
356
475
|
} else {
|
|
357
|
-
|
|
476
|
+
router3[method](url, transformedData, _options);
|
|
358
477
|
}
|
|
359
478
|
},
|
|
360
|
-
get(
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
},
|
|
366
|
-
put(url, options) {
|
|
367
|
-
this.submit("put", url, options);
|
|
368
|
-
},
|
|
369
|
-
patch(url, options) {
|
|
370
|
-
this.submit("patch", url, options);
|
|
371
|
-
},
|
|
372
|
-
delete(url, options) {
|
|
373
|
-
this.submit("delete", url, options);
|
|
374
|
-
},
|
|
479
|
+
get: createSubmitMethod("get"),
|
|
480
|
+
post: createSubmitMethod("post"),
|
|
481
|
+
put: createSubmitMethod("put"),
|
|
482
|
+
patch: createSubmitMethod("patch"),
|
|
483
|
+
delete: createSubmitMethod("delete"),
|
|
375
484
|
cancel() {
|
|
376
485
|
if (cancelToken) {
|
|
377
486
|
cancelToken.cancel();
|
|
378
487
|
}
|
|
379
488
|
},
|
|
380
489
|
dontRemember(...keys) {
|
|
381
|
-
|
|
382
|
-
return
|
|
490
|
+
setRememberExcludeKeys(keys);
|
|
491
|
+
return form;
|
|
383
492
|
},
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
if (rememberExcludeKeys.length > 0) {
|
|
388
|
-
const filtered = { ...data2 };
|
|
389
|
-
rememberExcludeKeys.forEach((k) => delete filtered[k]);
|
|
390
|
-
return { data: filtered, errors: this.errors };
|
|
391
|
-
}
|
|
392
|
-
return { data: data2, errors: this.errors };
|
|
393
|
-
},
|
|
394
|
-
__restore(restored2) {
|
|
395
|
-
Object.assign(this, restored2.data);
|
|
396
|
-
this.setError(restored2.errors);
|
|
493
|
+
optimistic(callback) {
|
|
494
|
+
pendingOptimisticCallback = callback;
|
|
495
|
+
return form;
|
|
397
496
|
}
|
|
398
497
|
});
|
|
399
|
-
|
|
400
|
-
(0, import_vue.watch)(
|
|
401
|
-
typedForm,
|
|
402
|
-
(newValue) => {
|
|
403
|
-
typedForm.isDirty = !(0, import_lodash_es2.isEqual)(typedForm.data(), defaults);
|
|
404
|
-
const storedData = import_core2.router.restore(rememberKey);
|
|
405
|
-
const newData = (0, import_lodash_es2.cloneDeep)(newValue.__remember());
|
|
406
|
-
if (rememberKey && !(0, import_lodash_es2.isEqual)(storedData, newData)) {
|
|
407
|
-
import_core2.router.remember(newData, rememberKey);
|
|
408
|
-
}
|
|
409
|
-
},
|
|
410
|
-
{ immediate: true, deep: true }
|
|
411
|
-
);
|
|
412
|
-
return precognitionEndpoint ? typedForm.withPrecognition(precognitionEndpoint) : typedForm;
|
|
498
|
+
return getPrecognitionEndpoint() ? form : form;
|
|
413
499
|
}
|
|
414
500
|
|
|
415
501
|
// src/app.ts
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
502
|
+
function isComponent(value) {
|
|
503
|
+
if (!value) {
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
if (typeof value === "function") {
|
|
507
|
+
return true;
|
|
508
|
+
}
|
|
509
|
+
if (typeof value === "object") {
|
|
510
|
+
const obj = value;
|
|
511
|
+
return typeof obj.render === "function" || typeof obj.setup === "function" || typeof obj.template === "string" || "__file" in obj || "__name" in obj;
|
|
512
|
+
}
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
function isRenderFunction(value) {
|
|
516
|
+
if (typeof value !== "function") {
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
519
|
+
const fn = value;
|
|
520
|
+
return fn.length === 2 && typeof fn.prototype === "undefined";
|
|
521
|
+
}
|
|
522
|
+
var component = ref2(void 0);
|
|
523
|
+
var page = ref2();
|
|
524
|
+
var pageAccessor = null;
|
|
525
|
+
var layout = shallowRef(null);
|
|
526
|
+
var key = ref2(void 0);
|
|
420
527
|
var headManager;
|
|
421
|
-
var App = (
|
|
528
|
+
var App = defineComponent2({
|
|
422
529
|
name: "Inertia",
|
|
423
530
|
props: {
|
|
424
531
|
initialPage: {
|
|
@@ -443,21 +550,35 @@ var App = (0, import_vue2.defineComponent)({
|
|
|
443
550
|
required: false,
|
|
444
551
|
default: () => () => {
|
|
445
552
|
}
|
|
553
|
+
},
|
|
554
|
+
defaultLayout: {
|
|
555
|
+
type: Function,
|
|
556
|
+
required: false
|
|
446
557
|
}
|
|
447
558
|
},
|
|
448
|
-
setup({
|
|
449
|
-
|
|
559
|
+
setup({
|
|
560
|
+
initialPage,
|
|
561
|
+
initialComponent,
|
|
562
|
+
resolveComponent,
|
|
563
|
+
titleCallback,
|
|
564
|
+
onHeadUpdate,
|
|
565
|
+
defaultLayout
|
|
566
|
+
}) {
|
|
567
|
+
component.value = initialComponent ? markRaw(initialComponent) : void 0;
|
|
450
568
|
page.value = { ...initialPage, flash: initialPage.flash ?? {} };
|
|
451
569
|
key.value = void 0;
|
|
452
570
|
const isServer = typeof window === "undefined";
|
|
453
|
-
headManager =
|
|
571
|
+
headManager = createHeadManager(isServer, titleCallback || ((title) => title), onHeadUpdate || (() => {
|
|
454
572
|
}));
|
|
455
573
|
if (!isServer) {
|
|
456
|
-
|
|
574
|
+
router4.init({
|
|
457
575
|
initialPage,
|
|
458
576
|
resolveComponent,
|
|
459
577
|
swapComponent: async (options) => {
|
|
460
|
-
|
|
578
|
+
if (!options.preserveState) {
|
|
579
|
+
resetLayoutProps();
|
|
580
|
+
}
|
|
581
|
+
component.value = markRaw(options.component);
|
|
461
582
|
page.value = options.page;
|
|
462
583
|
key.value = options.preserveState ? key.value : Date.now();
|
|
463
584
|
},
|
|
@@ -465,12 +586,12 @@ var App = (0, import_vue2.defineComponent)({
|
|
|
465
586
|
page.value = { ...page.value, flash };
|
|
466
587
|
}
|
|
467
588
|
});
|
|
468
|
-
|
|
589
|
+
router4.on("navigate", () => headManager.forceUpdate());
|
|
469
590
|
}
|
|
470
591
|
return () => {
|
|
471
592
|
if (component.value) {
|
|
472
593
|
component.value.inheritAttrs = !!component.value.inheritAttrs;
|
|
473
|
-
const child =
|
|
594
|
+
const child = h(component.value, {
|
|
474
595
|
...page.value.props,
|
|
475
596
|
key: key.value
|
|
476
597
|
});
|
|
@@ -478,14 +599,27 @@ var App = (0, import_vue2.defineComponent)({
|
|
|
478
599
|
component.value.layout = layout.value;
|
|
479
600
|
layout.value = null;
|
|
480
601
|
}
|
|
481
|
-
if (component.value.layout) {
|
|
482
|
-
|
|
483
|
-
|
|
602
|
+
if (component.value.layout && isRenderFunction(component.value.layout)) {
|
|
603
|
+
return component.value.layout(h, child);
|
|
604
|
+
}
|
|
605
|
+
const effectiveLayout = component.value.layout ?? defaultLayout?.(page.value.component, page.value);
|
|
606
|
+
if (effectiveLayout) {
|
|
607
|
+
const layouts = normalizeLayouts(
|
|
608
|
+
effectiveLayout,
|
|
609
|
+
isComponent,
|
|
610
|
+
component.value.layout ? isRenderFunction : void 0
|
|
611
|
+
);
|
|
612
|
+
if (layouts.length > 0) {
|
|
613
|
+
return layouts.reduceRight((childNode, layout2) => {
|
|
614
|
+
const layoutComponent = layout2.component;
|
|
615
|
+
layoutComponent.inheritAttrs = !!layoutComponent.inheritAttrs;
|
|
616
|
+
return h(
|
|
617
|
+
LayoutProvider,
|
|
618
|
+
{ layoutName: layout2.name },
|
|
619
|
+
() => h(layoutComponent, { ...page.value.props, ...layout2.props }, () => childNode)
|
|
620
|
+
);
|
|
621
|
+
}, child);
|
|
484
622
|
}
|
|
485
|
-
return (Array.isArray(component.value.layout) ? component.value.layout : [component.value.layout]).concat(child).reverse().reduce((child2, layout2) => {
|
|
486
|
-
layout2.inheritAttrs = !!layout2.inheritAttrs;
|
|
487
|
-
return (0, import_vue2.h)(layout2, { ...page.value.props }, () => child2);
|
|
488
|
-
});
|
|
489
623
|
}
|
|
490
624
|
return child;
|
|
491
625
|
}
|
|
@@ -495,34 +629,43 @@ var App = (0, import_vue2.defineComponent)({
|
|
|
495
629
|
var app_default = App;
|
|
496
630
|
var plugin = {
|
|
497
631
|
install(app) {
|
|
498
|
-
|
|
499
|
-
Object.defineProperty(app.config.globalProperties, "$inertia", { get: () =>
|
|
632
|
+
router4.form = useForm;
|
|
633
|
+
Object.defineProperty(app.config.globalProperties, "$inertia", { get: () => router4 });
|
|
500
634
|
Object.defineProperty(app.config.globalProperties, "$page", { get: () => page.value });
|
|
501
635
|
Object.defineProperty(app.config.globalProperties, "$headManager", { get: () => headManager });
|
|
502
636
|
app.mixin(remember_default);
|
|
503
637
|
}
|
|
504
638
|
};
|
|
505
639
|
function usePage() {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
640
|
+
if (!pageAccessor) {
|
|
641
|
+
pageAccessor = reactive2({
|
|
642
|
+
props: computed2(() => page.value?.props),
|
|
643
|
+
url: computed2(() => page.value?.url),
|
|
644
|
+
component: computed2(() => page.value?.component),
|
|
645
|
+
version: computed2(() => page.value?.version),
|
|
646
|
+
clearHistory: computed2(() => page.value?.clearHistory),
|
|
647
|
+
deferredProps: computed2(() => page.value?.deferredProps),
|
|
648
|
+
mergeProps: computed2(() => page.value?.mergeProps),
|
|
649
|
+
prependProps: computed2(() => page.value?.prependProps),
|
|
650
|
+
deepMergeProps: computed2(() => page.value?.deepMergeProps),
|
|
651
|
+
matchPropsOn: computed2(() => page.value?.matchPropsOn),
|
|
652
|
+
rememberedState: computed2(() => page.value?.rememberedState),
|
|
653
|
+
encryptHistory: computed2(() => page.value?.encryptHistory),
|
|
654
|
+
flash: computed2(() => page.value?.flash)
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
return pageAccessor;
|
|
521
658
|
}
|
|
522
659
|
|
|
523
660
|
// src/createInertiaApp.ts
|
|
524
|
-
|
|
525
|
-
|
|
661
|
+
import {
|
|
662
|
+
buildSSRBody,
|
|
663
|
+
getInitialPageFromDOM,
|
|
664
|
+
http as httpModule,
|
|
665
|
+
router as router5,
|
|
666
|
+
setupProgress
|
|
667
|
+
} from "@inertiajs/core";
|
|
668
|
+
import { createApp, createSSRApp, h as h2 } from "vue";
|
|
526
669
|
async function createInertiaApp({
|
|
527
670
|
id = "app",
|
|
528
671
|
resolve,
|
|
@@ -531,78 +674,111 @@ async function createInertiaApp({
|
|
|
531
674
|
progress: progress2 = {},
|
|
532
675
|
page: page2,
|
|
533
676
|
render,
|
|
534
|
-
defaults = {}
|
|
535
|
-
|
|
677
|
+
defaults = {},
|
|
678
|
+
http: http3,
|
|
679
|
+
layout: layout2
|
|
680
|
+
} = {}) {
|
|
536
681
|
config.replace(defaults);
|
|
682
|
+
if (http3) {
|
|
683
|
+
httpModule.setClient(http3);
|
|
684
|
+
}
|
|
537
685
|
const isServer = typeof window === "undefined";
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
686
|
+
const resolveComponent = (name, page3) => Promise.resolve(resolve(name, page3)).then((module) => module.default || module);
|
|
687
|
+
if (isServer && !page2 && !render) {
|
|
688
|
+
return async (page3, renderToString) => {
|
|
689
|
+
let head2 = [];
|
|
690
|
+
const initialComponent = await resolveComponent(page3.component, page3);
|
|
691
|
+
const props = {
|
|
692
|
+
initialPage: page3,
|
|
693
|
+
initialComponent,
|
|
694
|
+
resolveComponent,
|
|
695
|
+
titleCallback: title,
|
|
696
|
+
onHeadUpdate: (elements) => head2 = elements,
|
|
697
|
+
defaultLayout: layout2
|
|
698
|
+
};
|
|
699
|
+
let vueApp2;
|
|
700
|
+
if (setup) {
|
|
701
|
+
vueApp2 = setup({
|
|
702
|
+
el: null,
|
|
703
|
+
App: app_default,
|
|
704
|
+
props,
|
|
705
|
+
plugin
|
|
706
|
+
});
|
|
707
|
+
} else {
|
|
708
|
+
vueApp2 = createSSRApp({ render: () => h2(app_default, props) });
|
|
709
|
+
vueApp2.use(plugin);
|
|
710
|
+
}
|
|
711
|
+
const html = await renderToString(vueApp2);
|
|
712
|
+
const body = buildSSRBody(id, page3, html);
|
|
713
|
+
return { head: head2, body };
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
const initialPage = page2 || getInitialPageFromDOM(id);
|
|
541
717
|
let head = [];
|
|
542
718
|
const vueApp = await Promise.all([
|
|
543
|
-
resolveComponent(initialPage.component),
|
|
544
|
-
|
|
719
|
+
resolveComponent(initialPage.component, initialPage),
|
|
720
|
+
router5.decryptHistory().catch(() => {
|
|
545
721
|
})
|
|
546
722
|
]).then(([initialComponent]) => {
|
|
547
723
|
const props = {
|
|
548
724
|
initialPage,
|
|
549
725
|
initialComponent,
|
|
550
726
|
resolveComponent,
|
|
551
|
-
titleCallback: title
|
|
727
|
+
titleCallback: title,
|
|
728
|
+
onHeadUpdate: isServer ? (elements) => head = elements : void 0,
|
|
729
|
+
defaultLayout: layout2
|
|
552
730
|
};
|
|
553
731
|
if (isServer) {
|
|
554
|
-
|
|
555
|
-
return ssrSetup({
|
|
732
|
+
return setup({
|
|
556
733
|
el: null,
|
|
557
734
|
App: app_default,
|
|
558
|
-
props
|
|
735
|
+
props,
|
|
559
736
|
plugin
|
|
560
737
|
});
|
|
561
738
|
}
|
|
562
|
-
const
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
739
|
+
const el = document.getElementById(id);
|
|
740
|
+
if (setup) {
|
|
741
|
+
return setup({
|
|
742
|
+
el,
|
|
743
|
+
App: app_default,
|
|
744
|
+
props,
|
|
745
|
+
plugin
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
if (el.hasAttribute("data-server-rendered")) {
|
|
749
|
+
const app = createSSRApp({ render: () => h2(app_default, props) });
|
|
750
|
+
app.use(plugin);
|
|
751
|
+
app.mount(el);
|
|
752
|
+
} else {
|
|
753
|
+
const app = createApp({ render: () => h2(app_default, props) });
|
|
754
|
+
app.use(plugin);
|
|
755
|
+
app.mount(el);
|
|
756
|
+
}
|
|
569
757
|
});
|
|
570
758
|
if (!isServer && progress2) {
|
|
571
|
-
|
|
759
|
+
setupProgress(progress2);
|
|
572
760
|
}
|
|
573
|
-
if (isServer && render) {
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
return (0, import_vue3.h)("div", {
|
|
577
|
-
id,
|
|
578
|
-
"data-page": JSON.stringify(initialPage),
|
|
579
|
-
innerHTML: vueApp ? render(vueApp) : ""
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
return [
|
|
583
|
-
(0, import_vue3.h)("script", {
|
|
584
|
-
"data-page": id,
|
|
585
|
-
type: "application/json",
|
|
586
|
-
innerHTML: JSON.stringify(initialPage).replace(/\//g, "\\/")
|
|
587
|
-
}),
|
|
588
|
-
(0, import_vue3.h)("div", {
|
|
589
|
-
id,
|
|
590
|
-
innerHTML: vueApp ? render(vueApp) : ""
|
|
591
|
-
})
|
|
592
|
-
];
|
|
593
|
-
};
|
|
594
|
-
const body = await render(
|
|
595
|
-
(0, import_vue3.createSSRApp)({
|
|
596
|
-
render: () => element()
|
|
597
|
-
})
|
|
598
|
-
);
|
|
761
|
+
if (isServer && render && vueApp) {
|
|
762
|
+
const html = await render(vueApp);
|
|
763
|
+
const body = buildSSRBody(id, initialPage, html);
|
|
599
764
|
return { head, body };
|
|
600
765
|
}
|
|
601
766
|
}
|
|
602
767
|
|
|
603
768
|
// src/deferred.ts
|
|
604
|
-
|
|
605
|
-
|
|
769
|
+
import { isSameUrlWithoutQueryOrHash, router as router6 } from "@inertiajs/core";
|
|
770
|
+
import { get as get2 } from "lodash-es";
|
|
771
|
+
import { defineComponent as defineComponent3, onMounted, onUnmounted, ref as ref3 } from "vue";
|
|
772
|
+
var keysAreBeingReloaded = (only, except, keys) => {
|
|
773
|
+
if (only.length === 0 && except.length === 0) {
|
|
774
|
+
return true;
|
|
775
|
+
}
|
|
776
|
+
if (only.length > 0) {
|
|
777
|
+
return keys.some((key2) => only.includes(key2));
|
|
778
|
+
}
|
|
779
|
+
return keys.some((key2) => !except.includes(key2));
|
|
780
|
+
};
|
|
781
|
+
var deferred_default = defineComponent3({
|
|
606
782
|
name: "Deferred",
|
|
607
783
|
props: {
|
|
608
784
|
data: {
|
|
@@ -610,22 +786,71 @@ var deferred_default = (0, import_vue4.defineComponent)({
|
|
|
610
786
|
required: true
|
|
611
787
|
}
|
|
612
788
|
},
|
|
789
|
+
slots: Object,
|
|
790
|
+
setup(props, { slots }) {
|
|
791
|
+
const reloading = ref3(false);
|
|
792
|
+
const activeReloads = /* @__PURE__ */ new Set();
|
|
793
|
+
let removeStartListener = null;
|
|
794
|
+
let removeFinishListener = null;
|
|
795
|
+
onMounted(() => {
|
|
796
|
+
const keys = Array.isArray(props.data) ? props.data : [props.data];
|
|
797
|
+
removeStartListener = router6.on("start", (e) => {
|
|
798
|
+
const visit = e.detail.visit;
|
|
799
|
+
if (visit.preserveState === true && isSameUrlWithoutQueryOrHash(visit.url, window.location) && keysAreBeingReloaded(visit.only, visit.except, keys)) {
|
|
800
|
+
activeReloads.add(visit);
|
|
801
|
+
reloading.value = true;
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
removeFinishListener = router6.on("finish", (e) => {
|
|
805
|
+
const visit = e.detail.visit;
|
|
806
|
+
if (activeReloads.has(visit)) {
|
|
807
|
+
activeReloads.delete(visit);
|
|
808
|
+
reloading.value = activeReloads.size > 0;
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
});
|
|
812
|
+
onUnmounted(() => {
|
|
813
|
+
removeStartListener?.();
|
|
814
|
+
removeFinishListener?.();
|
|
815
|
+
activeReloads.clear();
|
|
816
|
+
});
|
|
817
|
+
return { reloading, slots };
|
|
818
|
+
},
|
|
613
819
|
render() {
|
|
614
820
|
const keys = Array.isArray(this.$props.data) ? this.$props.data : [this.$props.data];
|
|
615
821
|
if (!this.$slots.fallback) {
|
|
616
822
|
throw new Error("`<Deferred>` requires a `<template #fallback>` slot");
|
|
617
823
|
}
|
|
618
|
-
return keys.every((key2) => this.$page.props
|
|
824
|
+
return keys.every((key2) => get2(this.$page.props, key2) !== void 0) ? this.$slots.default?.({ reloading: this.reloading }) : this.$slots.fallback({});
|
|
619
825
|
}
|
|
620
826
|
});
|
|
621
827
|
|
|
622
828
|
// src/form.ts
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
829
|
+
import {
|
|
830
|
+
config as config2,
|
|
831
|
+
FormComponentResetSymbol,
|
|
832
|
+
formDataToObject,
|
|
833
|
+
isUrlMethodPair,
|
|
834
|
+
mergeDataIntoQueryString,
|
|
835
|
+
resetFormFields,
|
|
836
|
+
resolveUrlMethodPairComponent,
|
|
837
|
+
UseFormUtils as UseFormUtils3
|
|
838
|
+
} from "@inertiajs/core";
|
|
839
|
+
import { isEqual as isEqual2 } from "lodash-es";
|
|
840
|
+
import {
|
|
841
|
+
computed as computed3,
|
|
842
|
+
defineComponent as defineComponent4,
|
|
843
|
+
h as h3,
|
|
844
|
+
inject as inject2,
|
|
845
|
+
onBeforeUnmount,
|
|
846
|
+
onMounted as onMounted2,
|
|
847
|
+
provide as provide2,
|
|
848
|
+
ref as ref4,
|
|
849
|
+
watch as watch2
|
|
850
|
+
} from "vue";
|
|
626
851
|
var noop = () => void 0;
|
|
627
852
|
var FormContextKey = /* @__PURE__ */ Symbol("InertiaFormContext");
|
|
628
|
-
var Form = (
|
|
853
|
+
var Form = defineComponent4({
|
|
629
854
|
name: "Form",
|
|
630
855
|
slots: Object,
|
|
631
856
|
props: {
|
|
@@ -725,9 +950,21 @@ var Form = (0, import_vue5.defineComponent)({
|
|
|
725
950
|
type: Number,
|
|
726
951
|
default: 1500
|
|
727
952
|
},
|
|
953
|
+
optimistic: {
|
|
954
|
+
type: Function,
|
|
955
|
+
default: void 0
|
|
956
|
+
},
|
|
728
957
|
withAllErrors: {
|
|
729
958
|
type: Boolean,
|
|
730
959
|
default: null
|
|
960
|
+
},
|
|
961
|
+
component: {
|
|
962
|
+
type: String,
|
|
963
|
+
default: null
|
|
964
|
+
},
|
|
965
|
+
instant: {
|
|
966
|
+
type: Boolean,
|
|
967
|
+
default: false
|
|
731
968
|
}
|
|
732
969
|
},
|
|
733
970
|
setup(props, { slots, attrs, expose }) {
|
|
@@ -742,42 +979,51 @@ var Form = (0, import_vue5.defineComponent)({
|
|
|
742
979
|
if (props.validateFiles) {
|
|
743
980
|
form.validateFiles();
|
|
744
981
|
}
|
|
745
|
-
if (props.withAllErrors ??
|
|
982
|
+
if (props.withAllErrors ?? config2.get("form.withAllErrors")) {
|
|
746
983
|
form.withAllErrors();
|
|
747
984
|
}
|
|
748
|
-
const formElement = (
|
|
749
|
-
const method = (
|
|
750
|
-
() =>
|
|
985
|
+
const formElement = ref4();
|
|
986
|
+
const method = computed3(
|
|
987
|
+
() => isUrlMethodPair(props.action) ? props.action.method : props.method.toLowerCase()
|
|
751
988
|
);
|
|
752
|
-
const
|
|
753
|
-
|
|
989
|
+
const resolvedComponent = computed3(() => {
|
|
990
|
+
if (props.component) {
|
|
991
|
+
return props.component;
|
|
992
|
+
}
|
|
993
|
+
if (props.instant && isUrlMethodPair(props.action)) {
|
|
994
|
+
return resolveUrlMethodPairComponent(props.action);
|
|
995
|
+
}
|
|
996
|
+
return null;
|
|
997
|
+
});
|
|
998
|
+
const isDirty = ref4(false);
|
|
999
|
+
const defaultData = ref4(new FormData());
|
|
754
1000
|
const onFormUpdate = (event) => {
|
|
755
|
-
if (event.type === "reset" && event.detail?.[
|
|
1001
|
+
if (event.type === "reset" && event.detail?.[FormComponentResetSymbol]) {
|
|
756
1002
|
event.preventDefault();
|
|
757
1003
|
}
|
|
758
|
-
isDirty.value = event.type === "reset" ? false : !(
|
|
1004
|
+
isDirty.value = event.type === "reset" ? false : !isEqual2(getData(), formDataToObject(defaultData.value));
|
|
759
1005
|
};
|
|
760
1006
|
const formEvents = ["input", "change", "reset"];
|
|
761
|
-
(
|
|
1007
|
+
onMounted2(() => {
|
|
762
1008
|
defaultData.value = getFormData();
|
|
763
1009
|
form.defaults(getData());
|
|
764
1010
|
formEvents.forEach((e) => formElement.value.addEventListener(e, onFormUpdate));
|
|
765
1011
|
});
|
|
766
|
-
(
|
|
1012
|
+
watch2(
|
|
767
1013
|
() => props.validateFiles,
|
|
768
1014
|
(value) => value ? form.validateFiles() : form.withoutFileValidation()
|
|
769
1015
|
);
|
|
770
|
-
(
|
|
1016
|
+
watch2(
|
|
771
1017
|
() => props.validationTimeout,
|
|
772
1018
|
(value) => form.setValidationTimeout(value)
|
|
773
1019
|
);
|
|
774
|
-
|
|
1020
|
+
onBeforeUnmount(() => formEvents.forEach((e) => formElement.value?.removeEventListener(e, onFormUpdate)));
|
|
775
1021
|
const getFormData = (submitter) => new FormData(formElement.value, submitter);
|
|
776
|
-
const getData = (submitter) =>
|
|
1022
|
+
const getData = (submitter) => formDataToObject(getFormData(submitter));
|
|
777
1023
|
const getUrlAndData = (submitter) => {
|
|
778
|
-
return
|
|
1024
|
+
return mergeDataIntoQueryString(
|
|
779
1025
|
method.value,
|
|
780
|
-
|
|
1026
|
+
isUrlMethodPair(props.action) ? props.action.url : props.action,
|
|
781
1027
|
getData(submitter),
|
|
782
1028
|
props.queryStringArrayFormat
|
|
783
1029
|
);
|
|
@@ -805,6 +1051,8 @@ var Form = (0, import_vue5.defineComponent)({
|
|
|
805
1051
|
errorBag: props.errorBag,
|
|
806
1052
|
showProgress: props.showProgress,
|
|
807
1053
|
invalidateCacheTags: props.invalidateCacheTags,
|
|
1054
|
+
component: resolvedComponent.value,
|
|
1055
|
+
optimistic: props.optimistic ? (pageProps) => props.optimistic(pageProps, data) : void 0,
|
|
808
1056
|
onCancelToken: props.onCancelToken,
|
|
809
1057
|
onBefore: props.onBefore,
|
|
810
1058
|
onStart: props.onStart,
|
|
@@ -829,7 +1077,7 @@ var Form = (0, import_vue5.defineComponent)({
|
|
|
829
1077
|
form.transform(getTransformedData);
|
|
830
1078
|
};
|
|
831
1079
|
const reset = (...fields) => {
|
|
832
|
-
|
|
1080
|
+
resetFormFields(formElement.value, defaultData.value, fields);
|
|
833
1081
|
form.reset(...fields);
|
|
834
1082
|
};
|
|
835
1083
|
const clearErrors = (...fields) => {
|
|
@@ -881,18 +1129,18 @@ var Form = (0, import_vue5.defineComponent)({
|
|
|
881
1129
|
valid: form.valid,
|
|
882
1130
|
invalid: form.invalid,
|
|
883
1131
|
touched: form.touched,
|
|
884
|
-
validate: (field, config3) => form.validate(...
|
|
1132
|
+
validate: (field, config3) => form.validate(...UseFormUtils3.mergeHeadersForValidation(field, config3, props.headers)),
|
|
885
1133
|
validator: () => form.validator()
|
|
886
1134
|
};
|
|
887
1135
|
expose(exposed);
|
|
888
|
-
(
|
|
1136
|
+
provide2(FormContextKey, exposed);
|
|
889
1137
|
return () => {
|
|
890
|
-
return (
|
|
1138
|
+
return h3(
|
|
891
1139
|
"form",
|
|
892
1140
|
{
|
|
893
1141
|
...attrs,
|
|
894
1142
|
ref: formElement,
|
|
895
|
-
action:
|
|
1143
|
+
action: isUrlMethodPair(props.action) ? props.action.url : props.action,
|
|
896
1144
|
method: method.value,
|
|
897
1145
|
onSubmit: (event) => {
|
|
898
1146
|
event.preventDefault();
|
|
@@ -906,14 +1154,17 @@ var Form = (0, import_vue5.defineComponent)({
|
|
|
906
1154
|
}
|
|
907
1155
|
});
|
|
908
1156
|
function useFormContext() {
|
|
909
|
-
return (
|
|
1157
|
+
return inject2(FormContextKey);
|
|
1158
|
+
}
|
|
1159
|
+
function createForm() {
|
|
1160
|
+
return Form;
|
|
910
1161
|
}
|
|
911
1162
|
var form_default = Form;
|
|
912
1163
|
|
|
913
1164
|
// src/head.ts
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
var Head = (
|
|
1165
|
+
import { escape } from "lodash-es";
|
|
1166
|
+
import { defineComponent as defineComponent5 } from "vue";
|
|
1167
|
+
var Head = defineComponent5({
|
|
917
1168
|
props: {
|
|
918
1169
|
title: {
|
|
919
1170
|
type: String,
|
|
@@ -950,7 +1201,7 @@ var Head = (0, import_vue6.defineComponent)({
|
|
|
950
1201
|
},
|
|
951
1202
|
renderTagStart(node) {
|
|
952
1203
|
node.props = node.props || {};
|
|
953
|
-
node.props[
|
|
1204
|
+
node.props["data-inertia"] = node.props["head-key"] !== void 0 ? node.props["head-key"] : "";
|
|
954
1205
|
const attrs = Object.keys(node.props).reduce((carry, name) => {
|
|
955
1206
|
const value = String(node.props[name]);
|
|
956
1207
|
if (["key", "head-key"].includes(name)) {
|
|
@@ -958,7 +1209,7 @@ var Head = (0, import_vue6.defineComponent)({
|
|
|
958
1209
|
} else if (value === "") {
|
|
959
1210
|
return carry + ` ${name}`;
|
|
960
1211
|
} else {
|
|
961
|
-
return carry + ` ${name}="${
|
|
1212
|
+
return carry + ` ${name}="${escape(value)}"`;
|
|
962
1213
|
}
|
|
963
1214
|
}, "");
|
|
964
1215
|
return `<${String(node.type)}${attrs}>`;
|
|
@@ -1009,7 +1260,7 @@ var Head = (0, import_vue6.defineComponent)({
|
|
|
1009
1260
|
},
|
|
1010
1261
|
addTitleElement(elements) {
|
|
1011
1262
|
if (this.title && !elements.find((tag) => tag.startsWith("<title"))) {
|
|
1012
|
-
elements.push(`<title
|
|
1263
|
+
elements.push(`<title data-inertia="">${this.title}</title>`);
|
|
1013
1264
|
}
|
|
1014
1265
|
return elements;
|
|
1015
1266
|
},
|
|
@@ -1041,8 +1292,11 @@ var Head = (0, import_vue6.defineComponent)({
|
|
|
1041
1292
|
var head_default = Head;
|
|
1042
1293
|
|
|
1043
1294
|
// src/infiniteScroll.ts
|
|
1044
|
-
|
|
1045
|
-
|
|
1295
|
+
import {
|
|
1296
|
+
getScrollableParent,
|
|
1297
|
+
useInfiniteScroll
|
|
1298
|
+
} from "@inertiajs/core";
|
|
1299
|
+
import { computed as computed4, defineComponent as defineComponent6, Fragment, h as h4, onMounted as onMounted3, onUnmounted as onUnmounted2, ref as ref5, watch as watch3 } from "vue";
|
|
1046
1300
|
var resolveHTMLElement = (value, fallback) => {
|
|
1047
1301
|
if (!value) {
|
|
1048
1302
|
return fallback;
|
|
@@ -1055,7 +1309,7 @@ var resolveHTMLElement = (value, fallback) => {
|
|
|
1055
1309
|
}
|
|
1056
1310
|
return fallback;
|
|
1057
1311
|
};
|
|
1058
|
-
var InfiniteScroll = (
|
|
1312
|
+
var InfiniteScroll = defineComponent6({
|
|
1059
1313
|
name: "InfiniteScroll",
|
|
1060
1314
|
slots: Object,
|
|
1061
1315
|
props: {
|
|
@@ -1110,26 +1364,30 @@ var InfiniteScroll = (0, import_vue7.defineComponent)({
|
|
|
1110
1364
|
endElement: {
|
|
1111
1365
|
type: [String, Function, Object],
|
|
1112
1366
|
default: null
|
|
1367
|
+
},
|
|
1368
|
+
params: {
|
|
1369
|
+
type: Object,
|
|
1370
|
+
default: () => ({})
|
|
1113
1371
|
}
|
|
1114
1372
|
},
|
|
1115
1373
|
inheritAttrs: false,
|
|
1116
1374
|
setup(props, { slots, attrs, expose }) {
|
|
1117
|
-
const itemsElementRef = (
|
|
1118
|
-
const startElementRef = (
|
|
1119
|
-
const endElementRef = (
|
|
1120
|
-
const itemsElement = (
|
|
1375
|
+
const itemsElementRef = ref5(null);
|
|
1376
|
+
const startElementRef = ref5(null);
|
|
1377
|
+
const endElementRef = ref5(null);
|
|
1378
|
+
const itemsElement = computed4(
|
|
1121
1379
|
() => resolveHTMLElement(props.itemsElement, itemsElementRef.value)
|
|
1122
1380
|
);
|
|
1123
|
-
const scrollableParent = (
|
|
1124
|
-
const startElement = (
|
|
1381
|
+
const scrollableParent = computed4(() => getScrollableParent(itemsElement.value));
|
|
1382
|
+
const startElement = computed4(
|
|
1125
1383
|
() => resolveHTMLElement(props.startElement, startElementRef.value)
|
|
1126
1384
|
);
|
|
1127
|
-
const endElement = (
|
|
1128
|
-
const loadingPrevious = (
|
|
1129
|
-
const loadingNext = (
|
|
1130
|
-
const requestCount = (0
|
|
1131
|
-
const hasPreviousPage = (
|
|
1132
|
-
const hasNextPage = (
|
|
1385
|
+
const endElement = computed4(() => resolveHTMLElement(props.endElement, endElementRef.value));
|
|
1386
|
+
const loadingPrevious = ref5(false);
|
|
1387
|
+
const loadingNext = ref5(false);
|
|
1388
|
+
const requestCount = ref5(0);
|
|
1389
|
+
const hasPreviousPage = ref5(false);
|
|
1390
|
+
const hasNextPage = ref5(false);
|
|
1133
1391
|
const syncStateFromDataManager = () => {
|
|
1134
1392
|
requestCount.value = dataManager.getRequestCount();
|
|
1135
1393
|
hasPreviousPage.value = dataManager.hasPrevious();
|
|
@@ -1139,13 +1397,14 @@ var InfiniteScroll = (0, import_vue7.defineComponent)({
|
|
|
1139
1397
|
dataManager,
|
|
1140
1398
|
elementManager,
|
|
1141
1399
|
flush: flushInfiniteScroll
|
|
1142
|
-
} =
|
|
1400
|
+
} = useInfiniteScroll({
|
|
1143
1401
|
// Data
|
|
1144
1402
|
getPropName: () => props.data,
|
|
1145
1403
|
inReverseMode: () => props.reverse,
|
|
1146
1404
|
shouldFetchNext: () => !props.onlyPrevious,
|
|
1147
1405
|
shouldFetchPrevious: () => !props.onlyNext,
|
|
1148
1406
|
shouldPreserveUrl: () => props.preserveUrl,
|
|
1407
|
+
getReloadOptions: () => props.params,
|
|
1149
1408
|
// Elements
|
|
1150
1409
|
getTriggerMargin: () => props.buffer,
|
|
1151
1410
|
getStartElement: () => startElement.value,
|
|
@@ -1166,8 +1425,8 @@ var InfiniteScroll = (0, import_vue7.defineComponent)({
|
|
|
1166
1425
|
onDataReset: syncStateFromDataManager
|
|
1167
1426
|
});
|
|
1168
1427
|
syncStateFromDataManager();
|
|
1169
|
-
const autoLoad = (
|
|
1170
|
-
const manualMode = (
|
|
1428
|
+
const autoLoad = computed4(() => !manualMode.value);
|
|
1429
|
+
const manualMode = computed4(
|
|
1171
1430
|
() => props.manual || props.manualAfter > 0 && requestCount.value >= props.manualAfter
|
|
1172
1431
|
);
|
|
1173
1432
|
const scrollToBottom = () => {
|
|
@@ -1183,7 +1442,7 @@ var InfiniteScroll = (0, import_vue7.defineComponent)({
|
|
|
1183
1442
|
});
|
|
1184
1443
|
}
|
|
1185
1444
|
};
|
|
1186
|
-
(
|
|
1445
|
+
onMounted3(() => {
|
|
1187
1446
|
elementManager.setupObservers();
|
|
1188
1447
|
elementManager.processServerLoadedElements(dataManager.getLastLoadedPage());
|
|
1189
1448
|
const shouldAutoScroll = props.autoScroll !== void 0 ? props.autoScroll : props.reverse;
|
|
@@ -1194,8 +1453,8 @@ var InfiniteScroll = (0, import_vue7.defineComponent)({
|
|
|
1194
1453
|
elementManager.enableTriggers();
|
|
1195
1454
|
}
|
|
1196
1455
|
});
|
|
1197
|
-
(
|
|
1198
|
-
(
|
|
1456
|
+
onUnmounted2(flushInfiniteScroll);
|
|
1457
|
+
watch3(
|
|
1199
1458
|
() => [autoLoad.value, props.onlyNext, props.onlyPrevious],
|
|
1200
1459
|
([enabled]) => {
|
|
1201
1460
|
enabled ? elementManager.enableTriggers() : elementManager.disableTriggers();
|
|
@@ -1226,7 +1485,7 @@ var InfiniteScroll = (0, import_vue7.defineComponent)({
|
|
|
1226
1485
|
...sharedExposed
|
|
1227
1486
|
};
|
|
1228
1487
|
renderElements.push(
|
|
1229
|
-
(
|
|
1488
|
+
h4(
|
|
1230
1489
|
"div",
|
|
1231
1490
|
{ ref: startElementRef },
|
|
1232
1491
|
slots.previous ? slots.previous(exposedPrevious) : loadingPrevious.value ? slots.loading?.(exposedPrevious) : void 0
|
|
@@ -1234,7 +1493,7 @@ var InfiniteScroll = (0, import_vue7.defineComponent)({
|
|
|
1234
1493
|
);
|
|
1235
1494
|
}
|
|
1236
1495
|
renderElements.push(
|
|
1237
|
-
(
|
|
1496
|
+
h4(
|
|
1238
1497
|
props.as,
|
|
1239
1498
|
{ ...attrs, ref: itemsElementRef },
|
|
1240
1499
|
slots.default?.({
|
|
@@ -1255,25 +1514,32 @@ var InfiniteScroll = (0, import_vue7.defineComponent)({
|
|
|
1255
1514
|
...sharedExposed
|
|
1256
1515
|
};
|
|
1257
1516
|
renderElements.push(
|
|
1258
|
-
(
|
|
1517
|
+
h4(
|
|
1259
1518
|
"div",
|
|
1260
1519
|
{ ref: endElementRef },
|
|
1261
1520
|
slots.next ? slots.next(exposedNext) : loadingNext.value ? slots.loading?.(exposedNext) : void 0
|
|
1262
1521
|
)
|
|
1263
1522
|
);
|
|
1264
1523
|
}
|
|
1265
|
-
return (
|
|
1524
|
+
return h4(Fragment, {}, props.reverse ? [...renderElements].reverse() : renderElements);
|
|
1266
1525
|
};
|
|
1267
1526
|
}
|
|
1268
1527
|
});
|
|
1269
1528
|
var infiniteScroll_default = InfiniteScroll;
|
|
1270
1529
|
|
|
1271
1530
|
// src/link.ts
|
|
1272
|
-
|
|
1273
|
-
|
|
1531
|
+
import {
|
|
1532
|
+
isUrlMethodPair as isUrlMethodPair2,
|
|
1533
|
+
mergeDataIntoQueryString as mergeDataIntoQueryString2,
|
|
1534
|
+
resolveUrlMethodPairComponent as resolveUrlMethodPairComponent2,
|
|
1535
|
+
router as router7,
|
|
1536
|
+
shouldIntercept,
|
|
1537
|
+
shouldNavigate
|
|
1538
|
+
} from "@inertiajs/core";
|
|
1539
|
+
import { computed as computed5, defineComponent as defineComponent7, h as h5, onMounted as onMounted4, onUnmounted as onUnmounted3, ref as ref6 } from "vue";
|
|
1274
1540
|
var noop2 = () => {
|
|
1275
1541
|
};
|
|
1276
|
-
var Link = (
|
|
1542
|
+
var Link = defineComponent7({
|
|
1277
1543
|
name: "Link",
|
|
1278
1544
|
props: {
|
|
1279
1545
|
as: {
|
|
@@ -1383,12 +1649,24 @@ var Link = (0, import_vue8.defineComponent)({
|
|
|
1383
1649
|
viewTransition: {
|
|
1384
1650
|
type: [Boolean, Object],
|
|
1385
1651
|
default: false
|
|
1652
|
+
},
|
|
1653
|
+
component: {
|
|
1654
|
+
type: String,
|
|
1655
|
+
default: null
|
|
1656
|
+
},
|
|
1657
|
+
instant: {
|
|
1658
|
+
type: Boolean,
|
|
1659
|
+
default: false
|
|
1660
|
+
},
|
|
1661
|
+
pageProps: {
|
|
1662
|
+
type: [Object, Function],
|
|
1663
|
+
default: null
|
|
1386
1664
|
}
|
|
1387
1665
|
},
|
|
1388
1666
|
setup(props, { slots, attrs }) {
|
|
1389
|
-
const inFlightCount = (0
|
|
1390
|
-
const hoverTimeout = (
|
|
1391
|
-
const prefetchModes = (
|
|
1667
|
+
const inFlightCount = ref6(0);
|
|
1668
|
+
const hoverTimeout = ref6();
|
|
1669
|
+
const prefetchModes = computed5(() => {
|
|
1392
1670
|
if (props.prefetch === true) {
|
|
1393
1671
|
return ["hover"];
|
|
1394
1672
|
}
|
|
@@ -1400,7 +1678,7 @@ var Link = (0, import_vue8.defineComponent)({
|
|
|
1400
1678
|
}
|
|
1401
1679
|
return [props.prefetch];
|
|
1402
1680
|
});
|
|
1403
|
-
const cacheForValue = (
|
|
1681
|
+
const cacheForValue = computed5(() => {
|
|
1404
1682
|
if (props.cacheFor !== 0) {
|
|
1405
1683
|
return props.cacheFor;
|
|
1406
1684
|
}
|
|
@@ -1409,34 +1687,43 @@ var Link = (0, import_vue8.defineComponent)({
|
|
|
1409
1687
|
}
|
|
1410
1688
|
return config.get("prefetch.cacheFor");
|
|
1411
1689
|
});
|
|
1412
|
-
(
|
|
1690
|
+
onMounted4(() => {
|
|
1413
1691
|
if (prefetchModes.value.includes("mount")) {
|
|
1414
1692
|
prefetch();
|
|
1415
1693
|
}
|
|
1416
1694
|
});
|
|
1417
|
-
(
|
|
1695
|
+
onUnmounted3(() => {
|
|
1418
1696
|
clearTimeout(hoverTimeout.value);
|
|
1419
1697
|
});
|
|
1420
|
-
const method = (
|
|
1421
|
-
() => (
|
|
1698
|
+
const method = computed5(
|
|
1699
|
+
() => isUrlMethodPair2(props.href) ? props.href.method : (props.method ?? "get").toLowerCase()
|
|
1422
1700
|
);
|
|
1423
|
-
const as = (
|
|
1701
|
+
const as = computed5(() => {
|
|
1424
1702
|
if (typeof props.as !== "string" || props.as.toLowerCase() !== "a") {
|
|
1425
1703
|
return props.as;
|
|
1426
1704
|
}
|
|
1427
1705
|
return method.value !== "get" ? "button" : props.as.toLowerCase();
|
|
1428
1706
|
});
|
|
1429
|
-
const mergeDataArray = (
|
|
1430
|
-
() => (
|
|
1707
|
+
const mergeDataArray = computed5(
|
|
1708
|
+
() => mergeDataIntoQueryString2(
|
|
1431
1709
|
method.value,
|
|
1432
|
-
(
|
|
1710
|
+
isUrlMethodPair2(props.href) ? props.href.url : props.href,
|
|
1433
1711
|
props.data || {},
|
|
1434
1712
|
props.queryStringArrayFormat
|
|
1435
1713
|
)
|
|
1436
1714
|
);
|
|
1437
|
-
const href = (
|
|
1438
|
-
const data = (
|
|
1439
|
-
const
|
|
1715
|
+
const href = computed5(() => mergeDataArray.value[0]);
|
|
1716
|
+
const data = computed5(() => mergeDataArray.value[1]);
|
|
1717
|
+
const resolvedComponent = computed5(() => {
|
|
1718
|
+
if (props.component) {
|
|
1719
|
+
return props.component;
|
|
1720
|
+
}
|
|
1721
|
+
if (props.instant && isUrlMethodPair2(props.href)) {
|
|
1722
|
+
return resolveUrlMethodPairComponent2(props.href);
|
|
1723
|
+
}
|
|
1724
|
+
return null;
|
|
1725
|
+
});
|
|
1726
|
+
const elProps = computed5(() => {
|
|
1440
1727
|
if (as.value === "button") {
|
|
1441
1728
|
return { type: "button" };
|
|
1442
1729
|
}
|
|
@@ -1445,7 +1732,7 @@ var Link = (0, import_vue8.defineComponent)({
|
|
|
1445
1732
|
}
|
|
1446
1733
|
return {};
|
|
1447
1734
|
});
|
|
1448
|
-
const baseParams = (
|
|
1735
|
+
const baseParams = computed5(() => ({
|
|
1449
1736
|
data: data.value,
|
|
1450
1737
|
method: method.value,
|
|
1451
1738
|
replace: props.replace,
|
|
@@ -1455,9 +1742,11 @@ var Link = (0, import_vue8.defineComponent)({
|
|
|
1455
1742
|
only: props.only,
|
|
1456
1743
|
except: props.except,
|
|
1457
1744
|
headers: props.headers,
|
|
1458
|
-
async: props.async
|
|
1745
|
+
async: props.async,
|
|
1746
|
+
component: resolvedComponent.value,
|
|
1747
|
+
pageProps: props.pageProps
|
|
1459
1748
|
}));
|
|
1460
|
-
const visitParams = (
|
|
1749
|
+
const visitParams = computed5(() => ({
|
|
1461
1750
|
...baseParams.value,
|
|
1462
1751
|
viewTransition: props.viewTransition,
|
|
1463
1752
|
onCancelToken: props.onCancelToken,
|
|
@@ -1476,7 +1765,7 @@ var Link = (0, import_vue8.defineComponent)({
|
|
|
1476
1765
|
onError: props.onError
|
|
1477
1766
|
}));
|
|
1478
1767
|
const prefetch = () => {
|
|
1479
|
-
|
|
1768
|
+
router7.prefetch(
|
|
1480
1769
|
href.value,
|
|
1481
1770
|
{
|
|
1482
1771
|
...baseParams.value,
|
|
@@ -1491,9 +1780,9 @@ var Link = (0, import_vue8.defineComponent)({
|
|
|
1491
1780
|
};
|
|
1492
1781
|
const regularEvents = {
|
|
1493
1782
|
onClick: (event) => {
|
|
1494
|
-
if (
|
|
1783
|
+
if (shouldIntercept(event)) {
|
|
1495
1784
|
event.preventDefault();
|
|
1496
|
-
|
|
1785
|
+
router7.visit(href.value, visitParams.value);
|
|
1497
1786
|
}
|
|
1498
1787
|
}
|
|
1499
1788
|
};
|
|
@@ -1510,37 +1799,37 @@ var Link = (0, import_vue8.defineComponent)({
|
|
|
1510
1799
|
};
|
|
1511
1800
|
const prefetchClickEvents = {
|
|
1512
1801
|
onMousedown: (event) => {
|
|
1513
|
-
if (
|
|
1802
|
+
if (shouldIntercept(event)) {
|
|
1514
1803
|
event.preventDefault();
|
|
1515
1804
|
prefetch();
|
|
1516
1805
|
}
|
|
1517
1806
|
},
|
|
1518
1807
|
onKeydown: (event) => {
|
|
1519
|
-
if (
|
|
1808
|
+
if (shouldNavigate(event)) {
|
|
1520
1809
|
event.preventDefault();
|
|
1521
1810
|
prefetch();
|
|
1522
1811
|
}
|
|
1523
1812
|
},
|
|
1524
1813
|
onMouseup: (event) => {
|
|
1525
|
-
if (
|
|
1814
|
+
if (shouldIntercept(event)) {
|
|
1526
1815
|
event.preventDefault();
|
|
1527
|
-
|
|
1816
|
+
router7.visit(href.value, visitParams.value);
|
|
1528
1817
|
}
|
|
1529
1818
|
},
|
|
1530
1819
|
onKeyup: (event) => {
|
|
1531
|
-
if (
|
|
1820
|
+
if (shouldNavigate(event)) {
|
|
1532
1821
|
event.preventDefault();
|
|
1533
|
-
|
|
1822
|
+
router7.visit(href.value, visitParams.value);
|
|
1534
1823
|
}
|
|
1535
1824
|
},
|
|
1536
1825
|
onClick: (event) => {
|
|
1537
|
-
if (
|
|
1826
|
+
if (shouldIntercept(event)) {
|
|
1538
1827
|
event.preventDefault();
|
|
1539
1828
|
}
|
|
1540
1829
|
}
|
|
1541
1830
|
};
|
|
1542
1831
|
return () => {
|
|
1543
|
-
return (
|
|
1832
|
+
return h5(
|
|
1544
1833
|
as.value,
|
|
1545
1834
|
{
|
|
1546
1835
|
...attrs,
|
|
@@ -1563,23 +1852,199 @@ var Link = (0, import_vue8.defineComponent)({
|
|
|
1563
1852
|
});
|
|
1564
1853
|
var link_default = Link;
|
|
1565
1854
|
|
|
1855
|
+
// src/useHttp.ts
|
|
1856
|
+
import {
|
|
1857
|
+
hasFiles,
|
|
1858
|
+
http,
|
|
1859
|
+
HttpCancelledError,
|
|
1860
|
+
HttpResponseError,
|
|
1861
|
+
mergeDataIntoQueryString as mergeDataIntoQueryString3,
|
|
1862
|
+
objectToFormData,
|
|
1863
|
+
UseFormUtils as UseFormUtils4
|
|
1864
|
+
} from "@inertiajs/core";
|
|
1865
|
+
import { toSimpleValidationErrors as toSimpleValidationErrors2 } from "laravel-precognition";
|
|
1866
|
+
import { cloneDeep as cloneDeep4 } from "lodash-es";
|
|
1867
|
+
function useHttp(...args) {
|
|
1868
|
+
const { rememberKey, data, precognitionEndpoint } = UseFormUtils4.parseUseFormArguments(...args);
|
|
1869
|
+
let abortController = null;
|
|
1870
|
+
let pendingOptimisticCallback = null;
|
|
1871
|
+
const {
|
|
1872
|
+
form: baseForm,
|
|
1873
|
+
setDefaults,
|
|
1874
|
+
getTransform,
|
|
1875
|
+
getPrecognitionEndpoint,
|
|
1876
|
+
markAsSuccessful,
|
|
1877
|
+
wasDefaultsCalledInOnSuccess,
|
|
1878
|
+
resetDefaultsCalledInOnSuccess,
|
|
1879
|
+
setRememberExcludeKeys,
|
|
1880
|
+
resetBeforeSubmit,
|
|
1881
|
+
finishProcessing,
|
|
1882
|
+
withAllErrors
|
|
1883
|
+
} = useFormState({
|
|
1884
|
+
data,
|
|
1885
|
+
rememberKey,
|
|
1886
|
+
precognitionEndpoint
|
|
1887
|
+
});
|
|
1888
|
+
const form = baseForm;
|
|
1889
|
+
form.response = null;
|
|
1890
|
+
const submit = async (method, url, options) => {
|
|
1891
|
+
const onBefore = options.onBefore?.();
|
|
1892
|
+
if (onBefore === false) {
|
|
1893
|
+
return Promise.reject(new Error("Request cancelled by onBefore"));
|
|
1894
|
+
}
|
|
1895
|
+
resetDefaultsCalledInOnSuccess();
|
|
1896
|
+
resetBeforeSubmit();
|
|
1897
|
+
abortController = new AbortController();
|
|
1898
|
+
const cancelToken = {
|
|
1899
|
+
cancel: () => abortController?.abort()
|
|
1900
|
+
};
|
|
1901
|
+
options.onCancelToken?.(cancelToken);
|
|
1902
|
+
options.optimistic = options.optimistic ?? pendingOptimisticCallback ?? void 0;
|
|
1903
|
+
pendingOptimisticCallback = null;
|
|
1904
|
+
let snapshot;
|
|
1905
|
+
if (options.optimistic) {
|
|
1906
|
+
snapshot = cloneDeep4(form.data());
|
|
1907
|
+
const optimisticData = options.optimistic(cloneDeep4(snapshot));
|
|
1908
|
+
Object.keys(optimisticData).forEach((key2) => {
|
|
1909
|
+
;
|
|
1910
|
+
form[key2] = optimisticData[key2];
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
form.processing = true;
|
|
1914
|
+
options.onStart?.();
|
|
1915
|
+
const transform = getTransform();
|
|
1916
|
+
const transformedData = transform(form.data());
|
|
1917
|
+
const useFormData = hasFiles(transformedData);
|
|
1918
|
+
let requestUrl = url;
|
|
1919
|
+
let requestData;
|
|
1920
|
+
let contentType;
|
|
1921
|
+
if (method === "get") {
|
|
1922
|
+
const [urlWithParams] = mergeDataIntoQueryString3(
|
|
1923
|
+
method,
|
|
1924
|
+
url,
|
|
1925
|
+
transformedData
|
|
1926
|
+
);
|
|
1927
|
+
requestUrl = urlWithParams;
|
|
1928
|
+
} else {
|
|
1929
|
+
if (useFormData) {
|
|
1930
|
+
requestData = objectToFormData(transformedData);
|
|
1931
|
+
} else {
|
|
1932
|
+
requestData = JSON.stringify(transformedData);
|
|
1933
|
+
contentType = "application/json";
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
try {
|
|
1937
|
+
const response = await http.getClient().request({
|
|
1938
|
+
method,
|
|
1939
|
+
url: requestUrl,
|
|
1940
|
+
data: requestData,
|
|
1941
|
+
headers: {
|
|
1942
|
+
Accept: "application/json",
|
|
1943
|
+
...contentType ? { "Content-Type": contentType } : {},
|
|
1944
|
+
...options.headers
|
|
1945
|
+
},
|
|
1946
|
+
signal: abortController.signal,
|
|
1947
|
+
onUploadProgress: (event) => {
|
|
1948
|
+
form.progress = event;
|
|
1949
|
+
options.onProgress?.(event);
|
|
1950
|
+
}
|
|
1951
|
+
});
|
|
1952
|
+
const responseData = JSON.parse(response.data);
|
|
1953
|
+
if (response.status >= 200 && response.status < 300) {
|
|
1954
|
+
markAsSuccessful();
|
|
1955
|
+
form.response = responseData;
|
|
1956
|
+
options.onSuccess?.(responseData);
|
|
1957
|
+
if (!wasDefaultsCalledInOnSuccess()) {
|
|
1958
|
+
setDefaults(cloneDeep4(form.data()));
|
|
1959
|
+
}
|
|
1960
|
+
form.isDirty = false;
|
|
1961
|
+
return responseData;
|
|
1962
|
+
}
|
|
1963
|
+
throw new HttpResponseError(`Request failed with status ${response.status}`, response, url);
|
|
1964
|
+
} catch (error) {
|
|
1965
|
+
if (snapshot) {
|
|
1966
|
+
Object.keys(snapshot).forEach((key2) => {
|
|
1967
|
+
;
|
|
1968
|
+
form[key2] = snapshot[key2];
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
if (error instanceof HttpResponseError) {
|
|
1972
|
+
if (error.response.status === 422) {
|
|
1973
|
+
const responseData = JSON.parse(error.response.data);
|
|
1974
|
+
const validationErrors = responseData.errors || {};
|
|
1975
|
+
const processedErrors = withAllErrors.enabled() ? validationErrors : toSimpleValidationErrors2(validationErrors);
|
|
1976
|
+
form.clearErrors().setError(processedErrors);
|
|
1977
|
+
options.onError?.(processedErrors);
|
|
1978
|
+
}
|
|
1979
|
+
throw error;
|
|
1980
|
+
}
|
|
1981
|
+
if (error instanceof HttpCancelledError || error instanceof Error && error.name === "AbortError") {
|
|
1982
|
+
options.onCancel?.();
|
|
1983
|
+
throw new HttpCancelledError("Request was cancelled", url);
|
|
1984
|
+
}
|
|
1985
|
+
throw error;
|
|
1986
|
+
} finally {
|
|
1987
|
+
finishProcessing();
|
|
1988
|
+
abortController = null;
|
|
1989
|
+
options.onFinish?.();
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
const createSubmitMethod = (method) => async (url, options = {}) => {
|
|
1993
|
+
return submit(method, url, options);
|
|
1994
|
+
};
|
|
1995
|
+
Object.assign(form, {
|
|
1996
|
+
submit(...args2) {
|
|
1997
|
+
const parsed = UseFormUtils4.parseSubmitArguments(args2, getPrecognitionEndpoint());
|
|
1998
|
+
return submit(parsed.method, parsed.url, parsed.options);
|
|
1999
|
+
},
|
|
2000
|
+
get: createSubmitMethod("get"),
|
|
2001
|
+
post: createSubmitMethod("post"),
|
|
2002
|
+
put: createSubmitMethod("put"),
|
|
2003
|
+
patch: createSubmitMethod("patch"),
|
|
2004
|
+
delete: createSubmitMethod("delete"),
|
|
2005
|
+
cancel() {
|
|
2006
|
+
if (abortController) {
|
|
2007
|
+
abortController.abort();
|
|
2008
|
+
}
|
|
2009
|
+
},
|
|
2010
|
+
dontRemember(...keys) {
|
|
2011
|
+
setRememberExcludeKeys(keys);
|
|
2012
|
+
return form;
|
|
2013
|
+
},
|
|
2014
|
+
optimistic(callback) {
|
|
2015
|
+
pendingOptimisticCallback = callback;
|
|
2016
|
+
return form;
|
|
2017
|
+
},
|
|
2018
|
+
withAllErrors() {
|
|
2019
|
+
withAllErrors.enable();
|
|
2020
|
+
return form;
|
|
2021
|
+
}
|
|
2022
|
+
});
|
|
2023
|
+
const originalWithPrecognition = form.withPrecognition;
|
|
2024
|
+
form.withPrecognition = (...args2) => {
|
|
2025
|
+
originalWithPrecognition.call(form, ...args2);
|
|
2026
|
+
return form;
|
|
2027
|
+
};
|
|
2028
|
+
return getPrecognitionEndpoint() ? form : form;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
1566
2031
|
// src/usePoll.ts
|
|
1567
|
-
|
|
1568
|
-
|
|
2032
|
+
import { router as router8 } from "@inertiajs/core";
|
|
2033
|
+
import { onMounted as onMounted5, onUnmounted as onUnmounted4 } from "vue";
|
|
1569
2034
|
function usePoll(interval, requestOptions = {}, options = {
|
|
1570
2035
|
keepAlive: false,
|
|
1571
2036
|
autoStart: true
|
|
1572
2037
|
}) {
|
|
1573
|
-
const { stop, start } =
|
|
2038
|
+
const { stop, start } = router8.poll(interval, requestOptions, {
|
|
1574
2039
|
...options,
|
|
1575
2040
|
autoStart: false
|
|
1576
2041
|
});
|
|
1577
|
-
(
|
|
2042
|
+
onMounted5(() => {
|
|
1578
2043
|
if (options.autoStart ?? true) {
|
|
1579
2044
|
start();
|
|
1580
2045
|
}
|
|
1581
2046
|
});
|
|
1582
|
-
(
|
|
2047
|
+
onUnmounted4(() => {
|
|
1583
2048
|
stop();
|
|
1584
2049
|
});
|
|
1585
2050
|
return {
|
|
@@ -1589,33 +2054,33 @@ function usePoll(interval, requestOptions = {}, options = {
|
|
|
1589
2054
|
}
|
|
1590
2055
|
|
|
1591
2056
|
// src/usePrefetch.ts
|
|
1592
|
-
|
|
1593
|
-
|
|
2057
|
+
import { router as router9 } from "@inertiajs/core";
|
|
2058
|
+
import { onMounted as onMounted6, onUnmounted as onUnmounted5, ref as ref7 } from "vue";
|
|
1594
2059
|
function usePrefetch(options = {}) {
|
|
1595
|
-
const isPrefetching = (
|
|
1596
|
-
const lastUpdatedAt = (
|
|
1597
|
-
const isPrefetched = (
|
|
1598
|
-
const cached = typeof window === "undefined" ? null :
|
|
1599
|
-
const inFlight = typeof window === "undefined" ? null :
|
|
2060
|
+
const isPrefetching = ref7(false);
|
|
2061
|
+
const lastUpdatedAt = ref7(null);
|
|
2062
|
+
const isPrefetched = ref7(false);
|
|
2063
|
+
const cached = typeof window === "undefined" ? null : router9.getCached(window.location.pathname, options);
|
|
2064
|
+
const inFlight = typeof window === "undefined" ? null : router9.getPrefetching(window.location.pathname, options);
|
|
1600
2065
|
lastUpdatedAt.value = cached?.staleTimestamp || null;
|
|
1601
2066
|
isPrefetching.value = inFlight !== null;
|
|
1602
2067
|
isPrefetched.value = cached !== null;
|
|
1603
2068
|
let onPrefetchedListener;
|
|
1604
2069
|
let onPrefetchingListener;
|
|
1605
|
-
(
|
|
1606
|
-
onPrefetchingListener =
|
|
2070
|
+
onMounted6(() => {
|
|
2071
|
+
onPrefetchingListener = router9.on("prefetching", (e) => {
|
|
1607
2072
|
if (e.detail.visit.url.pathname === window.location.pathname) {
|
|
1608
2073
|
isPrefetching.value = true;
|
|
1609
2074
|
}
|
|
1610
2075
|
});
|
|
1611
|
-
onPrefetchedListener =
|
|
2076
|
+
onPrefetchedListener = router9.on("prefetched", (e) => {
|
|
1612
2077
|
if (e.detail.visit.url.pathname === window.location.pathname) {
|
|
1613
2078
|
isPrefetching.value = false;
|
|
1614
2079
|
isPrefetched.value = true;
|
|
1615
2080
|
}
|
|
1616
2081
|
});
|
|
1617
2082
|
});
|
|
1618
|
-
(
|
|
2083
|
+
onUnmounted5(() => {
|
|
1619
2084
|
onPrefetchedListener();
|
|
1620
2085
|
onPrefetchingListener();
|
|
1621
2086
|
});
|
|
@@ -1623,28 +2088,28 @@ function usePrefetch(options = {}) {
|
|
|
1623
2088
|
lastUpdatedAt,
|
|
1624
2089
|
isPrefetching,
|
|
1625
2090
|
isPrefetched,
|
|
1626
|
-
flush: () =>
|
|
2091
|
+
flush: () => router9.flush(window.location.pathname, options)
|
|
1627
2092
|
};
|
|
1628
2093
|
}
|
|
1629
2094
|
|
|
1630
2095
|
// src/useRemember.ts
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
2096
|
+
import { router as router10 } from "@inertiajs/core";
|
|
2097
|
+
import { cloneDeep as cloneDeep5 } from "lodash-es";
|
|
2098
|
+
import { isReactive, reactive as reactive3, ref as ref8, watch as watch4 } from "vue";
|
|
1634
2099
|
function useRemember(data, key2) {
|
|
1635
2100
|
if (typeof data === "object" && data !== null && data.__rememberable === false) {
|
|
1636
2101
|
return data;
|
|
1637
2102
|
}
|
|
1638
|
-
const restored =
|
|
1639
|
-
const type =
|
|
2103
|
+
const restored = router10.restore(key2);
|
|
2104
|
+
const type = isReactive(data) ? reactive3 : ref8;
|
|
1640
2105
|
const hasCallbacks = typeof data.__remember === "function" && typeof data.__restore === "function";
|
|
1641
2106
|
const remembered = type(
|
|
1642
|
-
restored === void 0 ? data : hasCallbacks ? data.__restore((
|
|
2107
|
+
restored === void 0 ? data : hasCallbacks ? data.__restore(cloneDeep5(restored)) : cloneDeep5(restored)
|
|
1643
2108
|
);
|
|
1644
|
-
(
|
|
2109
|
+
watch4(
|
|
1645
2110
|
remembered,
|
|
1646
2111
|
(newValue) => {
|
|
1647
|
-
|
|
2112
|
+
router10.remember(cloneDeep5(hasCallbacks ? data.__remember() : newValue), key2);
|
|
1648
2113
|
},
|
|
1649
2114
|
{ immediate: true, deep: true }
|
|
1650
2115
|
);
|
|
@@ -1652,9 +2117,10 @@ function useRemember(data, key2) {
|
|
|
1652
2117
|
}
|
|
1653
2118
|
|
|
1654
2119
|
// src/whenVisible.ts
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
2120
|
+
import { router as router11 } from "@inertiajs/core";
|
|
2121
|
+
import { get as get3 } from "lodash-es";
|
|
2122
|
+
import { defineComponent as defineComponent8, h as h6 } from "vue";
|
|
2123
|
+
var whenVisible_default = defineComponent8({
|
|
1658
2124
|
name: "WhenVisible",
|
|
1659
2125
|
slots: Object,
|
|
1660
2126
|
props: {
|
|
@@ -1695,9 +2161,9 @@ var whenVisible_default = (0, import_vue12.defineComponent)({
|
|
|
1695
2161
|
created() {
|
|
1696
2162
|
const page2 = usePage();
|
|
1697
2163
|
this.$watch(
|
|
1698
|
-
() => this.keys.map((key2) => page2.props
|
|
2164
|
+
() => this.keys.map((key2) => get3(page2.props, key2)),
|
|
1699
2165
|
() => {
|
|
1700
|
-
const exists = this.keys.length > 0 && this.keys.every((key2) => page2.props
|
|
2166
|
+
const exists = this.keys.length > 0 && this.keys.every((key2) => get3(page2.props, key2) !== void 0);
|
|
1701
2167
|
this.loaded = exists;
|
|
1702
2168
|
if (exists && !this.always) {
|
|
1703
2169
|
return;
|
|
@@ -1725,7 +2191,7 @@ var whenVisible_default = (0, import_vue12.defineComponent)({
|
|
|
1725
2191
|
}
|
|
1726
2192
|
this.fetching = true;
|
|
1727
2193
|
const reloadParams = this.getReloadParams();
|
|
1728
|
-
|
|
2194
|
+
router11.reload({
|
|
1729
2195
|
...reloadParams,
|
|
1730
2196
|
onStart: (e) => {
|
|
1731
2197
|
this.fetching = true;
|
|
@@ -1748,7 +2214,7 @@ var whenVisible_default = (0, import_vue12.defineComponent)({
|
|
|
1748
2214
|
this.observer.observe(this.$el.nextSibling);
|
|
1749
2215
|
},
|
|
1750
2216
|
getReloadParams() {
|
|
1751
|
-
const reloadParams = { ...this.$props.params };
|
|
2217
|
+
const reloadParams = { preserveErrors: true, ...this.$props.params };
|
|
1752
2218
|
if (this.$props.data) {
|
|
1753
2219
|
reloadParams.only = Array.isArray(this.$props.data) ? this.$props.data : [this.$props.data];
|
|
1754
2220
|
}
|
|
@@ -1758,7 +2224,7 @@ var whenVisible_default = (0, import_vue12.defineComponent)({
|
|
|
1758
2224
|
render() {
|
|
1759
2225
|
const els = [];
|
|
1760
2226
|
if (this.$props.always || !this.loaded) {
|
|
1761
|
-
els.push((
|
|
2227
|
+
els.push(h6(this.$props.as));
|
|
1762
2228
|
}
|
|
1763
2229
|
if (!this.loaded) {
|
|
1764
2230
|
els.push(this.$slots.fallback ? this.$slots.fallback({}) : null);
|
|
@@ -1770,5 +2236,31 @@ var whenVisible_default = (0, import_vue12.defineComponent)({
|
|
|
1770
2236
|
});
|
|
1771
2237
|
|
|
1772
2238
|
// src/index.ts
|
|
1773
|
-
var config =
|
|
2239
|
+
var config = coreConfig.extend({});
|
|
2240
|
+
export {
|
|
2241
|
+
app_default as App,
|
|
2242
|
+
deferred_default as Deferred,
|
|
2243
|
+
form_default as Form,
|
|
2244
|
+
head_default as Head,
|
|
2245
|
+
infiniteScroll_default as InfiniteScroll,
|
|
2246
|
+
link_default as Link,
|
|
2247
|
+
whenVisible_default as WhenVisible,
|
|
2248
|
+
config,
|
|
2249
|
+
createForm,
|
|
2250
|
+
createInertiaApp,
|
|
2251
|
+
http2 as http,
|
|
2252
|
+
progress,
|
|
2253
|
+
resetLayoutProps,
|
|
2254
|
+
router12 as router,
|
|
2255
|
+
setLayoutProps,
|
|
2256
|
+
setLayoutPropsFor,
|
|
2257
|
+
useForm,
|
|
2258
|
+
useFormContext,
|
|
2259
|
+
useHttp,
|
|
2260
|
+
useLayoutProps,
|
|
2261
|
+
usePage,
|
|
2262
|
+
usePoll,
|
|
2263
|
+
usePrefetch,
|
|
2264
|
+
useRemember
|
|
2265
|
+
};
|
|
1774
2266
|
//# sourceMappingURL=index.js.map
|