@inventreedb/ui 0.11.2 → 1.4.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/CHANGELOG.md +33 -0
- package/dist/.vite/manifest.json +92 -5
- package/dist/components/Boundary.js +16 -7
- package/dist/components/Boundary.js.map +1 -1
- package/dist/components/InvenTreeTable.js +4 -3
- package/dist/components/InvenTreeTable.js.map +1 -1
- package/dist/components/RowActions.js +3 -2
- package/dist/components/RowActions.js.map +1 -1
- package/dist/components/StylishText.d.ts +6 -0
- package/dist/components/StylishText.js +36 -0
- package/dist/components/StylishText.js.map +1 -0
- package/dist/components/nav/DetailDrawer.css.d.ts +1 -0
- package/dist/components/nav/DetailDrawer.css.js +6 -0
- package/dist/components/nav/DetailDrawer.css.js.map +1 -0
- package/dist/components/nav/DetailDrawer.d.ts +22 -0
- package/dist/components/nav/DetailDrawer.js +66 -0
- package/dist/components/nav/DetailDrawer.js.map +1 -0
- package/dist/enums/ApiEndpoints.d.ts +1 -0
- package/dist/enums/ApiEndpoints.js +1 -0
- package/dist/enums/ApiEndpoints.js.map +1 -1
- package/dist/enums/ModelInformation.js +1 -0
- package/dist/enums/ModelInformation.js.map +1 -1
- package/dist/enums/ModelType.d.ts +9 -0
- package/dist/enums/ModelType.js.map +1 -1
- package/dist/enums/Roles.d.ts +1 -0
- package/dist/enums/Roles.js +1 -0
- package/dist/enums/Roles.js.map +1 -1
- package/dist/functions/Events.js +4 -3
- package/dist/functions/Events.js.map +1 -1
- package/dist/functions/Navigation.js +5 -2
- package/dist/functions/Navigation.js.map +1 -1
- package/dist/functions/Plugins.js +4 -2
- package/dist/functions/Plugins.js.map +1 -1
- package/dist/hooks/MonitorBackgroundTask.js +10 -8
- package/dist/hooks/MonitorBackgroundTask.js.map +1 -1
- package/dist/hooks/MonitorDataOutput.js +4 -3
- package/dist/hooks/MonitorDataOutput.js.map +1 -1
- package/dist/hooks/UseFilterSet.js +7 -6
- package/dist/hooks/UseFilterSet.js.map +1 -1
- package/dist/hooks/UseTable.js +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.js +40 -15
- package/dist/node_modules/@mantine/hooks/esm/use-debounced-value/use-debounced-value.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-document-visibility/use-document-visibility.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-local-storage/create-storage.js +57 -62
- package/dist/node_modules/@mantine/hooks/esm/use-local-storage/create-storage.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-local-storage/use-local-storage.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/use-window-event/use-window-event.js +5 -3
- package/dist/node_modules/@mantine/hooks/esm/use-window-event/use-window-event.js.map +1 -1
- package/dist/node_modules/@mantine/hooks/esm/utils/random-id/random-id.js.map +1 -1
- package/dist/node_modules/@remix-run/router/dist/router.js +458 -0
- package/dist/node_modules/@remix-run/router/dist/router.js.map +1 -0
- package/dist/node_modules/@sentry/browser/build/npm/esm/prod/report-dialog.js +2 -2
- package/dist/node_modules/@sentry/browser/build/npm/esm/prod/report-dialog.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/scope.js +6 -5
- package/dist/node_modules/@sentry/core/build/esm/scope.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/chain-and-copy-promiselike.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/chain-and-copy-promiselike.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/is.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/is.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/misc.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/misc.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/randomSafeContext.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/randomSafeContext.js.map +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/time.js +1 -1
- package/dist/node_modules/@sentry/core/build/esm/utils/time.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustments.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconAdjustments.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +14 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js.map +1 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleCheck.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCircleX.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconDots.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconEdit.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconExclamationCircle.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconPlus.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js.map +1 -1
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js +6 -0
- package/dist/node_modules/@tabler/icons-react/dist/esm/icons/IconTrash.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js +31 -20
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js +27 -17
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js +179 -177
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js +31 -21
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/suspense.js.map +1 -1
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +7 -4
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.js +10 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.js +10 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.js.map +1 -1
- package/dist/node_modules/react-router/dist/index.js +714 -0
- package/dist/node_modules/react-router/dist/index.js.map +1 -0
- package/dist/node_modules/react-router-dom/dist/index.js +536 -0
- package/dist/node_modules/react-router-dom/dist/index.js.map +1 -0
- package/dist/node_modules/zustand/esm/react/shallow.js +13 -0
- package/dist/node_modules/zustand/esm/react/shallow.js.map +1 -0
- package/dist/node_modules/zustand/esm/vanilla/shallow.js +57 -0
- package/dist/node_modules/zustand/esm/vanilla/shallow.js.map +1 -0
- package/dist/states/LocalLibState.d.ts +17 -0
- package/dist/states/LocalLibState.js +16 -0
- package/dist/states/LocalLibState.js.map +1 -0
- package/dist/states/StoredTableState.js +2 -1
- package/dist/states/StoredTableState.js.map +1 -1
- package/dist/states/types.d.ts +3 -0
- package/dist/types/Forms.d.ts +13 -6
- package/dist/types/Panel.d.ts +26 -0
- package/dist/types/Plugins.d.ts +14 -2
- package/dist/types/Plugins.js +2 -2
- package/dist/types/Plugins.js.map +1 -1
- package/dist/types/Rendering.d.ts +53 -0
- package/dist/types/Tables.d.ts +5 -1
- package/dist/ui.css +4 -0
- package/lib/components/Boundary.tsx +6 -3
- package/lib/components/RowActions.tsx +2 -2
- package/lib/components/StylishText.tsx +46 -0
- package/lib/components/nav/DetailDrawer.css.ts +6 -0
- package/lib/components/nav/DetailDrawer.tsx +108 -0
- package/lib/enums/ApiEndpoints.tsx +1 -0
- package/lib/enums/ModelInformation.tsx +1 -0
- package/lib/enums/ModelType.tsx +13 -0
- package/lib/enums/Roles.tsx +1 -0
- package/lib/hooks/UseFilterSet.tsx +8 -8
- package/lib/index.ts +16 -0
- package/lib/states/LocalLibState.tsx +23 -0
- package/lib/states/types.tsx +7 -0
- package/lib/types/Forms.tsx +13 -6
- package/lib/types/Panel.tsx +30 -0
- package/lib/types/Plugins.tsx +20 -1
- package/lib/types/Rendering.tsx +60 -0
- package/lib/types/Tables.tsx +5 -1
- package/package.json +20 -17
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @remix-run/router v1.23.2
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
function _extends() {
|
|
12
|
+
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
13
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
14
|
+
var source = arguments[i];
|
|
15
|
+
for (var key in source) {
|
|
16
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
17
|
+
target[key] = source[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return target;
|
|
22
|
+
};
|
|
23
|
+
return _extends.apply(this, arguments);
|
|
24
|
+
}
|
|
25
|
+
var Action;
|
|
26
|
+
(function(Action2) {
|
|
27
|
+
Action2["Pop"] = "POP";
|
|
28
|
+
Action2["Push"] = "PUSH";
|
|
29
|
+
Action2["Replace"] = "REPLACE";
|
|
30
|
+
})(Action || (Action = {}));
|
|
31
|
+
function invariant(value, message) {
|
|
32
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
33
|
+
throw new Error(message);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function warning(cond, message) {
|
|
37
|
+
if (!cond) {
|
|
38
|
+
if (typeof console !== "undefined") console.warn(message);
|
|
39
|
+
try {
|
|
40
|
+
throw new Error(message);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function createPath(_ref) {
|
|
46
|
+
let {
|
|
47
|
+
pathname = "/",
|
|
48
|
+
search = "",
|
|
49
|
+
hash = ""
|
|
50
|
+
} = _ref;
|
|
51
|
+
if (search && search !== "?") pathname += search.charAt(0) === "?" ? search : "?" + search;
|
|
52
|
+
if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
|
|
53
|
+
return pathname;
|
|
54
|
+
}
|
|
55
|
+
function parsePath(path) {
|
|
56
|
+
let parsedPath = {};
|
|
57
|
+
if (path) {
|
|
58
|
+
let hashIndex = path.indexOf("#");
|
|
59
|
+
if (hashIndex >= 0) {
|
|
60
|
+
parsedPath.hash = path.substr(hashIndex);
|
|
61
|
+
path = path.substr(0, hashIndex);
|
|
62
|
+
}
|
|
63
|
+
let searchIndex = path.indexOf("?");
|
|
64
|
+
if (searchIndex >= 0) {
|
|
65
|
+
parsedPath.search = path.substr(searchIndex);
|
|
66
|
+
path = path.substr(0, searchIndex);
|
|
67
|
+
}
|
|
68
|
+
if (path) {
|
|
69
|
+
parsedPath.pathname = path;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return parsedPath;
|
|
73
|
+
}
|
|
74
|
+
var ResultType;
|
|
75
|
+
(function(ResultType2) {
|
|
76
|
+
ResultType2["data"] = "data";
|
|
77
|
+
ResultType2["deferred"] = "deferred";
|
|
78
|
+
ResultType2["redirect"] = "redirect";
|
|
79
|
+
ResultType2["error"] = "error";
|
|
80
|
+
})(ResultType || (ResultType = {}));
|
|
81
|
+
function matchRoutes(routes, locationArg, basename) {
|
|
82
|
+
if (basename === void 0) {
|
|
83
|
+
basename = "/";
|
|
84
|
+
}
|
|
85
|
+
return matchRoutesImpl(routes, locationArg, basename);
|
|
86
|
+
}
|
|
87
|
+
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
88
|
+
let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
89
|
+
let pathname = stripBasename(location.pathname || "/", basename);
|
|
90
|
+
if (pathname == null) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
let branches = flattenRoutes(routes);
|
|
94
|
+
rankRouteBranches(branches);
|
|
95
|
+
let matches = null;
|
|
96
|
+
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
97
|
+
let decoded = decodePath(pathname);
|
|
98
|
+
matches = matchRouteBranch(branches[i], decoded);
|
|
99
|
+
}
|
|
100
|
+
return matches;
|
|
101
|
+
}
|
|
102
|
+
function flattenRoutes(routes, branches, parentsMeta, parentPath) {
|
|
103
|
+
if (branches === void 0) {
|
|
104
|
+
branches = [];
|
|
105
|
+
}
|
|
106
|
+
if (parentsMeta === void 0) {
|
|
107
|
+
parentsMeta = [];
|
|
108
|
+
}
|
|
109
|
+
if (parentPath === void 0) {
|
|
110
|
+
parentPath = "";
|
|
111
|
+
}
|
|
112
|
+
let flattenRoute = (route, index, relativePath) => {
|
|
113
|
+
let meta = {
|
|
114
|
+
relativePath: relativePath === void 0 ? route.path || "" : relativePath,
|
|
115
|
+
caseSensitive: route.caseSensitive === true,
|
|
116
|
+
childrenIndex: index,
|
|
117
|
+
route
|
|
118
|
+
};
|
|
119
|
+
if (meta.relativePath.startsWith("/")) {
|
|
120
|
+
invariant(meta.relativePath.startsWith(parentPath), 'Absolute route path "' + meta.relativePath + '" nested under path ' + ('"' + parentPath + '" is not valid. An absolute child route path ') + "must start with the combined path of all its parent routes.");
|
|
121
|
+
meta.relativePath = meta.relativePath.slice(parentPath.length);
|
|
122
|
+
}
|
|
123
|
+
let path = joinPaths([parentPath, meta.relativePath]);
|
|
124
|
+
let routesMeta = parentsMeta.concat(meta);
|
|
125
|
+
if (route.children && route.children.length > 0) {
|
|
126
|
+
invariant(
|
|
127
|
+
// Our types know better, but runtime JS may not!
|
|
128
|
+
// @ts-expect-error
|
|
129
|
+
route.index !== true,
|
|
130
|
+
"Index routes must not have child routes. Please remove " + ('all child routes from route path "' + path + '".')
|
|
131
|
+
);
|
|
132
|
+
flattenRoutes(route.children, branches, routesMeta, path);
|
|
133
|
+
}
|
|
134
|
+
if (route.path == null && !route.index) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
branches.push({
|
|
138
|
+
path,
|
|
139
|
+
score: computeScore(path, route.index),
|
|
140
|
+
routesMeta
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
routes.forEach((route, index) => {
|
|
144
|
+
var _route$path;
|
|
145
|
+
if (route.path === "" || !((_route$path = route.path) != null && _route$path.includes("?"))) {
|
|
146
|
+
flattenRoute(route, index);
|
|
147
|
+
} else {
|
|
148
|
+
for (let exploded of explodeOptionalSegments(route.path)) {
|
|
149
|
+
flattenRoute(route, index, exploded);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return branches;
|
|
154
|
+
}
|
|
155
|
+
function explodeOptionalSegments(path) {
|
|
156
|
+
let segments = path.split("/");
|
|
157
|
+
if (segments.length === 0) return [];
|
|
158
|
+
let [first, ...rest] = segments;
|
|
159
|
+
let isOptional = first.endsWith("?");
|
|
160
|
+
let required = first.replace(/\?$/, "");
|
|
161
|
+
if (rest.length === 0) {
|
|
162
|
+
return isOptional ? [required, ""] : [required];
|
|
163
|
+
}
|
|
164
|
+
let restExploded = explodeOptionalSegments(rest.join("/"));
|
|
165
|
+
let result = [];
|
|
166
|
+
result.push(...restExploded.map((subpath) => subpath === "" ? required : [required, subpath].join("/")));
|
|
167
|
+
if (isOptional) {
|
|
168
|
+
result.push(...restExploded);
|
|
169
|
+
}
|
|
170
|
+
return result.map((exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded);
|
|
171
|
+
}
|
|
172
|
+
function rankRouteBranches(branches) {
|
|
173
|
+
branches.sort((a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(a.routesMeta.map((meta) => meta.childrenIndex), b.routesMeta.map((meta) => meta.childrenIndex)));
|
|
174
|
+
}
|
|
175
|
+
const paramRe = /^:[\w-]+$/;
|
|
176
|
+
const dynamicSegmentValue = 3;
|
|
177
|
+
const indexRouteValue = 2;
|
|
178
|
+
const emptySegmentValue = 1;
|
|
179
|
+
const staticSegmentValue = 10;
|
|
180
|
+
const splatPenalty = -2;
|
|
181
|
+
const isSplat = (s) => s === "*";
|
|
182
|
+
function computeScore(path, index) {
|
|
183
|
+
let segments = path.split("/");
|
|
184
|
+
let initialScore = segments.length;
|
|
185
|
+
if (segments.some(isSplat)) {
|
|
186
|
+
initialScore += splatPenalty;
|
|
187
|
+
}
|
|
188
|
+
if (index) {
|
|
189
|
+
initialScore += indexRouteValue;
|
|
190
|
+
}
|
|
191
|
+
return segments.filter((s) => !isSplat(s)).reduce((score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue), initialScore);
|
|
192
|
+
}
|
|
193
|
+
function compareIndexes(a, b) {
|
|
194
|
+
let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
|
|
195
|
+
return siblings ? (
|
|
196
|
+
// If two routes are siblings, we should try to match the earlier sibling
|
|
197
|
+
// first. This allows people to have fine-grained control over the matching
|
|
198
|
+
// behavior by simply putting routes with identical paths in the order they
|
|
199
|
+
// want them tried.
|
|
200
|
+
a[a.length - 1] - b[b.length - 1]
|
|
201
|
+
) : (
|
|
202
|
+
// Otherwise, it doesn't really make sense to rank non-siblings by index,
|
|
203
|
+
// so they sort equally.
|
|
204
|
+
0
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
function matchRouteBranch(branch, pathname, allowPartial) {
|
|
208
|
+
let {
|
|
209
|
+
routesMeta
|
|
210
|
+
} = branch;
|
|
211
|
+
let matchedParams = {};
|
|
212
|
+
let matchedPathname = "/";
|
|
213
|
+
let matches = [];
|
|
214
|
+
for (let i = 0; i < routesMeta.length; ++i) {
|
|
215
|
+
let meta = routesMeta[i];
|
|
216
|
+
let end = i === routesMeta.length - 1;
|
|
217
|
+
let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
|
|
218
|
+
let match = matchPath({
|
|
219
|
+
path: meta.relativePath,
|
|
220
|
+
caseSensitive: meta.caseSensitive,
|
|
221
|
+
end
|
|
222
|
+
}, remainingPathname);
|
|
223
|
+
let route = meta.route;
|
|
224
|
+
if (!match) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
Object.assign(matchedParams, match.params);
|
|
228
|
+
matches.push({
|
|
229
|
+
// TODO: Can this as be avoided?
|
|
230
|
+
params: matchedParams,
|
|
231
|
+
pathname: joinPaths([matchedPathname, match.pathname]),
|
|
232
|
+
pathnameBase: normalizePathname(joinPaths([matchedPathname, match.pathnameBase])),
|
|
233
|
+
route
|
|
234
|
+
});
|
|
235
|
+
if (match.pathnameBase !== "/") {
|
|
236
|
+
matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return matches;
|
|
240
|
+
}
|
|
241
|
+
function matchPath(pattern, pathname) {
|
|
242
|
+
if (typeof pattern === "string") {
|
|
243
|
+
pattern = {
|
|
244
|
+
path: pattern,
|
|
245
|
+
caseSensitive: false,
|
|
246
|
+
end: true
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end);
|
|
250
|
+
let match = pathname.match(matcher);
|
|
251
|
+
if (!match) return null;
|
|
252
|
+
let matchedPathname = match[0];
|
|
253
|
+
let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
|
|
254
|
+
let captureGroups = match.slice(1);
|
|
255
|
+
let params = compiledParams.reduce((memo, _ref, index) => {
|
|
256
|
+
let {
|
|
257
|
+
paramName,
|
|
258
|
+
isOptional
|
|
259
|
+
} = _ref;
|
|
260
|
+
if (paramName === "*") {
|
|
261
|
+
let splatValue = captureGroups[index] || "";
|
|
262
|
+
pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
|
|
263
|
+
}
|
|
264
|
+
const value = captureGroups[index];
|
|
265
|
+
if (isOptional && !value) {
|
|
266
|
+
memo[paramName] = void 0;
|
|
267
|
+
} else {
|
|
268
|
+
memo[paramName] = (value || "").replace(/%2F/g, "/");
|
|
269
|
+
}
|
|
270
|
+
return memo;
|
|
271
|
+
}, {});
|
|
272
|
+
return {
|
|
273
|
+
params,
|
|
274
|
+
pathname: matchedPathname,
|
|
275
|
+
pathnameBase,
|
|
276
|
+
pattern
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function compilePath(path, caseSensitive, end) {
|
|
280
|
+
if (caseSensitive === void 0) {
|
|
281
|
+
caseSensitive = false;
|
|
282
|
+
}
|
|
283
|
+
if (end === void 0) {
|
|
284
|
+
end = true;
|
|
285
|
+
}
|
|
286
|
+
warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), 'Route path "' + path + '" will be treated as if it were ' + ('"' + path.replace(/\*$/, "/*") + '" because the `*` character must ') + "always follow a `/` in the pattern. To get rid of this warning, " + ('please change the route path to "' + path.replace(/\*$/, "/*") + '".'));
|
|
287
|
+
let params = [];
|
|
288
|
+
let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (_, paramName, isOptional) => {
|
|
289
|
+
params.push({
|
|
290
|
+
paramName,
|
|
291
|
+
isOptional: isOptional != null
|
|
292
|
+
});
|
|
293
|
+
return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
|
|
294
|
+
});
|
|
295
|
+
if (path.endsWith("*")) {
|
|
296
|
+
params.push({
|
|
297
|
+
paramName: "*"
|
|
298
|
+
});
|
|
299
|
+
regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
|
|
300
|
+
} else if (end) {
|
|
301
|
+
regexpSource += "\\/*$";
|
|
302
|
+
} else if (path !== "" && path !== "/") {
|
|
303
|
+
regexpSource += "(?:(?=\\/|$))";
|
|
304
|
+
} else ;
|
|
305
|
+
let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
|
|
306
|
+
return [matcher, params];
|
|
307
|
+
}
|
|
308
|
+
function decodePath(value) {
|
|
309
|
+
try {
|
|
310
|
+
return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
|
|
311
|
+
} catch (error) {
|
|
312
|
+
warning(false, 'The URL path "' + value + '" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent ' + ("encoding (" + error + ")."));
|
|
313
|
+
return value;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function stripBasename(pathname, basename) {
|
|
317
|
+
if (basename === "/") return pathname;
|
|
318
|
+
if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
|
|
322
|
+
let nextChar = pathname.charAt(startIndex);
|
|
323
|
+
if (nextChar && nextChar !== "/") {
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
return pathname.slice(startIndex) || "/";
|
|
327
|
+
}
|
|
328
|
+
const ABSOLUTE_URL_REGEX$1 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
329
|
+
const isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX$1.test(url);
|
|
330
|
+
function resolvePath(to, fromPathname) {
|
|
331
|
+
if (fromPathname === void 0) {
|
|
332
|
+
fromPathname = "/";
|
|
333
|
+
}
|
|
334
|
+
let {
|
|
335
|
+
pathname: toPathname,
|
|
336
|
+
search = "",
|
|
337
|
+
hash = ""
|
|
338
|
+
} = typeof to === "string" ? parsePath(to) : to;
|
|
339
|
+
let pathname;
|
|
340
|
+
if (toPathname) {
|
|
341
|
+
if (isAbsoluteUrl(toPathname)) {
|
|
342
|
+
pathname = toPathname;
|
|
343
|
+
} else {
|
|
344
|
+
if (toPathname.includes("//")) {
|
|
345
|
+
let oldPathname = toPathname;
|
|
346
|
+
toPathname = toPathname.replace(/\/\/+/g, "/");
|
|
347
|
+
warning(false, "Pathnames cannot have embedded double slashes - normalizing " + (oldPathname + " -> " + toPathname));
|
|
348
|
+
}
|
|
349
|
+
if (toPathname.startsWith("/")) {
|
|
350
|
+
pathname = resolvePathname(toPathname.substring(1), "/");
|
|
351
|
+
} else {
|
|
352
|
+
pathname = resolvePathname(toPathname, fromPathname);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
pathname = fromPathname;
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
pathname,
|
|
360
|
+
search: normalizeSearch(search),
|
|
361
|
+
hash: normalizeHash(hash)
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
function resolvePathname(relativePath, fromPathname) {
|
|
365
|
+
let segments = fromPathname.replace(/\/+$/, "").split("/");
|
|
366
|
+
let relativeSegments = relativePath.split("/");
|
|
367
|
+
relativeSegments.forEach((segment) => {
|
|
368
|
+
if (segment === "..") {
|
|
369
|
+
if (segments.length > 1) segments.pop();
|
|
370
|
+
} else if (segment !== ".") {
|
|
371
|
+
segments.push(segment);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
return segments.length > 1 ? segments.join("/") : "/";
|
|
375
|
+
}
|
|
376
|
+
function getInvalidPathError(char, field, dest, path) {
|
|
377
|
+
return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path) + "]. Please separate it out to the ") + ("`to." + dest + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.';
|
|
378
|
+
}
|
|
379
|
+
function getPathContributingMatches(matches) {
|
|
380
|
+
return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0);
|
|
381
|
+
}
|
|
382
|
+
function getResolveToMatches(matches, v7_relativeSplatPath) {
|
|
383
|
+
let pathMatches = getPathContributingMatches(matches);
|
|
384
|
+
if (v7_relativeSplatPath) {
|
|
385
|
+
return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
|
|
386
|
+
}
|
|
387
|
+
return pathMatches.map((match) => match.pathnameBase);
|
|
388
|
+
}
|
|
389
|
+
function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) {
|
|
390
|
+
if (isPathRelative === void 0) {
|
|
391
|
+
isPathRelative = false;
|
|
392
|
+
}
|
|
393
|
+
let to;
|
|
394
|
+
if (typeof toArg === "string") {
|
|
395
|
+
to = parsePath(toArg);
|
|
396
|
+
} else {
|
|
397
|
+
to = _extends({}, toArg);
|
|
398
|
+
invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
|
|
399
|
+
invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
|
|
400
|
+
invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
|
|
401
|
+
}
|
|
402
|
+
let isEmptyPath = toArg === "" || to.pathname === "";
|
|
403
|
+
let toPathname = isEmptyPath ? "/" : to.pathname;
|
|
404
|
+
let from;
|
|
405
|
+
if (toPathname == null) {
|
|
406
|
+
from = locationPathname;
|
|
407
|
+
} else {
|
|
408
|
+
let routePathnameIndex = routePathnames.length - 1;
|
|
409
|
+
if (!isPathRelative && toPathname.startsWith("..")) {
|
|
410
|
+
let toSegments = toPathname.split("/");
|
|
411
|
+
while (toSegments[0] === "..") {
|
|
412
|
+
toSegments.shift();
|
|
413
|
+
routePathnameIndex -= 1;
|
|
414
|
+
}
|
|
415
|
+
to.pathname = toSegments.join("/");
|
|
416
|
+
}
|
|
417
|
+
from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
|
|
418
|
+
}
|
|
419
|
+
let path = resolvePath(to, from);
|
|
420
|
+
let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
|
|
421
|
+
let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
|
|
422
|
+
if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
|
|
423
|
+
path.pathname += "/";
|
|
424
|
+
}
|
|
425
|
+
return path;
|
|
426
|
+
}
|
|
427
|
+
const joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
|
|
428
|
+
const normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
|
|
429
|
+
const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
|
|
430
|
+
const normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
|
431
|
+
class AbortedDeferredError extends Error {
|
|
432
|
+
}
|
|
433
|
+
function isRouteErrorResponse(error) {
|
|
434
|
+
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
|
435
|
+
}
|
|
436
|
+
const validMutationMethodsArr = ["post", "put", "patch", "delete"];
|
|
437
|
+
new Set(validMutationMethodsArr);
|
|
438
|
+
const validRequestMethodsArr = ["get", ...validMutationMethodsArr];
|
|
439
|
+
new Set(validRequestMethodsArr);
|
|
440
|
+
export {
|
|
441
|
+
AbortedDeferredError,
|
|
442
|
+
Action,
|
|
443
|
+
decodePath as UNSAFE_decodePath,
|
|
444
|
+
getResolveToMatches as UNSAFE_getResolveToMatches,
|
|
445
|
+
invariant as UNSAFE_invariant,
|
|
446
|
+
warning as UNSAFE_warning,
|
|
447
|
+
createPath,
|
|
448
|
+
isRouteErrorResponse,
|
|
449
|
+
joinPaths,
|
|
450
|
+
matchPath,
|
|
451
|
+
matchRoutes,
|
|
452
|
+
normalizePathname,
|
|
453
|
+
parsePath,
|
|
454
|
+
resolvePath,
|
|
455
|
+
resolveTo,
|
|
456
|
+
stripBasename
|
|
457
|
+
};
|
|
458
|
+
//# sourceMappingURL=router.js.map
|