@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.js
CHANGED
|
@@ -31,9 +31,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
createHeadManager: () => createHeadManager,
|
|
34
|
+
formDataToObject: () => formDataToObject,
|
|
34
35
|
hideProgress: () => hide,
|
|
35
36
|
hrefToUrl: () => hrefToUrl,
|
|
36
37
|
mergeDataIntoQueryString: () => mergeDataIntoQueryString,
|
|
38
|
+
objectToFormData: () => objectToFormData,
|
|
37
39
|
revealProgress: () => reveal,
|
|
38
40
|
router: () => router,
|
|
39
41
|
setupProgress: () => setupProgress,
|
|
@@ -551,7 +553,7 @@ var Queue = class {
|
|
|
551
553
|
return this.process();
|
|
552
554
|
}
|
|
553
555
|
process() {
|
|
554
|
-
this.processingPromise ?? (this.processingPromise = this.processNext().
|
|
556
|
+
this.processingPromise ?? (this.processingPromise = this.processNext().finally(() => {
|
|
555
557
|
this.processingPromise = null;
|
|
556
558
|
}));
|
|
557
559
|
return this.processingPromise;
|
|
@@ -2066,6 +2068,55 @@ var Router = class {
|
|
|
2066
2068
|
}
|
|
2067
2069
|
};
|
|
2068
2070
|
|
|
2071
|
+
// src/formObject.ts
|
|
2072
|
+
var import_compat = require("es-toolkit/compat");
|
|
2073
|
+
function undotKey(key) {
|
|
2074
|
+
if (!key.includes(".")) {
|
|
2075
|
+
return key;
|
|
2076
|
+
}
|
|
2077
|
+
const transformSegment = (segment) => {
|
|
2078
|
+
if (segment.startsWith("[") && segment.endsWith("]")) {
|
|
2079
|
+
return segment;
|
|
2080
|
+
}
|
|
2081
|
+
return segment.split(".").reduce((result, part, index) => index === 0 ? part : `${result}[${part}]`);
|
|
2082
|
+
};
|
|
2083
|
+
return key.replace(/\\\./g, "__ESCAPED_DOT__").split(/(\[[^\]]*\])/).filter(Boolean).map(transformSegment).join("").replace(/__ESCAPED_DOT__/g, ".");
|
|
2084
|
+
}
|
|
2085
|
+
function parseKey(key) {
|
|
2086
|
+
const path = [];
|
|
2087
|
+
const pattern = /([^\[\]]+)|\[(\d*)\]/g;
|
|
2088
|
+
let match;
|
|
2089
|
+
while ((match = pattern.exec(key)) !== null) {
|
|
2090
|
+
if (match[1] !== void 0) {
|
|
2091
|
+
path.push(match[1]);
|
|
2092
|
+
} else if (match[2] !== void 0) {
|
|
2093
|
+
path.push(match[2] === "" ? "" : Number(match[2]));
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
return path;
|
|
2097
|
+
}
|
|
2098
|
+
function formDataToObject(source) {
|
|
2099
|
+
const form = {};
|
|
2100
|
+
for (const [key, value] of source.entries()) {
|
|
2101
|
+
if (value instanceof File && value.size === 0 && value.name === "") {
|
|
2102
|
+
continue;
|
|
2103
|
+
}
|
|
2104
|
+
const path = parseKey(undotKey(key));
|
|
2105
|
+
if (path[path.length - 1] === "") {
|
|
2106
|
+
const arrayPath = path.slice(0, -1);
|
|
2107
|
+
const existing = (0, import_compat.get)(form, arrayPath);
|
|
2108
|
+
if (Array.isArray(existing)) {
|
|
2109
|
+
existing.push(value);
|
|
2110
|
+
} else {
|
|
2111
|
+
(0, import_compat.set)(form, arrayPath, [value]);
|
|
2112
|
+
}
|
|
2113
|
+
continue;
|
|
2114
|
+
}
|
|
2115
|
+
(0, import_compat.set)(form, path, value);
|
|
2116
|
+
}
|
|
2117
|
+
return form;
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2069
2120
|
// src/head.ts
|
|
2070
2121
|
var Renderer = {
|
|
2071
2122
|
buildDOMElement(tag) {
|
|
@@ -2213,7 +2264,7 @@ var configure = (options) => {
|
|
|
2213
2264
|
progress.id = baseComponentSelector;
|
|
2214
2265
|
progress.innerHTML = settings.template;
|
|
2215
2266
|
};
|
|
2216
|
-
var
|
|
2267
|
+
var set2 = (n) => {
|
|
2217
2268
|
const started = isStarted();
|
|
2218
2269
|
n = clamp(n, settings.minimum, 1);
|
|
2219
2270
|
status = n === 1 ? null : n;
|
|
@@ -2262,7 +2313,7 @@ var set = (n) => {
|
|
|
2262
2313
|
var isStarted = () => typeof status === "number";
|
|
2263
2314
|
var start = () => {
|
|
2264
2315
|
if (!status) {
|
|
2265
|
-
|
|
2316
|
+
set2(0);
|
|
2266
2317
|
}
|
|
2267
2318
|
const work = function() {
|
|
2268
2319
|
setTimeout(function() {
|
|
@@ -2282,7 +2333,7 @@ var done = (force) => {
|
|
|
2282
2333
|
return;
|
|
2283
2334
|
}
|
|
2284
2335
|
increaseByRandom(0.3 + 0.5 * Math.random());
|
|
2285
|
-
|
|
2336
|
+
set2(1);
|
|
2286
2337
|
};
|
|
2287
2338
|
var increaseByRandom = (amount) => {
|
|
2288
2339
|
const n = status;
|
|
@@ -2306,7 +2357,7 @@ var increaseByRandom = (amount) => {
|
|
|
2306
2357
|
}
|
|
2307
2358
|
return 0;
|
|
2308
2359
|
})();
|
|
2309
|
-
return
|
|
2360
|
+
return set2(clamp(n + amount, 0, 0.994));
|
|
2310
2361
|
};
|
|
2311
2362
|
var render = (fromStart) => {
|
|
2312
2363
|
if (isRendered()) {
|
|
@@ -2452,7 +2503,7 @@ var progress_component_default = {
|
|
|
2452
2503
|
configure,
|
|
2453
2504
|
isStarted,
|
|
2454
2505
|
done,
|
|
2455
|
-
set,
|
|
2506
|
+
set: set2,
|
|
2456
2507
|
remove,
|
|
2457
2508
|
start,
|
|
2458
2509
|
status,
|