@inertiajs/core 2.0.16 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +57 -6
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +57 -6
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/types/formObject.d.ts +5 -0
- package/types/index.d.ts +2 -0
- package/types/types.d.ts +28 -0
package/dist/index.esm.js
CHANGED
|
@@ -507,7 +507,7 @@ var Queue = class {
|
|
|
507
507
|
return this.process();
|
|
508
508
|
}
|
|
509
509
|
process() {
|
|
510
|
-
this.processingPromise ?? (this.processingPromise = this.processNext().
|
|
510
|
+
this.processingPromise ?? (this.processingPromise = this.processNext().finally(() => {
|
|
511
511
|
this.processingPromise = null;
|
|
512
512
|
}));
|
|
513
513
|
return this.processingPromise;
|
|
@@ -2022,6 +2022,55 @@ var Router = class {
|
|
|
2022
2022
|
}
|
|
2023
2023
|
};
|
|
2024
2024
|
|
|
2025
|
+
// src/formObject.ts
|
|
2026
|
+
import { get, set } from "es-toolkit/compat";
|
|
2027
|
+
function undotKey(key) {
|
|
2028
|
+
if (!key.includes(".")) {
|
|
2029
|
+
return key;
|
|
2030
|
+
}
|
|
2031
|
+
const transformSegment = (segment) => {
|
|
2032
|
+
if (segment.startsWith("[") && segment.endsWith("]")) {
|
|
2033
|
+
return segment;
|
|
2034
|
+
}
|
|
2035
|
+
return segment.split(".").reduce((result, part, index) => index === 0 ? part : `${result}[${part}]`);
|
|
2036
|
+
};
|
|
2037
|
+
return key.replace(/\\\./g, "__ESCAPED_DOT__").split(/(\[[^\]]*\])/).filter(Boolean).map(transformSegment).join("").replace(/__ESCAPED_DOT__/g, ".");
|
|
2038
|
+
}
|
|
2039
|
+
function parseKey(key) {
|
|
2040
|
+
const path = [];
|
|
2041
|
+
const pattern = /([^\[\]]+)|\[(\d*)\]/g;
|
|
2042
|
+
let match;
|
|
2043
|
+
while ((match = pattern.exec(key)) !== null) {
|
|
2044
|
+
if (match[1] !== void 0) {
|
|
2045
|
+
path.push(match[1]);
|
|
2046
|
+
} else if (match[2] !== void 0) {
|
|
2047
|
+
path.push(match[2] === "" ? "" : Number(match[2]));
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
return path;
|
|
2051
|
+
}
|
|
2052
|
+
function formDataToObject(source) {
|
|
2053
|
+
const form = {};
|
|
2054
|
+
for (const [key, value] of source.entries()) {
|
|
2055
|
+
if (value instanceof File && value.size === 0 && value.name === "") {
|
|
2056
|
+
continue;
|
|
2057
|
+
}
|
|
2058
|
+
const path = parseKey(undotKey(key));
|
|
2059
|
+
if (path[path.length - 1] === "") {
|
|
2060
|
+
const arrayPath = path.slice(0, -1);
|
|
2061
|
+
const existing = get(form, arrayPath);
|
|
2062
|
+
if (Array.isArray(existing)) {
|
|
2063
|
+
existing.push(value);
|
|
2064
|
+
} else {
|
|
2065
|
+
set(form, arrayPath, [value]);
|
|
2066
|
+
}
|
|
2067
|
+
continue;
|
|
2068
|
+
}
|
|
2069
|
+
set(form, path, value);
|
|
2070
|
+
}
|
|
2071
|
+
return form;
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2025
2074
|
// src/head.ts
|
|
2026
2075
|
var Renderer = {
|
|
2027
2076
|
buildDOMElement(tag) {
|
|
@@ -2169,7 +2218,7 @@ var configure = (options) => {
|
|
|
2169
2218
|
progress.id = baseComponentSelector;
|
|
2170
2219
|
progress.innerHTML = settings.template;
|
|
2171
2220
|
};
|
|
2172
|
-
var
|
|
2221
|
+
var set2 = (n) => {
|
|
2173
2222
|
const started = isStarted();
|
|
2174
2223
|
n = clamp(n, settings.minimum, 1);
|
|
2175
2224
|
status = n === 1 ? null : n;
|
|
@@ -2218,7 +2267,7 @@ var set = (n) => {
|
|
|
2218
2267
|
var isStarted = () => typeof status === "number";
|
|
2219
2268
|
var start = () => {
|
|
2220
2269
|
if (!status) {
|
|
2221
|
-
|
|
2270
|
+
set2(0);
|
|
2222
2271
|
}
|
|
2223
2272
|
const work = function() {
|
|
2224
2273
|
setTimeout(function() {
|
|
@@ -2238,7 +2287,7 @@ var done = (force) => {
|
|
|
2238
2287
|
return;
|
|
2239
2288
|
}
|
|
2240
2289
|
increaseByRandom(0.3 + 0.5 * Math.random());
|
|
2241
|
-
|
|
2290
|
+
set2(1);
|
|
2242
2291
|
};
|
|
2243
2292
|
var increaseByRandom = (amount) => {
|
|
2244
2293
|
const n = status;
|
|
@@ -2262,7 +2311,7 @@ var increaseByRandom = (amount) => {
|
|
|
2262
2311
|
}
|
|
2263
2312
|
return 0;
|
|
2264
2313
|
})();
|
|
2265
|
-
return
|
|
2314
|
+
return set2(clamp(n + amount, 0, 0.994));
|
|
2266
2315
|
};
|
|
2267
2316
|
var render = (fromStart) => {
|
|
2268
2317
|
if (isRendered()) {
|
|
@@ -2408,7 +2457,7 @@ var progress_component_default = {
|
|
|
2408
2457
|
configure,
|
|
2409
2458
|
isStarted,
|
|
2410
2459
|
done,
|
|
2411
|
-
set,
|
|
2460
|
+
set: set2,
|
|
2412
2461
|
remove,
|
|
2413
2462
|
start,
|
|
2414
2463
|
status,
|
|
@@ -2478,9 +2527,11 @@ function shouldIntercept(event) {
|
|
|
2478
2527
|
var router = new Router();
|
|
2479
2528
|
export {
|
|
2480
2529
|
createHeadManager,
|
|
2530
|
+
formDataToObject,
|
|
2481
2531
|
hide as hideProgress,
|
|
2482
2532
|
hrefToUrl,
|
|
2483
2533
|
mergeDataIntoQueryString,
|
|
2534
|
+
objectToFormData,
|
|
2484
2535
|
reveal as revealProgress,
|
|
2485
2536
|
router,
|
|
2486
2537
|
setupProgress,
|