@pnkx-lib/ui 1.9.3 → 1.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,9 @@
|
|
1
|
-
import { j as jsxRuntimeExports, b as Icon, _ as _extends, c as _typeof, P as PnkxField, C as CheckboxField, u as useForm, d as classNames, e as _arrayLikeToArray, f as _unsupportedIterableToArray, w as warningOnce
|
1
|
+
import { j as jsxRuntimeExports, b as Icon, _ as _extends, c as _typeof, P as PnkxField, C as CheckboxField, u as useForm, d as classNames, e as _arrayLikeToArray, f as _unsupportedIterableToArray, w as warningOnce, h as _createClass, i as _classCallCheck, k as _defineProperty, l as _slicedToArray, m as warning$1, n as canUseDom, o as _objectSpread2, p as updateCSS, r as removeCSS, q as _arrayWithHoles, s as _nonIterableRest, t as resetWarned$1, F as FastColor, v as generate, x as presetPrimaryColors, y as presetPalettes, z as _inherits, A as _createSuper, B as _assertThisInitialized, G as _objectWithoutProperties, H as IconContext } from './Switch-za5Skgtp.js';
|
2
2
|
import { Button as Button$1, Cascader, Space as Space$1, Card, Skeleton as Skeleton$1, Modal as Modal$1, Tooltip as Tooltip$1, Popconfirm as Popconfirm$1, Typography, Table as Table$1, Tabs as Tabs$1, Popover as Popover$1, Badge as Badge$1, Col as Col$1, Row as Row$1, Dropdown as Dropdown$1, Breadcrumb as Breadcrumb$1, Flex as Flex$1, Splitter as Splitter$1, Menu as Menu$1, Pagination as Pagination$1, Steps as Steps$1, Tag as Tag$1, Divider as Divider$2, Alert as Alert$1, Spin as Spin$1, Drawer as Drawer$1, QRCode as QRCode$1, Result as Result$1, Rate as Rate$1, Segmented as Segmented$1, Statistic as Statistic$1, Timeline as Timeline$1, Tour as Tour$1, Tree as Tree$1, Watermark as Watermark$1, Anchor as Anchor$1, Affix, AutoComplete as AutoComplete$1, Input, Collapse, ColorPicker, Empty as Empty$2, Image as Image$1 } from 'antd';
|
3
3
|
import * as React from 'react';
|
4
4
|
import React__default, { version as version$1, isValidElement, useLayoutEffect as useLayoutEffect$1, useEffect, useRef, useMemo as useMemo$1, useCallback, useState, createContext, memo, useReducer, useContext, Component } from 'react';
|
5
5
|
import ReactDOM__default, { unstable_batchedUpdates, createPortal } from 'react-dom';
|
6
|
+
import { useNavigate, useLocation } from 'react-router';
|
6
7
|
import { u as useToast } from './cloneDeep-BLYi2V0G.js';
|
7
8
|
|
8
9
|
const Button = (props) => {
|
@@ -2296,11 +2297,11 @@ function getOwnerDocument(target) {
|
|
2296
2297
|
* @param callback {function} Callback function that is invoked when the dependencies of the hook change
|
2297
2298
|
*/
|
2298
2299
|
|
2299
|
-
const useIsomorphicLayoutEffect$
|
2300
|
+
const useIsomorphicLayoutEffect$1 = canUseDOM ? useLayoutEffect$1 : useEffect;
|
2300
2301
|
|
2301
2302
|
function useEvent$1(handler) {
|
2302
2303
|
const handlerRef = useRef(handler);
|
2303
|
-
useIsomorphicLayoutEffect$
|
2304
|
+
useIsomorphicLayoutEffect$1(() => {
|
2304
2305
|
handlerRef.current = handler;
|
2305
2306
|
});
|
2306
2307
|
return useCallback(function () {
|
@@ -2332,7 +2333,7 @@ function useLatestValue(value, dependencies) {
|
|
2332
2333
|
}
|
2333
2334
|
|
2334
2335
|
const valueRef = useRef(value);
|
2335
|
-
useIsomorphicLayoutEffect$
|
2336
|
+
useIsomorphicLayoutEffect$1(() => {
|
2336
2337
|
if (valueRef.current !== value) {
|
2337
2338
|
valueRef.current = value;
|
2338
2339
|
}
|
@@ -4635,7 +4636,7 @@ function useRect(element, measure, fallbackRect) {
|
|
4635
4636
|
const resizeObserver = useResizeObserver({
|
4636
4637
|
callback: measureRect
|
4637
4638
|
});
|
4638
|
-
useIsomorphicLayoutEffect$
|
4639
|
+
useIsomorphicLayoutEffect$1(() => {
|
4639
4640
|
measureRect();
|
4640
4641
|
|
4641
4642
|
if (element) {
|
@@ -4834,7 +4835,7 @@ function useRects(elements, measure) {
|
|
4834
4835
|
const resizeObserver = useResizeObserver({
|
4835
4836
|
callback: measureRects
|
4836
4837
|
});
|
4837
|
-
useIsomorphicLayoutEffect$
|
4838
|
+
useIsomorphicLayoutEffect$1(() => {
|
4838
4839
|
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
4839
4840
|
measureRects();
|
4840
4841
|
elements.forEach(element => resizeObserver == null ? void 0 : resizeObserver.observe(element));
|
@@ -5222,7 +5223,7 @@ function useLayoutShiftScrollCompensation(_ref) {
|
|
5222
5223
|
x: config,
|
5223
5224
|
y: config
|
5224
5225
|
} : config;
|
5225
|
-
useIsomorphicLayoutEffect$
|
5226
|
+
useIsomorphicLayoutEffect$1(() => {
|
5226
5227
|
const disabled = !x && !y;
|
5227
5228
|
|
5228
5229
|
if (disabled || !activeNode) {
|
@@ -5634,7 +5635,7 @@ const DndContext = /*#__PURE__*/memo(function DndContext(_ref) {
|
|
5634
5635
|
}, [draggableNodes, instantiateSensor]);
|
5635
5636
|
const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
|
5636
5637
|
useSensorSetup(sensors);
|
5637
|
-
useIsomorphicLayoutEffect$
|
5638
|
+
useIsomorphicLayoutEffect$1(() => {
|
5638
5639
|
if (activeNodeRect && status === Status.Initializing) {
|
5639
5640
|
setStatus(Status.Initialized);
|
5640
5641
|
}
|
@@ -5716,7 +5717,7 @@ const DndContext = /*#__PURE__*/memo(function DndContext(_ref) {
|
|
5716
5717
|
});
|
5717
5718
|
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
5718
5719
|
[overId]);
|
5719
|
-
useIsomorphicLayoutEffect$
|
5720
|
+
useIsomorphicLayoutEffect$1(() => {
|
5720
5721
|
sensorContext.current = {
|
5721
5722
|
activatorEvent,
|
5722
5723
|
active,
|
@@ -5844,7 +5845,7 @@ function useDraggable(_ref) {
|
|
5844
5845
|
const [activatorNode, setActivatorNodeRef] = useNodeRef();
|
5845
5846
|
const listeners = useSyntheticListeners(activators, id);
|
5846
5847
|
const dataRef = useLatestValue(data);
|
5847
|
-
useIsomorphicLayoutEffect$
|
5848
|
+
useIsomorphicLayoutEffect$1(() => {
|
5848
5849
|
draggableNodes.set(id, {
|
5849
5850
|
id,
|
5850
5851
|
key,
|
@@ -6200,7 +6201,7 @@ function SortableContext(_ref) {
|
|
6200
6201
|
const itemsHaveChanged = !itemsEqual(items, previousItemsRef.current);
|
6201
6202
|
const disableTransforms = overIndex !== -1 && activeIndex === -1 || itemsHaveChanged;
|
6202
6203
|
const disabled = normalizeDisabled(disabledProp);
|
6203
|
-
useIsomorphicLayoutEffect$
|
6204
|
+
useIsomorphicLayoutEffect$1(() => {
|
6204
6205
|
if (itemsHaveChanged && isDragging) {
|
6205
6206
|
measureDroppableContainers(items);
|
6206
6207
|
}
|
@@ -6289,7 +6290,7 @@ function useDerivedTransform(_ref) {
|
|
6289
6290
|
} = _ref;
|
6290
6291
|
const [derivedTransform, setDerivedtransform] = useState(null);
|
6291
6292
|
const previousIndex = useRef(index);
|
6292
|
-
useIsomorphicLayoutEffect$
|
6293
|
+
useIsomorphicLayoutEffect$1(() => {
|
6293
6294
|
if (!disabled && index !== previousIndex.current && node.current) {
|
6294
6295
|
const initial = rect.current;
|
6295
6296
|
|
@@ -10166,7 +10167,7 @@ function isEqual(obj1, obj2) {
|
|
10166
10167
|
function deepEqual(a, b) {
|
10167
10168
|
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
10168
10169
|
var circular = refSet.has(a);
|
10169
|
-
warningOnce
|
10170
|
+
warningOnce(!circular, 'Warning: There may be circular references');
|
10170
10171
|
if (circular) {
|
10171
10172
|
return false;
|
10172
10173
|
}
|
@@ -10452,7 +10453,7 @@ var Theme = /*#__PURE__*/function () {
|
|
10452
10453
|
this.derivatives = Array.isArray(derivatives) ? derivatives : [derivatives];
|
10453
10454
|
this.id = uuid;
|
10454
10455
|
if (derivatives.length === 0) {
|
10455
|
-
warning$
|
10456
|
+
warning$1(derivatives.length > 0, '[Ant Design CSS-in-JS] Theme should have at least one derivative function.');
|
10456
10457
|
}
|
10457
10458
|
uuid += 1;
|
10458
10459
|
}
|
@@ -10658,7 +10659,7 @@ var useCleanupRegister = function useCleanupRegister(deps) {
|
|
10658
10659
|
function register(fn) {
|
10659
10660
|
if (cleanupFlag) {
|
10660
10661
|
if (process.env.NODE_ENV !== 'production') {
|
10661
|
-
warning$
|
10662
|
+
warning$1(false, '[Ant Design CSS-in-JS] You are registering a cleanup function after unmount, which will not have any effect.');
|
10662
10663
|
}
|
10663
10664
|
return;
|
10664
10665
|
}
|
@@ -11548,7 +11549,7 @@ function stringify (element, index, children, callback) {
|
|
11548
11549
|
function lintWarning(message, info) {
|
11549
11550
|
var path = info.path,
|
11550
11551
|
parentSelectors = info.parentSelectors;
|
11551
|
-
warningOnce
|
11552
|
+
warningOnce(false, "[Ant Design CSS-in-JS] ".concat(path ? "Error in ".concat(path, ": ") : '').concat(message).concat(parentSelectors.length ? " Selector: ".concat(parentSelectors.join(' | ')) : ''));
|
11552
11553
|
}
|
11553
11554
|
|
11554
11555
|
var linter$1 = function linter(key, value, info) {
|
@@ -12236,10 +12237,10 @@ function resetWarned() {
|
|
12236
12237
|
resetWarned$1();
|
12237
12238
|
}
|
12238
12239
|
// eslint-disable-next-line import/no-mutable-exports
|
12239
|
-
let warning
|
12240
|
+
let warning = noop$1;
|
12240
12241
|
if (process.env.NODE_ENV !== 'production') {
|
12241
|
-
warning
|
12242
|
-
warningOnce
|
12242
|
+
warning = (valid, component, message) => {
|
12243
|
+
warningOnce(valid, `[antd: ${component}] ${message}`);
|
12243
12244
|
// StrictMode will inject console which will not throw warning in React 17.
|
12244
12245
|
if (process.env.NODE_ENV === 'test') {
|
12245
12246
|
resetWarned();
|
@@ -12272,7 +12273,7 @@ const devUseWarning = process.env.NODE_ENV !== 'production' ? component => {
|
|
12272
12273
|
console.warn('[antd] There exists deprecated usage in your code:', deprecatedWarnList);
|
12273
12274
|
}
|
12274
12275
|
} else {
|
12275
|
-
process.env.NODE_ENV !== "production" ? warning
|
12276
|
+
process.env.NODE_ENV !== "production" ? warning(valid, component, message) : void 0;
|
12276
12277
|
}
|
12277
12278
|
}
|
12278
12279
|
};
|
@@ -12899,7 +12900,7 @@ function registerTheme(globalPrefixCls, theme) {
|
|
12899
12900
|
if (canUseDom()) {
|
12900
12901
|
updateCSS(style, `${dynamicStyleMark}-dynamic-theme`);
|
12901
12902
|
} else {
|
12902
|
-
process.env.NODE_ENV !== "production" ? warning
|
12903
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'ConfigProvider', 'SSR do not support dynamic theme with css variables.') : void 0;
|
12903
12904
|
}
|
12904
12905
|
}
|
12905
12906
|
|
@@ -13171,7 +13172,7 @@ function getComponentToken(component, token, defaultToken, options) {
|
|
13171
13172
|
oldTokenKey = _ref2[0],
|
13172
13173
|
newTokenKey = _ref2[1];
|
13173
13174
|
if (process.env.NODE_ENV !== 'production') {
|
13174
|
-
warningOnce
|
13175
|
+
warningOnce(!(customToken !== null && customToken !== void 0 && customToken[oldTokenKey]), "Component Token `".concat(String(oldTokenKey), "` of ").concat(String(component), " is deprecated. Please use `").concat(String(newTokenKey), "` instead."));
|
13175
13176
|
}
|
13176
13177
|
|
13177
13178
|
// Should wrap with `if` clause, or there will be `undefined` in object.
|
@@ -14350,7 +14351,7 @@ const useDomMotionEvents = (function (onInternalMotionEnd) {
|
|
14350
14351
|
});
|
14351
14352
|
|
14352
14353
|
// It's safe to use `useLayoutEffect` but the warning is annoying
|
14353
|
-
var useIsomorphicLayoutEffect
|
14354
|
+
var useIsomorphicLayoutEffect = canUseDom() ? useLayoutEffect$1 : useEffect;
|
14354
14355
|
|
14355
14356
|
var raf = function raf(callback) {
|
14356
14357
|
return +setTimeout(callback, 16);
|
@@ -14458,7 +14459,7 @@ const useStepQueue = (function (status, prepareOnly, callback) {
|
|
14458
14459
|
setStep(STEP_PREPARE, true);
|
14459
14460
|
}
|
14460
14461
|
var STEP_QUEUE = prepareOnly ? SIMPLE_STEP_QUEUE : FULL_STEP_QUEUE;
|
14461
|
-
useIsomorphicLayoutEffect
|
14462
|
+
useIsomorphicLayoutEffect(function () {
|
14462
14463
|
if (step !== STEP_NONE && step !== STEP_ACTIVATED) {
|
14463
14464
|
var index = STEP_QUEUE.indexOf(step);
|
14464
14465
|
var nextStep = STEP_QUEUE[index + 1];
|
@@ -14637,7 +14638,7 @@ function useStatus(supportMotion, visible, getElement, _ref) {
|
|
14637
14638
|
var visibleRef = useRef(null);
|
14638
14639
|
|
14639
14640
|
// Update with new status
|
14640
|
-
useIsomorphicLayoutEffect
|
14641
|
+
useIsomorphicLayoutEffect(function () {
|
14641
14642
|
// When use Suspense, the `visible` will repeat trigger,
|
14642
14643
|
// But not real change of the `visible`, we need to skip it.
|
14643
14644
|
// https://github.com/ant-design/ant-design/issues/44379
|
@@ -15121,7 +15122,7 @@ var __rest$2 = undefined && undefined.__rest || function (s, e) {
|
|
15121
15122
|
*/
|
15122
15123
|
let existThemeConfig = false;
|
15123
15124
|
process.env.NODE_ENV !== 'production' ? componentName => {
|
15124
|
-
process.env.NODE_ENV !== "production" ? warning
|
15125
|
+
process.env.NODE_ENV !== "production" ? warning(!existThemeConfig, componentName, `Static function can not consume context like dynamic theme. Please use 'App' component instead.`) : void 0;
|
15125
15126
|
} : /* istanbul ignore next */
|
15126
15127
|
null;
|
15127
15128
|
// These props is used by `useContext` directly in sub component
|
@@ -15145,7 +15146,7 @@ const setGlobalConfig = props => {
|
|
15145
15146
|
}
|
15146
15147
|
if (theme) {
|
15147
15148
|
if (isLegacyTheme(theme)) {
|
15148
|
-
process.env.NODE_ENV !== "production" ? warning
|
15149
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'ConfigProvider', '`config` of css variable theme is not work in v5. Please use new `theme` config instead.') : void 0;
|
15149
15150
|
registerTheme(getGlobalPrefixCls(), theme);
|
15150
15151
|
}
|
15151
15152
|
}
|
@@ -15466,7 +15467,7 @@ ConfigProvider.config = setGlobalConfig;
|
|
15466
15467
|
ConfigProvider.useConfig = useConfig;
|
15467
15468
|
Object.defineProperty(ConfigProvider, 'SizeContext', {
|
15468
15469
|
get: () => {
|
15469
|
-
process.env.NODE_ENV !== "production" ? warning
|
15470
|
+
process.env.NODE_ENV !== "production" ? warning(false, 'ConfigProvider', 'ConfigProvider.SizeContext is deprecated. Please use `ConfigProvider.useConfig().componentSize` instead.') : void 0;
|
15470
15471
|
return SizeContext;
|
15471
15472
|
}
|
15472
15473
|
});
|
@@ -16212,1980 +16213,6 @@ function Cog6ToothIcon({
|
|
16212
16213
|
}
|
16213
16214
|
const ForwardRef = /*#__PURE__*/ React.forwardRef(Cog6ToothIcon);
|
16214
16215
|
|
16215
|
-
var dist = {};
|
16216
|
-
|
16217
|
-
var hasRequiredDist;
|
16218
|
-
|
16219
|
-
function requireDist () {
|
16220
|
-
if (hasRequiredDist) return dist;
|
16221
|
-
hasRequiredDist = 1;
|
16222
|
-
Object.defineProperty(dist, "__esModule", { value: true });
|
16223
|
-
dist.parse = parse;
|
16224
|
-
dist.serialize = serialize;
|
16225
|
-
/**
|
16226
|
-
* RegExp to match cookie-name in RFC 6265 sec 4.1.1
|
16227
|
-
* This refers out to the obsoleted definition of token in RFC 2616 sec 2.2
|
16228
|
-
* which has been replaced by the token definition in RFC 7230 appendix B.
|
16229
|
-
*
|
16230
|
-
* cookie-name = token
|
16231
|
-
* token = 1*tchar
|
16232
|
-
* tchar = "!" / "#" / "$" / "%" / "&" / "'" /
|
16233
|
-
* "*" / "+" / "-" / "." / "^" / "_" /
|
16234
|
-
* "`" / "|" / "~" / DIGIT / ALPHA
|
16235
|
-
*
|
16236
|
-
* Note: Allowing more characters - https://github.com/jshttp/cookie/issues/191
|
16237
|
-
* Allow same range as cookie value, except `=`, which delimits end of name.
|
16238
|
-
*/
|
16239
|
-
const cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/;
|
16240
|
-
/**
|
16241
|
-
* RegExp to match cookie-value in RFC 6265 sec 4.1.1
|
16242
|
-
*
|
16243
|
-
* cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )
|
16244
|
-
* cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
|
16245
|
-
* ; US-ASCII characters excluding CTLs,
|
16246
|
-
* ; whitespace DQUOTE, comma, semicolon,
|
16247
|
-
* ; and backslash
|
16248
|
-
*
|
16249
|
-
* Allowing more characters: https://github.com/jshttp/cookie/issues/191
|
16250
|
-
* Comma, backslash, and DQUOTE are not part of the parsing algorithm.
|
16251
|
-
*/
|
16252
|
-
const cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/;
|
16253
|
-
/**
|
16254
|
-
* RegExp to match domain-value in RFC 6265 sec 4.1.1
|
16255
|
-
*
|
16256
|
-
* domain-value = <subdomain>
|
16257
|
-
* ; defined in [RFC1034], Section 3.5, as
|
16258
|
-
* ; enhanced by [RFC1123], Section 2.1
|
16259
|
-
* <subdomain> = <label> | <subdomain> "." <label>
|
16260
|
-
* <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]
|
16261
|
-
* Labels must be 63 characters or less.
|
16262
|
-
* 'let-dig' not 'letter' in the first char, per RFC1123
|
16263
|
-
* <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>
|
16264
|
-
* <let-dig-hyp> = <let-dig> | "-"
|
16265
|
-
* <let-dig> = <letter> | <digit>
|
16266
|
-
* <letter> = any one of the 52 alphabetic characters A through Z in
|
16267
|
-
* upper case and a through z in lower case
|
16268
|
-
* <digit> = any one of the ten digits 0 through 9
|
16269
|
-
*
|
16270
|
-
* Keep support for leading dot: https://github.com/jshttp/cookie/issues/173
|
16271
|
-
*
|
16272
|
-
* > (Note that a leading %x2E ("."), if present, is ignored even though that
|
16273
|
-
* character is not permitted, but a trailing %x2E ("."), if present, will
|
16274
|
-
* cause the user agent to ignore the attribute.)
|
16275
|
-
*/
|
16276
|
-
const domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
|
16277
|
-
/**
|
16278
|
-
* RegExp to match path-value in RFC 6265 sec 4.1.1
|
16279
|
-
*
|
16280
|
-
* path-value = <any CHAR except CTLs or ";">
|
16281
|
-
* CHAR = %x01-7F
|
16282
|
-
* ; defined in RFC 5234 appendix B.1
|
16283
|
-
*/
|
16284
|
-
const pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
|
16285
|
-
const __toString = Object.prototype.toString;
|
16286
|
-
const NullObject = /* @__PURE__ */ (() => {
|
16287
|
-
const C = function () { };
|
16288
|
-
C.prototype = Object.create(null);
|
16289
|
-
return C;
|
16290
|
-
})();
|
16291
|
-
/**
|
16292
|
-
* Parse a cookie header.
|
16293
|
-
*
|
16294
|
-
* Parse the given cookie header string into an object
|
16295
|
-
* The object has the various cookies as keys(names) => values
|
16296
|
-
*/
|
16297
|
-
function parse(str, options) {
|
16298
|
-
const obj = new NullObject();
|
16299
|
-
const len = str.length;
|
16300
|
-
// RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
|
16301
|
-
if (len < 2)
|
16302
|
-
return obj;
|
16303
|
-
const dec = options?.decode || decode;
|
16304
|
-
let index = 0;
|
16305
|
-
do {
|
16306
|
-
const eqIdx = str.indexOf("=", index);
|
16307
|
-
if (eqIdx === -1)
|
16308
|
-
break; // No more cookie pairs.
|
16309
|
-
const colonIdx = str.indexOf(";", index);
|
16310
|
-
const endIdx = colonIdx === -1 ? len : colonIdx;
|
16311
|
-
if (eqIdx > endIdx) {
|
16312
|
-
// backtrack on prior semicolon
|
16313
|
-
index = str.lastIndexOf(";", eqIdx - 1) + 1;
|
16314
|
-
continue;
|
16315
|
-
}
|
16316
|
-
const keyStartIdx = startIndex(str, index, eqIdx);
|
16317
|
-
const keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
|
16318
|
-
const key = str.slice(keyStartIdx, keyEndIdx);
|
16319
|
-
// only assign once
|
16320
|
-
if (obj[key] === undefined) {
|
16321
|
-
let valStartIdx = startIndex(str, eqIdx + 1, endIdx);
|
16322
|
-
let valEndIdx = endIndex(str, endIdx, valStartIdx);
|
16323
|
-
const value = dec(str.slice(valStartIdx, valEndIdx));
|
16324
|
-
obj[key] = value;
|
16325
|
-
}
|
16326
|
-
index = endIdx + 1;
|
16327
|
-
} while (index < len);
|
16328
|
-
return obj;
|
16329
|
-
}
|
16330
|
-
function startIndex(str, index, max) {
|
16331
|
-
do {
|
16332
|
-
const code = str.charCodeAt(index);
|
16333
|
-
if (code !== 0x20 /* */ && code !== 0x09 /* \t */)
|
16334
|
-
return index;
|
16335
|
-
} while (++index < max);
|
16336
|
-
return max;
|
16337
|
-
}
|
16338
|
-
function endIndex(str, index, min) {
|
16339
|
-
while (index > min) {
|
16340
|
-
const code = str.charCodeAt(--index);
|
16341
|
-
if (code !== 0x20 /* */ && code !== 0x09 /* \t */)
|
16342
|
-
return index + 1;
|
16343
|
-
}
|
16344
|
-
return min;
|
16345
|
-
}
|
16346
|
-
/**
|
16347
|
-
* Serialize data into a cookie header.
|
16348
|
-
*
|
16349
|
-
* Serialize a name value pair into a cookie string suitable for
|
16350
|
-
* http headers. An optional options object specifies cookie parameters.
|
16351
|
-
*
|
16352
|
-
* serialize('foo', 'bar', { httpOnly: true })
|
16353
|
-
* => "foo=bar; httpOnly"
|
16354
|
-
*/
|
16355
|
-
function serialize(name, val, options) {
|
16356
|
-
const enc = options?.encode || encodeURIComponent;
|
16357
|
-
if (!cookieNameRegExp.test(name)) {
|
16358
|
-
throw new TypeError(`argument name is invalid: ${name}`);
|
16359
|
-
}
|
16360
|
-
const value = enc(val);
|
16361
|
-
if (!cookieValueRegExp.test(value)) {
|
16362
|
-
throw new TypeError(`argument val is invalid: ${val}`);
|
16363
|
-
}
|
16364
|
-
let str = name + "=" + value;
|
16365
|
-
if (!options)
|
16366
|
-
return str;
|
16367
|
-
if (options.maxAge !== undefined) {
|
16368
|
-
if (!Number.isInteger(options.maxAge)) {
|
16369
|
-
throw new TypeError(`option maxAge is invalid: ${options.maxAge}`);
|
16370
|
-
}
|
16371
|
-
str += "; Max-Age=" + options.maxAge;
|
16372
|
-
}
|
16373
|
-
if (options.domain) {
|
16374
|
-
if (!domainValueRegExp.test(options.domain)) {
|
16375
|
-
throw new TypeError(`option domain is invalid: ${options.domain}`);
|
16376
|
-
}
|
16377
|
-
str += "; Domain=" + options.domain;
|
16378
|
-
}
|
16379
|
-
if (options.path) {
|
16380
|
-
if (!pathValueRegExp.test(options.path)) {
|
16381
|
-
throw new TypeError(`option path is invalid: ${options.path}`);
|
16382
|
-
}
|
16383
|
-
str += "; Path=" + options.path;
|
16384
|
-
}
|
16385
|
-
if (options.expires) {
|
16386
|
-
if (!isDate(options.expires) ||
|
16387
|
-
!Number.isFinite(options.expires.valueOf())) {
|
16388
|
-
throw new TypeError(`option expires is invalid: ${options.expires}`);
|
16389
|
-
}
|
16390
|
-
str += "; Expires=" + options.expires.toUTCString();
|
16391
|
-
}
|
16392
|
-
if (options.httpOnly) {
|
16393
|
-
str += "; HttpOnly";
|
16394
|
-
}
|
16395
|
-
if (options.secure) {
|
16396
|
-
str += "; Secure";
|
16397
|
-
}
|
16398
|
-
if (options.partitioned) {
|
16399
|
-
str += "; Partitioned";
|
16400
|
-
}
|
16401
|
-
if (options.priority) {
|
16402
|
-
const priority = typeof options.priority === "string"
|
16403
|
-
? options.priority.toLowerCase()
|
16404
|
-
: undefined;
|
16405
|
-
switch (priority) {
|
16406
|
-
case "low":
|
16407
|
-
str += "; Priority=Low";
|
16408
|
-
break;
|
16409
|
-
case "medium":
|
16410
|
-
str += "; Priority=Medium";
|
16411
|
-
break;
|
16412
|
-
case "high":
|
16413
|
-
str += "; Priority=High";
|
16414
|
-
break;
|
16415
|
-
default:
|
16416
|
-
throw new TypeError(`option priority is invalid: ${options.priority}`);
|
16417
|
-
}
|
16418
|
-
}
|
16419
|
-
if (options.sameSite) {
|
16420
|
-
const sameSite = typeof options.sameSite === "string"
|
16421
|
-
? options.sameSite.toLowerCase()
|
16422
|
-
: options.sameSite;
|
16423
|
-
switch (sameSite) {
|
16424
|
-
case true:
|
16425
|
-
case "strict":
|
16426
|
-
str += "; SameSite=Strict";
|
16427
|
-
break;
|
16428
|
-
case "lax":
|
16429
|
-
str += "; SameSite=Lax";
|
16430
|
-
break;
|
16431
|
-
case "none":
|
16432
|
-
str += "; SameSite=None";
|
16433
|
-
break;
|
16434
|
-
default:
|
16435
|
-
throw new TypeError(`option sameSite is invalid: ${options.sameSite}`);
|
16436
|
-
}
|
16437
|
-
}
|
16438
|
-
return str;
|
16439
|
-
}
|
16440
|
-
/**
|
16441
|
-
* URL-decode string value. Optimized to skip native call when no %.
|
16442
|
-
*/
|
16443
|
-
function decode(str) {
|
16444
|
-
if (str.indexOf("%") === -1)
|
16445
|
-
return str;
|
16446
|
-
try {
|
16447
|
-
return decodeURIComponent(str);
|
16448
|
-
}
|
16449
|
-
catch (e) {
|
16450
|
-
return str;
|
16451
|
-
}
|
16452
|
-
}
|
16453
|
-
/**
|
16454
|
-
* Determine if value is a Date.
|
16455
|
-
*/
|
16456
|
-
function isDate(val) {
|
16457
|
-
return __toString.call(val) === "[object Date]";
|
16458
|
-
}
|
16459
|
-
|
16460
|
-
return dist;
|
16461
|
-
}
|
16462
|
-
|
16463
|
-
requireDist();
|
16464
|
-
|
16465
|
-
/**
|
16466
|
-
* react-router v7.6.0
|
16467
|
-
*
|
16468
|
-
* Copyright (c) Remix Software Inc.
|
16469
|
-
*
|
16470
|
-
* This source code is licensed under the MIT license found in the
|
16471
|
-
* LICENSE.md file in the root directory of this source tree.
|
16472
|
-
*
|
16473
|
-
* @license MIT
|
16474
|
-
*/
|
16475
|
-
function invariant(value, message) {
|
16476
|
-
if (value === false || value === null || typeof value === "undefined") {
|
16477
|
-
throw new Error(message);
|
16478
|
-
}
|
16479
|
-
}
|
16480
|
-
function warning(cond, message) {
|
16481
|
-
if (!cond) {
|
16482
|
-
if (typeof console !== "undefined") console.warn(message);
|
16483
|
-
try {
|
16484
|
-
throw new Error(message);
|
16485
|
-
} catch (e) {
|
16486
|
-
}
|
16487
|
-
}
|
16488
|
-
}
|
16489
|
-
function createPath({
|
16490
|
-
pathname = "/",
|
16491
|
-
search = "",
|
16492
|
-
hash = ""
|
16493
|
-
}) {
|
16494
|
-
if (search && search !== "?")
|
16495
|
-
pathname += search.charAt(0) === "?" ? search : "?" + search;
|
16496
|
-
if (hash && hash !== "#")
|
16497
|
-
pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
|
16498
|
-
return pathname;
|
16499
|
-
}
|
16500
|
-
function parsePath(path) {
|
16501
|
-
let parsedPath = {};
|
16502
|
-
if (path) {
|
16503
|
-
let hashIndex = path.indexOf("#");
|
16504
|
-
if (hashIndex >= 0) {
|
16505
|
-
parsedPath.hash = path.substring(hashIndex);
|
16506
|
-
path = path.substring(0, hashIndex);
|
16507
|
-
}
|
16508
|
-
let searchIndex = path.indexOf("?");
|
16509
|
-
if (searchIndex >= 0) {
|
16510
|
-
parsedPath.search = path.substring(searchIndex);
|
16511
|
-
path = path.substring(0, searchIndex);
|
16512
|
-
}
|
16513
|
-
if (path) {
|
16514
|
-
parsedPath.pathname = path;
|
16515
|
-
}
|
16516
|
-
}
|
16517
|
-
return parsedPath;
|
16518
|
-
}
|
16519
|
-
function matchRoutes(routes, locationArg, basename = "/") {
|
16520
|
-
return matchRoutesImpl(routes, locationArg, basename, false);
|
16521
|
-
}
|
16522
|
-
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
16523
|
-
let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
16524
|
-
let pathname = stripBasename(location.pathname || "/", basename);
|
16525
|
-
if (pathname == null) {
|
16526
|
-
return null;
|
16527
|
-
}
|
16528
|
-
let branches = flattenRoutes(routes);
|
16529
|
-
rankRouteBranches(branches);
|
16530
|
-
let matches = null;
|
16531
|
-
for (let i = 0; matches == null && i < branches.length; ++i) {
|
16532
|
-
let decoded = decodePath(pathname);
|
16533
|
-
matches = matchRouteBranch(
|
16534
|
-
branches[i],
|
16535
|
-
decoded,
|
16536
|
-
allowPartial
|
16537
|
-
);
|
16538
|
-
}
|
16539
|
-
return matches;
|
16540
|
-
}
|
16541
|
-
function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "") {
|
16542
|
-
let flattenRoute = (route, index, relativePath) => {
|
16543
|
-
let meta = {
|
16544
|
-
relativePath: relativePath === void 0 ? route.path || "" : relativePath,
|
16545
|
-
caseSensitive: route.caseSensitive === true,
|
16546
|
-
childrenIndex: index,
|
16547
|
-
route
|
16548
|
-
};
|
16549
|
-
if (meta.relativePath.startsWith("/")) {
|
16550
|
-
invariant(
|
16551
|
-
meta.relativePath.startsWith(parentPath),
|
16552
|
-
`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.`
|
16553
|
-
);
|
16554
|
-
meta.relativePath = meta.relativePath.slice(parentPath.length);
|
16555
|
-
}
|
16556
|
-
let path = joinPaths([parentPath, meta.relativePath]);
|
16557
|
-
let routesMeta = parentsMeta.concat(meta);
|
16558
|
-
if (route.children && route.children.length > 0) {
|
16559
|
-
invariant(
|
16560
|
-
// Our types know better, but runtime JS may not!
|
16561
|
-
// @ts-expect-error
|
16562
|
-
route.index !== true,
|
16563
|
-
`Index routes must not have child routes. Please remove all child routes from route path "${path}".`
|
16564
|
-
);
|
16565
|
-
flattenRoutes(route.children, branches, routesMeta, path);
|
16566
|
-
}
|
16567
|
-
if (route.path == null && !route.index) {
|
16568
|
-
return;
|
16569
|
-
}
|
16570
|
-
branches.push({
|
16571
|
-
path,
|
16572
|
-
score: computeScore(path, route.index),
|
16573
|
-
routesMeta
|
16574
|
-
});
|
16575
|
-
};
|
16576
|
-
routes.forEach((route, index) => {
|
16577
|
-
if (route.path === "" || !route.path?.includes("?")) {
|
16578
|
-
flattenRoute(route, index);
|
16579
|
-
} else {
|
16580
|
-
for (let exploded of explodeOptionalSegments(route.path)) {
|
16581
|
-
flattenRoute(route, index, exploded);
|
16582
|
-
}
|
16583
|
-
}
|
16584
|
-
});
|
16585
|
-
return branches;
|
16586
|
-
}
|
16587
|
-
function explodeOptionalSegments(path) {
|
16588
|
-
let segments = path.split("/");
|
16589
|
-
if (segments.length === 0) return [];
|
16590
|
-
let [first, ...rest] = segments;
|
16591
|
-
let isOptional = first.endsWith("?");
|
16592
|
-
let required = first.replace(/\?$/, "");
|
16593
|
-
if (rest.length === 0) {
|
16594
|
-
return isOptional ? [required, ""] : [required];
|
16595
|
-
}
|
16596
|
-
let restExploded = explodeOptionalSegments(rest.join("/"));
|
16597
|
-
let result = [];
|
16598
|
-
result.push(
|
16599
|
-
...restExploded.map(
|
16600
|
-
(subpath) => subpath === "" ? required : [required, subpath].join("/")
|
16601
|
-
)
|
16602
|
-
);
|
16603
|
-
if (isOptional) {
|
16604
|
-
result.push(...restExploded);
|
16605
|
-
}
|
16606
|
-
return result.map(
|
16607
|
-
(exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded
|
16608
|
-
);
|
16609
|
-
}
|
16610
|
-
function rankRouteBranches(branches) {
|
16611
|
-
branches.sort(
|
16612
|
-
(a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(
|
16613
|
-
a.routesMeta.map((meta) => meta.childrenIndex),
|
16614
|
-
b.routesMeta.map((meta) => meta.childrenIndex)
|
16615
|
-
)
|
16616
|
-
);
|
16617
|
-
}
|
16618
|
-
var paramRe = /^:[\w-]+$/;
|
16619
|
-
var dynamicSegmentValue = 3;
|
16620
|
-
var indexRouteValue = 2;
|
16621
|
-
var emptySegmentValue = 1;
|
16622
|
-
var staticSegmentValue = 10;
|
16623
|
-
var splatPenalty = -2;
|
16624
|
-
var isSplat = (s) => s === "*";
|
16625
|
-
function computeScore(path, index) {
|
16626
|
-
let segments = path.split("/");
|
16627
|
-
let initialScore = segments.length;
|
16628
|
-
if (segments.some(isSplat)) {
|
16629
|
-
initialScore += splatPenalty;
|
16630
|
-
}
|
16631
|
-
if (index) {
|
16632
|
-
initialScore += indexRouteValue;
|
16633
|
-
}
|
16634
|
-
return segments.filter((s) => !isSplat(s)).reduce(
|
16635
|
-
(score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
|
16636
|
-
initialScore
|
16637
|
-
);
|
16638
|
-
}
|
16639
|
-
function compareIndexes(a, b) {
|
16640
|
-
let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
|
16641
|
-
return siblings ? (
|
16642
|
-
// If two routes are siblings, we should try to match the earlier sibling
|
16643
|
-
// first. This allows people to have fine-grained control over the matching
|
16644
|
-
// behavior by simply putting routes with identical paths in the order they
|
16645
|
-
// want them tried.
|
16646
|
-
a[a.length - 1] - b[b.length - 1]
|
16647
|
-
) : (
|
16648
|
-
// Otherwise, it doesn't really make sense to rank non-siblings by index,
|
16649
|
-
// so they sort equally.
|
16650
|
-
0
|
16651
|
-
);
|
16652
|
-
}
|
16653
|
-
function matchRouteBranch(branch, pathname, allowPartial = false) {
|
16654
|
-
let { routesMeta } = branch;
|
16655
|
-
let matchedParams = {};
|
16656
|
-
let matchedPathname = "/";
|
16657
|
-
let matches = [];
|
16658
|
-
for (let i = 0; i < routesMeta.length; ++i) {
|
16659
|
-
let meta = routesMeta[i];
|
16660
|
-
let end = i === routesMeta.length - 1;
|
16661
|
-
let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
|
16662
|
-
let match = matchPath(
|
16663
|
-
{ path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
|
16664
|
-
remainingPathname
|
16665
|
-
);
|
16666
|
-
let route = meta.route;
|
16667
|
-
if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
|
16668
|
-
match = matchPath(
|
16669
|
-
{
|
16670
|
-
path: meta.relativePath,
|
16671
|
-
caseSensitive: meta.caseSensitive,
|
16672
|
-
end: false
|
16673
|
-
},
|
16674
|
-
remainingPathname
|
16675
|
-
);
|
16676
|
-
}
|
16677
|
-
if (!match) {
|
16678
|
-
return null;
|
16679
|
-
}
|
16680
|
-
Object.assign(matchedParams, match.params);
|
16681
|
-
matches.push({
|
16682
|
-
// TODO: Can this as be avoided?
|
16683
|
-
params: matchedParams,
|
16684
|
-
pathname: joinPaths([matchedPathname, match.pathname]),
|
16685
|
-
pathnameBase: normalizePathname(
|
16686
|
-
joinPaths([matchedPathname, match.pathnameBase])
|
16687
|
-
),
|
16688
|
-
route
|
16689
|
-
});
|
16690
|
-
if (match.pathnameBase !== "/") {
|
16691
|
-
matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
|
16692
|
-
}
|
16693
|
-
}
|
16694
|
-
return matches;
|
16695
|
-
}
|
16696
|
-
function matchPath(pattern, pathname) {
|
16697
|
-
if (typeof pattern === "string") {
|
16698
|
-
pattern = { path: pattern, caseSensitive: false, end: true };
|
16699
|
-
}
|
16700
|
-
let [matcher, compiledParams] = compilePath(
|
16701
|
-
pattern.path,
|
16702
|
-
pattern.caseSensitive,
|
16703
|
-
pattern.end
|
16704
|
-
);
|
16705
|
-
let match = pathname.match(matcher);
|
16706
|
-
if (!match) return null;
|
16707
|
-
let matchedPathname = match[0];
|
16708
|
-
let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
|
16709
|
-
let captureGroups = match.slice(1);
|
16710
|
-
let params = compiledParams.reduce(
|
16711
|
-
(memo2, { paramName, isOptional }, index) => {
|
16712
|
-
if (paramName === "*") {
|
16713
|
-
let splatValue = captureGroups[index] || "";
|
16714
|
-
pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
|
16715
|
-
}
|
16716
|
-
const value = captureGroups[index];
|
16717
|
-
if (isOptional && !value) {
|
16718
|
-
memo2[paramName] = void 0;
|
16719
|
-
} else {
|
16720
|
-
memo2[paramName] = (value || "").replace(/%2F/g, "/");
|
16721
|
-
}
|
16722
|
-
return memo2;
|
16723
|
-
},
|
16724
|
-
{}
|
16725
|
-
);
|
16726
|
-
return {
|
16727
|
-
params,
|
16728
|
-
pathname: matchedPathname,
|
16729
|
-
pathnameBase,
|
16730
|
-
pattern
|
16731
|
-
};
|
16732
|
-
}
|
16733
|
-
function compilePath(path, caseSensitive = false, end = true) {
|
16734
|
-
warning(
|
16735
|
-
path === "*" || !path.endsWith("*") || path.endsWith("/*"),
|
16736
|
-
`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(/\*$/, "/*")}".`
|
16737
|
-
);
|
16738
|
-
let params = [];
|
16739
|
-
let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(
|
16740
|
-
/\/:([\w-]+)(\?)?/g,
|
16741
|
-
(_, paramName, isOptional) => {
|
16742
|
-
params.push({ paramName, isOptional: isOptional != null });
|
16743
|
-
return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
|
16744
|
-
}
|
16745
|
-
);
|
16746
|
-
if (path.endsWith("*")) {
|
16747
|
-
params.push({ paramName: "*" });
|
16748
|
-
regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
|
16749
|
-
} else if (end) {
|
16750
|
-
regexpSource += "\\/*$";
|
16751
|
-
} else if (path !== "" && path !== "/") {
|
16752
|
-
regexpSource += "(?:(?=\\/|$))";
|
16753
|
-
} else ;
|
16754
|
-
let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
|
16755
|
-
return [matcher, params];
|
16756
|
-
}
|
16757
|
-
function decodePath(value) {
|
16758
|
-
try {
|
16759
|
-
return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
|
16760
|
-
} catch (error) {
|
16761
|
-
warning(
|
16762
|
-
false,
|
16763
|
-
`The URL path "${value}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`
|
16764
|
-
);
|
16765
|
-
return value;
|
16766
|
-
}
|
16767
|
-
}
|
16768
|
-
function stripBasename(pathname, basename) {
|
16769
|
-
if (basename === "/") return pathname;
|
16770
|
-
if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
|
16771
|
-
return null;
|
16772
|
-
}
|
16773
|
-
let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
|
16774
|
-
let nextChar = pathname.charAt(startIndex);
|
16775
|
-
if (nextChar && nextChar !== "/") {
|
16776
|
-
return null;
|
16777
|
-
}
|
16778
|
-
return pathname.slice(startIndex) || "/";
|
16779
|
-
}
|
16780
|
-
function resolvePath(to, fromPathname = "/") {
|
16781
|
-
let {
|
16782
|
-
pathname: toPathname,
|
16783
|
-
search = "",
|
16784
|
-
hash = ""
|
16785
|
-
} = typeof to === "string" ? parsePath(to) : to;
|
16786
|
-
let pathname = toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname(toPathname, fromPathname) : fromPathname;
|
16787
|
-
return {
|
16788
|
-
pathname,
|
16789
|
-
search: normalizeSearch(search),
|
16790
|
-
hash: normalizeHash(hash)
|
16791
|
-
};
|
16792
|
-
}
|
16793
|
-
function resolvePathname(relativePath, fromPathname) {
|
16794
|
-
let segments = fromPathname.replace(/\/+$/, "").split("/");
|
16795
|
-
let relativeSegments = relativePath.split("/");
|
16796
|
-
relativeSegments.forEach((segment) => {
|
16797
|
-
if (segment === "..") {
|
16798
|
-
if (segments.length > 1) segments.pop();
|
16799
|
-
} else if (segment !== ".") {
|
16800
|
-
segments.push(segment);
|
16801
|
-
}
|
16802
|
-
});
|
16803
|
-
return segments.length > 1 ? segments.join("/") : "/";
|
16804
|
-
}
|
16805
|
-
function getInvalidPathError(char, field, dest, path) {
|
16806
|
-
return `Cannot include a '${char}' character in a manually specified \`to.${field}\` field [${JSON.stringify(
|
16807
|
-
path
|
16808
|
-
)}]. 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.`;
|
16809
|
-
}
|
16810
|
-
function getPathContributingMatches(matches) {
|
16811
|
-
return matches.filter(
|
16812
|
-
(match, index) => index === 0 || match.route.path && match.route.path.length > 0
|
16813
|
-
);
|
16814
|
-
}
|
16815
|
-
function getResolveToMatches(matches) {
|
16816
|
-
let pathMatches = getPathContributingMatches(matches);
|
16817
|
-
return pathMatches.map(
|
16818
|
-
(match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase
|
16819
|
-
);
|
16820
|
-
}
|
16821
|
-
function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = false) {
|
16822
|
-
let to;
|
16823
|
-
if (typeof toArg === "string") {
|
16824
|
-
to = parsePath(toArg);
|
16825
|
-
} else {
|
16826
|
-
to = { ...toArg };
|
16827
|
-
invariant(
|
16828
|
-
!to.pathname || !to.pathname.includes("?"),
|
16829
|
-
getInvalidPathError("?", "pathname", "search", to)
|
16830
|
-
);
|
16831
|
-
invariant(
|
16832
|
-
!to.pathname || !to.pathname.includes("#"),
|
16833
|
-
getInvalidPathError("#", "pathname", "hash", to)
|
16834
|
-
);
|
16835
|
-
invariant(
|
16836
|
-
!to.search || !to.search.includes("#"),
|
16837
|
-
getInvalidPathError("#", "search", "hash", to)
|
16838
|
-
);
|
16839
|
-
}
|
16840
|
-
let isEmptyPath = toArg === "" || to.pathname === "";
|
16841
|
-
let toPathname = isEmptyPath ? "/" : to.pathname;
|
16842
|
-
let from;
|
16843
|
-
if (toPathname == null) {
|
16844
|
-
from = locationPathname;
|
16845
|
-
} else {
|
16846
|
-
let routePathnameIndex = routePathnames.length - 1;
|
16847
|
-
if (!isPathRelative && toPathname.startsWith("..")) {
|
16848
|
-
let toSegments = toPathname.split("/");
|
16849
|
-
while (toSegments[0] === "..") {
|
16850
|
-
toSegments.shift();
|
16851
|
-
routePathnameIndex -= 1;
|
16852
|
-
}
|
16853
|
-
to.pathname = toSegments.join("/");
|
16854
|
-
}
|
16855
|
-
from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
|
16856
|
-
}
|
16857
|
-
let path = resolvePath(to, from);
|
16858
|
-
let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
|
16859
|
-
let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
|
16860
|
-
if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
|
16861
|
-
path.pathname += "/";
|
16862
|
-
}
|
16863
|
-
return path;
|
16864
|
-
}
|
16865
|
-
var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
|
16866
|
-
var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
|
16867
|
-
var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
|
16868
|
-
var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
16869
|
-
function isRouteErrorResponse(error) {
|
16870
|
-
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
16871
|
-
}
|
16872
|
-
var validMutationMethodsArr = [
|
16873
|
-
"POST",
|
16874
|
-
"PUT",
|
16875
|
-
"PATCH",
|
16876
|
-
"DELETE"
|
16877
|
-
];
|
16878
|
-
new Set(
|
16879
|
-
validMutationMethodsArr
|
16880
|
-
);
|
16881
|
-
var validRequestMethodsArr = [
|
16882
|
-
"GET",
|
16883
|
-
...validMutationMethodsArr
|
16884
|
-
];
|
16885
|
-
new Set(validRequestMethodsArr);
|
16886
|
-
var DataRouterContext = React.createContext(null);
|
16887
|
-
DataRouterContext.displayName = "DataRouter";
|
16888
|
-
var DataRouterStateContext = React.createContext(null);
|
16889
|
-
DataRouterStateContext.displayName = "DataRouterState";
|
16890
|
-
var ViewTransitionContext = React.createContext({
|
16891
|
-
isTransitioning: false
|
16892
|
-
});
|
16893
|
-
ViewTransitionContext.displayName = "ViewTransition";
|
16894
|
-
var FetchersContext = React.createContext(
|
16895
|
-
/* @__PURE__ */ new Map()
|
16896
|
-
);
|
16897
|
-
FetchersContext.displayName = "Fetchers";
|
16898
|
-
var AwaitContext = React.createContext(null);
|
16899
|
-
AwaitContext.displayName = "Await";
|
16900
|
-
var NavigationContext = React.createContext(
|
16901
|
-
null
|
16902
|
-
);
|
16903
|
-
NavigationContext.displayName = "Navigation";
|
16904
|
-
var LocationContext = React.createContext(
|
16905
|
-
null
|
16906
|
-
);
|
16907
|
-
LocationContext.displayName = "Location";
|
16908
|
-
var RouteContext = React.createContext({
|
16909
|
-
outlet: null,
|
16910
|
-
matches: [],
|
16911
|
-
isDataRoute: false
|
16912
|
-
});
|
16913
|
-
RouteContext.displayName = "Route";
|
16914
|
-
var RouteErrorContext = React.createContext(null);
|
16915
|
-
RouteErrorContext.displayName = "RouteError";
|
16916
|
-
function useHref(to, { relative } = {}) {
|
16917
|
-
invariant(
|
16918
|
-
useInRouterContext(),
|
16919
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
16920
|
-
// router loaded. We can help them understand how to avoid that.
|
16921
|
-
`useHref() may be used only in the context of a <Router> component.`
|
16922
|
-
);
|
16923
|
-
let { basename, navigator } = React.useContext(NavigationContext);
|
16924
|
-
let { hash, pathname, search } = useResolvedPath(to, { relative });
|
16925
|
-
let joinedPathname = pathname;
|
16926
|
-
if (basename !== "/") {
|
16927
|
-
joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
|
16928
|
-
}
|
16929
|
-
return navigator.createHref({ pathname: joinedPathname, search, hash });
|
16930
|
-
}
|
16931
|
-
function useInRouterContext() {
|
16932
|
-
return React.useContext(LocationContext) != null;
|
16933
|
-
}
|
16934
|
-
function useLocation() {
|
16935
|
-
invariant(
|
16936
|
-
useInRouterContext(),
|
16937
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
16938
|
-
// router loaded. We can help them understand how to avoid that.
|
16939
|
-
`useLocation() may be used only in the context of a <Router> component.`
|
16940
|
-
);
|
16941
|
-
return React.useContext(LocationContext).location;
|
16942
|
-
}
|
16943
|
-
var navigateEffectWarning = `You should call navigate() in a React.useEffect(), not when your component is first rendered.`;
|
16944
|
-
function useIsomorphicLayoutEffect(cb) {
|
16945
|
-
let isStatic = React.useContext(NavigationContext).static;
|
16946
|
-
if (!isStatic) {
|
16947
|
-
React.useLayoutEffect(cb);
|
16948
|
-
}
|
16949
|
-
}
|
16950
|
-
function useNavigate() {
|
16951
|
-
let { isDataRoute } = React.useContext(RouteContext);
|
16952
|
-
return isDataRoute ? useNavigateStable() : useNavigateUnstable();
|
16953
|
-
}
|
16954
|
-
function useNavigateUnstable() {
|
16955
|
-
invariant(
|
16956
|
-
useInRouterContext(),
|
16957
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
16958
|
-
// router loaded. We can help them understand how to avoid that.
|
16959
|
-
`useNavigate() may be used only in the context of a <Router> component.`
|
16960
|
-
);
|
16961
|
-
let dataRouterContext = React.useContext(DataRouterContext);
|
16962
|
-
let { basename, navigator } = React.useContext(NavigationContext);
|
16963
|
-
let { matches } = React.useContext(RouteContext);
|
16964
|
-
let { pathname: locationPathname } = useLocation();
|
16965
|
-
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
16966
|
-
let activeRef = React.useRef(false);
|
16967
|
-
useIsomorphicLayoutEffect(() => {
|
16968
|
-
activeRef.current = true;
|
16969
|
-
});
|
16970
|
-
let navigate = React.useCallback(
|
16971
|
-
(to, options = {}) => {
|
16972
|
-
warning(activeRef.current, navigateEffectWarning);
|
16973
|
-
if (!activeRef.current) return;
|
16974
|
-
if (typeof to === "number") {
|
16975
|
-
navigator.go(to);
|
16976
|
-
return;
|
16977
|
-
}
|
16978
|
-
let path = resolveTo(
|
16979
|
-
to,
|
16980
|
-
JSON.parse(routePathnamesJson),
|
16981
|
-
locationPathname,
|
16982
|
-
options.relative === "path"
|
16983
|
-
);
|
16984
|
-
if (dataRouterContext == null && basename !== "/") {
|
16985
|
-
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
16986
|
-
}
|
16987
|
-
(!!options.replace ? navigator.replace : navigator.push)(
|
16988
|
-
path,
|
16989
|
-
options.state,
|
16990
|
-
options
|
16991
|
-
);
|
16992
|
-
},
|
16993
|
-
[
|
16994
|
-
basename,
|
16995
|
-
navigator,
|
16996
|
-
routePathnamesJson,
|
16997
|
-
locationPathname,
|
16998
|
-
dataRouterContext
|
16999
|
-
]
|
17000
|
-
);
|
17001
|
-
return navigate;
|
17002
|
-
}
|
17003
|
-
React.createContext(null);
|
17004
|
-
function useResolvedPath(to, { relative } = {}) {
|
17005
|
-
let { matches } = React.useContext(RouteContext);
|
17006
|
-
let { pathname: locationPathname } = useLocation();
|
17007
|
-
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
17008
|
-
return React.useMemo(
|
17009
|
-
() => resolveTo(
|
17010
|
-
to,
|
17011
|
-
JSON.parse(routePathnamesJson),
|
17012
|
-
locationPathname,
|
17013
|
-
relative === "path"
|
17014
|
-
),
|
17015
|
-
[to, routePathnamesJson, locationPathname, relative]
|
17016
|
-
);
|
17017
|
-
}
|
17018
|
-
function useRoutesImpl(routes, locationArg, dataRouterState, future) {
|
17019
|
-
invariant(
|
17020
|
-
useInRouterContext(),
|
17021
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
17022
|
-
// router loaded. We can help them understand how to avoid that.
|
17023
|
-
`useRoutes() may be used only in the context of a <Router> component.`
|
17024
|
-
);
|
17025
|
-
let { navigator, static: isStatic } = React.useContext(NavigationContext);
|
17026
|
-
let { matches: parentMatches } = React.useContext(RouteContext);
|
17027
|
-
let routeMatch = parentMatches[parentMatches.length - 1];
|
17028
|
-
let parentParams = routeMatch ? routeMatch.params : {};
|
17029
|
-
let parentPathname = routeMatch ? routeMatch.pathname : "/";
|
17030
|
-
let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
|
17031
|
-
let parentRoute = routeMatch && routeMatch.route;
|
17032
|
-
{
|
17033
|
-
let parentPath = parentRoute && parentRoute.path || "";
|
17034
|
-
warningOnce(
|
17035
|
-
parentPathname,
|
17036
|
-
!parentRoute || parentPath.endsWith("*") || parentPath.endsWith("*?"),
|
17037
|
-
`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${parentPathname}" (under <Route path="${parentPath}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
17038
|
-
|
17039
|
-
Please change the parent <Route path="${parentPath}"> to <Route path="${parentPath === "/" ? "*" : `${parentPath}/*`}">.`
|
17040
|
-
);
|
17041
|
-
}
|
17042
|
-
let locationFromContext = useLocation();
|
17043
|
-
let location;
|
17044
|
-
{
|
17045
|
-
location = locationFromContext;
|
17046
|
-
}
|
17047
|
-
let pathname = location.pathname || "/";
|
17048
|
-
let remainingPathname = pathname;
|
17049
|
-
if (parentPathnameBase !== "/") {
|
17050
|
-
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
|
17051
|
-
let segments = pathname.replace(/^\//, "").split("/");
|
17052
|
-
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
|
17053
|
-
}
|
17054
|
-
let matches = !isStatic && dataRouterState && dataRouterState.matches && dataRouterState.matches.length > 0 ? dataRouterState.matches : matchRoutes(routes, { pathname: remainingPathname });
|
17055
|
-
{
|
17056
|
-
warning(
|
17057
|
-
parentRoute || matches != null,
|
17058
|
-
`No routes matched location "${location.pathname}${location.search}${location.hash}" `
|
17059
|
-
);
|
17060
|
-
warning(
|
17061
|
-
matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0,
|
17062
|
-
`Matched leaf route at location "${location.pathname}${location.search}${location.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`
|
17063
|
-
);
|
17064
|
-
}
|
17065
|
-
let renderedMatches = _renderMatches(
|
17066
|
-
matches && matches.map(
|
17067
|
-
(match) => Object.assign({}, match, {
|
17068
|
-
params: Object.assign({}, parentParams, match.params),
|
17069
|
-
pathname: joinPaths([
|
17070
|
-
parentPathnameBase,
|
17071
|
-
// Re-encode pathnames that were decoded inside matchRoutes
|
17072
|
-
navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname
|
17073
|
-
]),
|
17074
|
-
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
|
17075
|
-
parentPathnameBase,
|
17076
|
-
// Re-encode pathnames that were decoded inside matchRoutes
|
17077
|
-
navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
|
17078
|
-
])
|
17079
|
-
})
|
17080
|
-
),
|
17081
|
-
parentMatches,
|
17082
|
-
dataRouterState,
|
17083
|
-
future
|
17084
|
-
);
|
17085
|
-
return renderedMatches;
|
17086
|
-
}
|
17087
|
-
function DefaultErrorComponent() {
|
17088
|
-
let error = useRouteError();
|
17089
|
-
let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
|
17090
|
-
let stack = error instanceof Error ? error.stack : null;
|
17091
|
-
let lightgrey = "rgba(200,200,200, 0.5)";
|
17092
|
-
let preStyles = { padding: "0.5rem", backgroundColor: lightgrey };
|
17093
|
-
let codeStyles = { padding: "2px 4px", backgroundColor: lightgrey };
|
17094
|
-
let devInfo = null;
|
17095
|
-
{
|
17096
|
-
console.error(
|
17097
|
-
"Error handled by React Router default ErrorBoundary:",
|
17098
|
-
error
|
17099
|
-
);
|
17100
|
-
devInfo = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React.createElement("code", { style: codeStyles }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React.createElement("code", { style: codeStyles }, "errorElement"), " prop on your route."));
|
17101
|
-
}
|
17102
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React.createElement("h3", { style: { fontStyle: "italic" } }, message), stack ? /* @__PURE__ */ React.createElement("pre", { style: preStyles }, stack) : null, devInfo);
|
17103
|
-
}
|
17104
|
-
var defaultErrorElement = /* @__PURE__ */ React.createElement(DefaultErrorComponent, null);
|
17105
|
-
var RenderErrorBoundary = class extends React.Component {
|
17106
|
-
constructor(props) {
|
17107
|
-
super(props);
|
17108
|
-
this.state = {
|
17109
|
-
location: props.location,
|
17110
|
-
revalidation: props.revalidation,
|
17111
|
-
error: props.error
|
17112
|
-
};
|
17113
|
-
}
|
17114
|
-
static getDerivedStateFromError(error) {
|
17115
|
-
return { error };
|
17116
|
-
}
|
17117
|
-
static getDerivedStateFromProps(props, state) {
|
17118
|
-
if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
|
17119
|
-
return {
|
17120
|
-
error: props.error,
|
17121
|
-
location: props.location,
|
17122
|
-
revalidation: props.revalidation
|
17123
|
-
};
|
17124
|
-
}
|
17125
|
-
return {
|
17126
|
-
error: props.error !== void 0 ? props.error : state.error,
|
17127
|
-
location: state.location,
|
17128
|
-
revalidation: props.revalidation || state.revalidation
|
17129
|
-
};
|
17130
|
-
}
|
17131
|
-
componentDidCatch(error, errorInfo) {
|
17132
|
-
console.error(
|
17133
|
-
"React Router caught the following error during render",
|
17134
|
-
error,
|
17135
|
-
errorInfo
|
17136
|
-
);
|
17137
|
-
}
|
17138
|
-
render() {
|
17139
|
-
return this.state.error !== void 0 ? /* @__PURE__ */ React.createElement(RouteContext.Provider, { value: this.props.routeContext }, /* @__PURE__ */ React.createElement(
|
17140
|
-
RouteErrorContext.Provider,
|
17141
|
-
{
|
17142
|
-
value: this.state.error,
|
17143
|
-
children: this.props.component
|
17144
|
-
}
|
17145
|
-
)) : this.props.children;
|
17146
|
-
}
|
17147
|
-
};
|
17148
|
-
function RenderedRoute({ routeContext, match, children }) {
|
17149
|
-
let dataRouterContext = React.useContext(DataRouterContext);
|
17150
|
-
if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
|
17151
|
-
dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
|
17152
|
-
}
|
17153
|
-
return /* @__PURE__ */ React.createElement(RouteContext.Provider, { value: routeContext }, children);
|
17154
|
-
}
|
17155
|
-
function _renderMatches(matches, parentMatches = [], dataRouterState = null, future = null) {
|
17156
|
-
if (matches == null) {
|
17157
|
-
if (!dataRouterState) {
|
17158
|
-
return null;
|
17159
|
-
}
|
17160
|
-
if (dataRouterState.errors) {
|
17161
|
-
matches = dataRouterState.matches;
|
17162
|
-
} else if (parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
|
17163
|
-
matches = dataRouterState.matches;
|
17164
|
-
} else {
|
17165
|
-
return null;
|
17166
|
-
}
|
17167
|
-
}
|
17168
|
-
let renderedMatches = matches;
|
17169
|
-
let errors = dataRouterState?.errors;
|
17170
|
-
if (errors != null) {
|
17171
|
-
let errorIndex = renderedMatches.findIndex(
|
17172
|
-
(m) => m.route.id && errors?.[m.route.id] !== void 0
|
17173
|
-
);
|
17174
|
-
invariant(
|
17175
|
-
errorIndex >= 0,
|
17176
|
-
`Could not find a matching route for errors on route IDs: ${Object.keys(
|
17177
|
-
errors
|
17178
|
-
).join(",")}`
|
17179
|
-
);
|
17180
|
-
renderedMatches = renderedMatches.slice(
|
17181
|
-
0,
|
17182
|
-
Math.min(renderedMatches.length, errorIndex + 1)
|
17183
|
-
);
|
17184
|
-
}
|
17185
|
-
let renderFallback = false;
|
17186
|
-
let fallbackIndex = -1;
|
17187
|
-
if (dataRouterState) {
|
17188
|
-
for (let i = 0; i < renderedMatches.length; i++) {
|
17189
|
-
let match = renderedMatches[i];
|
17190
|
-
if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
|
17191
|
-
fallbackIndex = i;
|
17192
|
-
}
|
17193
|
-
if (match.route.id) {
|
17194
|
-
let { loaderData, errors: errors2 } = dataRouterState;
|
17195
|
-
let needsToRunLoader = match.route.loader && !loaderData.hasOwnProperty(match.route.id) && (!errors2 || errors2[match.route.id] === void 0);
|
17196
|
-
if (match.route.lazy || needsToRunLoader) {
|
17197
|
-
renderFallback = true;
|
17198
|
-
if (fallbackIndex >= 0) {
|
17199
|
-
renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
|
17200
|
-
} else {
|
17201
|
-
renderedMatches = [renderedMatches[0]];
|
17202
|
-
}
|
17203
|
-
break;
|
17204
|
-
}
|
17205
|
-
}
|
17206
|
-
}
|
17207
|
-
}
|
17208
|
-
return renderedMatches.reduceRight((outlet, match, index) => {
|
17209
|
-
let error;
|
17210
|
-
let shouldRenderHydrateFallback = false;
|
17211
|
-
let errorElement = null;
|
17212
|
-
let hydrateFallbackElement = null;
|
17213
|
-
if (dataRouterState) {
|
17214
|
-
error = errors && match.route.id ? errors[match.route.id] : void 0;
|
17215
|
-
errorElement = match.route.errorElement || defaultErrorElement;
|
17216
|
-
if (renderFallback) {
|
17217
|
-
if (fallbackIndex < 0 && index === 0) {
|
17218
|
-
warningOnce(
|
17219
|
-
"route-fallback",
|
17220
|
-
false,
|
17221
|
-
"No `HydrateFallback` element provided to render during initial hydration"
|
17222
|
-
);
|
17223
|
-
shouldRenderHydrateFallback = true;
|
17224
|
-
hydrateFallbackElement = null;
|
17225
|
-
} else if (fallbackIndex === index) {
|
17226
|
-
shouldRenderHydrateFallback = true;
|
17227
|
-
hydrateFallbackElement = match.route.hydrateFallbackElement || null;
|
17228
|
-
}
|
17229
|
-
}
|
17230
|
-
}
|
17231
|
-
let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
|
17232
|
-
let getChildren = () => {
|
17233
|
-
let children;
|
17234
|
-
if (error) {
|
17235
|
-
children = errorElement;
|
17236
|
-
} else if (shouldRenderHydrateFallback) {
|
17237
|
-
children = hydrateFallbackElement;
|
17238
|
-
} else if (match.route.Component) {
|
17239
|
-
children = /* @__PURE__ */ React.createElement(match.route.Component, null);
|
17240
|
-
} else if (match.route.element) {
|
17241
|
-
children = match.route.element;
|
17242
|
-
} else {
|
17243
|
-
children = outlet;
|
17244
|
-
}
|
17245
|
-
return /* @__PURE__ */ React.createElement(
|
17246
|
-
RenderedRoute,
|
17247
|
-
{
|
17248
|
-
match,
|
17249
|
-
routeContext: {
|
17250
|
-
outlet,
|
17251
|
-
matches: matches2,
|
17252
|
-
isDataRoute: dataRouterState != null
|
17253
|
-
},
|
17254
|
-
children
|
17255
|
-
}
|
17256
|
-
);
|
17257
|
-
};
|
17258
|
-
return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React.createElement(
|
17259
|
-
RenderErrorBoundary,
|
17260
|
-
{
|
17261
|
-
location: dataRouterState.location,
|
17262
|
-
revalidation: dataRouterState.revalidation,
|
17263
|
-
component: errorElement,
|
17264
|
-
error,
|
17265
|
-
children: getChildren(),
|
17266
|
-
routeContext: { outlet: null, matches: matches2, isDataRoute: true }
|
17267
|
-
}
|
17268
|
-
) : getChildren();
|
17269
|
-
}, null);
|
17270
|
-
}
|
17271
|
-
function getDataRouterConsoleError(hookName) {
|
17272
|
-
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
17273
|
-
}
|
17274
|
-
function useDataRouterContext(hookName) {
|
17275
|
-
let ctx = React.useContext(DataRouterContext);
|
17276
|
-
invariant(ctx, getDataRouterConsoleError(hookName));
|
17277
|
-
return ctx;
|
17278
|
-
}
|
17279
|
-
function useDataRouterState(hookName) {
|
17280
|
-
let state = React.useContext(DataRouterStateContext);
|
17281
|
-
invariant(state, getDataRouterConsoleError(hookName));
|
17282
|
-
return state;
|
17283
|
-
}
|
17284
|
-
function useRouteContext(hookName) {
|
17285
|
-
let route = React.useContext(RouteContext);
|
17286
|
-
invariant(route, getDataRouterConsoleError(hookName));
|
17287
|
-
return route;
|
17288
|
-
}
|
17289
|
-
function useCurrentRouteId(hookName) {
|
17290
|
-
let route = useRouteContext(hookName);
|
17291
|
-
let thisRoute = route.matches[route.matches.length - 1];
|
17292
|
-
invariant(
|
17293
|
-
thisRoute.route.id,
|
17294
|
-
`${hookName} can only be used on routes that contain a unique "id"`
|
17295
|
-
);
|
17296
|
-
return thisRoute.route.id;
|
17297
|
-
}
|
17298
|
-
function useRouteId() {
|
17299
|
-
return useCurrentRouteId(
|
17300
|
-
"useRouteId"
|
17301
|
-
/* UseRouteId */
|
17302
|
-
);
|
17303
|
-
}
|
17304
|
-
function useRouteError() {
|
17305
|
-
let error = React.useContext(RouteErrorContext);
|
17306
|
-
let state = useDataRouterState(
|
17307
|
-
"useRouteError"
|
17308
|
-
/* UseRouteError */
|
17309
|
-
);
|
17310
|
-
let routeId = useCurrentRouteId(
|
17311
|
-
"useRouteError"
|
17312
|
-
/* UseRouteError */
|
17313
|
-
);
|
17314
|
-
if (error !== void 0) {
|
17315
|
-
return error;
|
17316
|
-
}
|
17317
|
-
return state.errors?.[routeId];
|
17318
|
-
}
|
17319
|
-
function useNavigateStable() {
|
17320
|
-
let { router } = useDataRouterContext(
|
17321
|
-
"useNavigate"
|
17322
|
-
/* UseNavigateStable */
|
17323
|
-
);
|
17324
|
-
let id = useCurrentRouteId(
|
17325
|
-
"useNavigate"
|
17326
|
-
/* UseNavigateStable */
|
17327
|
-
);
|
17328
|
-
let activeRef = React.useRef(false);
|
17329
|
-
useIsomorphicLayoutEffect(() => {
|
17330
|
-
activeRef.current = true;
|
17331
|
-
});
|
17332
|
-
let navigate = React.useCallback(
|
17333
|
-
async (to, options = {}) => {
|
17334
|
-
warning(activeRef.current, navigateEffectWarning);
|
17335
|
-
if (!activeRef.current) return;
|
17336
|
-
if (typeof to === "number") {
|
17337
|
-
router.navigate(to);
|
17338
|
-
} else {
|
17339
|
-
await router.navigate(to, { fromRouteId: id, ...options });
|
17340
|
-
}
|
17341
|
-
},
|
17342
|
-
[router, id]
|
17343
|
-
);
|
17344
|
-
return navigate;
|
17345
|
-
}
|
17346
|
-
var alreadyWarned = {};
|
17347
|
-
function warningOnce(key, cond, message) {
|
17348
|
-
if (!cond && !alreadyWarned[key]) {
|
17349
|
-
alreadyWarned[key] = true;
|
17350
|
-
warning(false, message);
|
17351
|
-
}
|
17352
|
-
}
|
17353
|
-
React.memo(DataRoutes);
|
17354
|
-
function DataRoutes({
|
17355
|
-
routes,
|
17356
|
-
future,
|
17357
|
-
state
|
17358
|
-
}) {
|
17359
|
-
return useRoutesImpl(routes, void 0, state, future);
|
17360
|
-
}
|
17361
|
-
var defaultMethod = "get";
|
17362
|
-
var defaultEncType = "application/x-www-form-urlencoded";
|
17363
|
-
function isHtmlElement(object) {
|
17364
|
-
return object != null && typeof object.tagName === "string";
|
17365
|
-
}
|
17366
|
-
function isButtonElement(object) {
|
17367
|
-
return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
|
17368
|
-
}
|
17369
|
-
function isFormElement(object) {
|
17370
|
-
return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
|
17371
|
-
}
|
17372
|
-
function isInputElement(object) {
|
17373
|
-
return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
|
17374
|
-
}
|
17375
|
-
function isModifiedEvent(event) {
|
17376
|
-
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
17377
|
-
}
|
17378
|
-
function shouldProcessLinkClick(event, target) {
|
17379
|
-
return event.button === 0 && // Ignore everything but left clicks
|
17380
|
-
(!target || target === "_self") && // Let browser handle "target=_blank" etc.
|
17381
|
-
!isModifiedEvent(event);
|
17382
|
-
}
|
17383
|
-
var _formDataSupportsSubmitter = null;
|
17384
|
-
function isFormDataSubmitterSupported() {
|
17385
|
-
if (_formDataSupportsSubmitter === null) {
|
17386
|
-
try {
|
17387
|
-
new FormData(
|
17388
|
-
document.createElement("form"),
|
17389
|
-
// @ts-expect-error if FormData supports the submitter parameter, this will throw
|
17390
|
-
0
|
17391
|
-
);
|
17392
|
-
_formDataSupportsSubmitter = false;
|
17393
|
-
} catch (e) {
|
17394
|
-
_formDataSupportsSubmitter = true;
|
17395
|
-
}
|
17396
|
-
}
|
17397
|
-
return _formDataSupportsSubmitter;
|
17398
|
-
}
|
17399
|
-
var supportedFormEncTypes = /* @__PURE__ */ new Set([
|
17400
|
-
"application/x-www-form-urlencoded",
|
17401
|
-
"multipart/form-data",
|
17402
|
-
"text/plain"
|
17403
|
-
]);
|
17404
|
-
function getFormEncType(encType) {
|
17405
|
-
if (encType != null && !supportedFormEncTypes.has(encType)) {
|
17406
|
-
warning(
|
17407
|
-
false,
|
17408
|
-
`"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
|
17409
|
-
);
|
17410
|
-
return null;
|
17411
|
-
}
|
17412
|
-
return encType;
|
17413
|
-
}
|
17414
|
-
function getFormSubmissionInfo(target, basename) {
|
17415
|
-
let method;
|
17416
|
-
let action;
|
17417
|
-
let encType;
|
17418
|
-
let formData;
|
17419
|
-
let body;
|
17420
|
-
if (isFormElement(target)) {
|
17421
|
-
let attr = target.getAttribute("action");
|
17422
|
-
action = attr ? stripBasename(attr, basename) : null;
|
17423
|
-
method = target.getAttribute("method") || defaultMethod;
|
17424
|
-
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
|
17425
|
-
formData = new FormData(target);
|
17426
|
-
} else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
|
17427
|
-
let form = target.form;
|
17428
|
-
if (form == null) {
|
17429
|
-
throw new Error(
|
17430
|
-
`Cannot submit a <button> or <input type="submit"> without a <form>`
|
17431
|
-
);
|
17432
|
-
}
|
17433
|
-
let attr = target.getAttribute("formaction") || form.getAttribute("action");
|
17434
|
-
action = attr ? stripBasename(attr, basename) : null;
|
17435
|
-
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
|
17436
|
-
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
|
17437
|
-
formData = new FormData(form, target);
|
17438
|
-
if (!isFormDataSubmitterSupported()) {
|
17439
|
-
let { name, type, value } = target;
|
17440
|
-
if (type === "image") {
|
17441
|
-
let prefix = name ? `${name}.` : "";
|
17442
|
-
formData.append(`${prefix}x`, "0");
|
17443
|
-
formData.append(`${prefix}y`, "0");
|
17444
|
-
} else if (name) {
|
17445
|
-
formData.append(name, value);
|
17446
|
-
}
|
17447
|
-
}
|
17448
|
-
} else if (isHtmlElement(target)) {
|
17449
|
-
throw new Error(
|
17450
|
-
`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
|
17451
|
-
);
|
17452
|
-
} else {
|
17453
|
-
method = defaultMethod;
|
17454
|
-
action = null;
|
17455
|
-
encType = defaultEncType;
|
17456
|
-
body = target;
|
17457
|
-
}
|
17458
|
-
if (formData && encType === "text/plain") {
|
17459
|
-
body = formData;
|
17460
|
-
formData = void 0;
|
17461
|
-
}
|
17462
|
-
return { action, method: method.toLowerCase(), encType, formData, body };
|
17463
|
-
}
|
17464
|
-
function invariant2(value, message) {
|
17465
|
-
if (value === false || value === null || typeof value === "undefined") {
|
17466
|
-
throw new Error(message);
|
17467
|
-
}
|
17468
|
-
}
|
17469
|
-
async function loadRouteModule(route, routeModulesCache) {
|
17470
|
-
if (route.id in routeModulesCache) {
|
17471
|
-
return routeModulesCache[route.id];
|
17472
|
-
}
|
17473
|
-
try {
|
17474
|
-
let routeModule = await import(
|
17475
|
-
/* @vite-ignore */
|
17476
|
-
/* webpackIgnore: true */
|
17477
|
-
route.module
|
17478
|
-
);
|
17479
|
-
routeModulesCache[route.id] = routeModule;
|
17480
|
-
return routeModule;
|
17481
|
-
} catch (error) {
|
17482
|
-
console.error(
|
17483
|
-
`Error loading route module \`${route.module}\`, reloading page...`
|
17484
|
-
);
|
17485
|
-
console.error(error);
|
17486
|
-
if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
|
17487
|
-
void 0) ;
|
17488
|
-
window.location.reload();
|
17489
|
-
return new Promise(() => {
|
17490
|
-
});
|
17491
|
-
}
|
17492
|
-
}
|
17493
|
-
function isHtmlLinkDescriptor(object) {
|
17494
|
-
if (object == null) {
|
17495
|
-
return false;
|
17496
|
-
}
|
17497
|
-
if (object.href == null) {
|
17498
|
-
return object.rel === "preload" && typeof object.imageSrcSet === "string" && typeof object.imageSizes === "string";
|
17499
|
-
}
|
17500
|
-
return typeof object.rel === "string" && typeof object.href === "string";
|
17501
|
-
}
|
17502
|
-
async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
|
17503
|
-
let links = await Promise.all(
|
17504
|
-
matches.map(async (match) => {
|
17505
|
-
let route = manifest.routes[match.route.id];
|
17506
|
-
if (route) {
|
17507
|
-
let mod = await loadRouteModule(route, routeModules);
|
17508
|
-
return mod.links ? mod.links() : [];
|
17509
|
-
}
|
17510
|
-
return [];
|
17511
|
-
})
|
17512
|
-
);
|
17513
|
-
return dedupeLinkDescriptors(
|
17514
|
-
links.flat(1).filter(isHtmlLinkDescriptor).filter((link) => link.rel === "stylesheet" || link.rel === "preload").map(
|
17515
|
-
(link) => link.rel === "stylesheet" ? { ...link, rel: "prefetch", as: "style" } : { ...link, rel: "prefetch" }
|
17516
|
-
)
|
17517
|
-
);
|
17518
|
-
}
|
17519
|
-
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
|
17520
|
-
let isNew = (match, index) => {
|
17521
|
-
if (!currentMatches[index]) return true;
|
17522
|
-
return match.route.id !== currentMatches[index].route.id;
|
17523
|
-
};
|
17524
|
-
let matchPathChanged = (match, index) => {
|
17525
|
-
return (
|
17526
|
-
// param change, /users/123 -> /users/456
|
17527
|
-
currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
|
17528
|
-
// e.g. /files/images/avatar.jpg -> files/finances.xls
|
17529
|
-
currentMatches[index].route.path?.endsWith("*") && currentMatches[index].params["*"] !== match.params["*"]
|
17530
|
-
);
|
17531
|
-
};
|
17532
|
-
if (mode === "assets") {
|
17533
|
-
return nextMatches.filter(
|
17534
|
-
(match, index) => isNew(match, index) || matchPathChanged(match, index)
|
17535
|
-
);
|
17536
|
-
}
|
17537
|
-
if (mode === "data") {
|
17538
|
-
return nextMatches.filter((match, index) => {
|
17539
|
-
let manifestRoute = manifest.routes[match.route.id];
|
17540
|
-
if (!manifestRoute || !manifestRoute.hasLoader) {
|
17541
|
-
return false;
|
17542
|
-
}
|
17543
|
-
if (isNew(match, index) || matchPathChanged(match, index)) {
|
17544
|
-
return true;
|
17545
|
-
}
|
17546
|
-
if (match.route.shouldRevalidate) {
|
17547
|
-
let routeChoice = match.route.shouldRevalidate({
|
17548
|
-
currentUrl: new URL(
|
17549
|
-
location.pathname + location.search + location.hash,
|
17550
|
-
window.origin
|
17551
|
-
),
|
17552
|
-
currentParams: currentMatches[0]?.params || {},
|
17553
|
-
nextUrl: new URL(page, window.origin),
|
17554
|
-
nextParams: match.params,
|
17555
|
-
defaultShouldRevalidate: true
|
17556
|
-
});
|
17557
|
-
if (typeof routeChoice === "boolean") {
|
17558
|
-
return routeChoice;
|
17559
|
-
}
|
17560
|
-
}
|
17561
|
-
return true;
|
17562
|
-
});
|
17563
|
-
}
|
17564
|
-
return [];
|
17565
|
-
}
|
17566
|
-
function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
|
17567
|
-
return dedupeHrefs(
|
17568
|
-
matches.map((match) => {
|
17569
|
-
let route = manifest.routes[match.route.id];
|
17570
|
-
if (!route) return [];
|
17571
|
-
let hrefs = [route.module];
|
17572
|
-
if (route.clientActionModule) {
|
17573
|
-
hrefs = hrefs.concat(route.clientActionModule);
|
17574
|
-
}
|
17575
|
-
if (route.clientLoaderModule) {
|
17576
|
-
hrefs = hrefs.concat(route.clientLoaderModule);
|
17577
|
-
}
|
17578
|
-
if (includeHydrateFallback && route.hydrateFallbackModule) {
|
17579
|
-
hrefs = hrefs.concat(route.hydrateFallbackModule);
|
17580
|
-
}
|
17581
|
-
if (route.imports) {
|
17582
|
-
hrefs = hrefs.concat(route.imports);
|
17583
|
-
}
|
17584
|
-
return hrefs;
|
17585
|
-
}).flat(1)
|
17586
|
-
);
|
17587
|
-
}
|
17588
|
-
function dedupeHrefs(hrefs) {
|
17589
|
-
return [...new Set(hrefs)];
|
17590
|
-
}
|
17591
|
-
function sortKeys(obj) {
|
17592
|
-
let sorted = {};
|
17593
|
-
let keys = Object.keys(obj).sort();
|
17594
|
-
for (let key of keys) {
|
17595
|
-
sorted[key] = obj[key];
|
17596
|
-
}
|
17597
|
-
return sorted;
|
17598
|
-
}
|
17599
|
-
function dedupeLinkDescriptors(descriptors, preloads) {
|
17600
|
-
let set = /* @__PURE__ */ new Set();
|
17601
|
-
new Set(preloads);
|
17602
|
-
return descriptors.reduce((deduped, descriptor) => {
|
17603
|
-
let key = JSON.stringify(sortKeys(descriptor));
|
17604
|
-
if (!set.has(key)) {
|
17605
|
-
set.add(key);
|
17606
|
-
deduped.push({ key, link: descriptor });
|
17607
|
-
}
|
17608
|
-
return deduped;
|
17609
|
-
}, []);
|
17610
|
-
}
|
17611
|
-
Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
17612
|
-
var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205]);
|
17613
|
-
function singleFetchUrl(reqUrl, basename) {
|
17614
|
-
let url = typeof reqUrl === "string" ? new URL(
|
17615
|
-
reqUrl,
|
17616
|
-
// This can be called during the SSR flow via PrefetchPageLinksImpl so
|
17617
|
-
// don't assume window is available
|
17618
|
-
typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
|
17619
|
-
) : reqUrl;
|
17620
|
-
if (url.pathname === "/") {
|
17621
|
-
url.pathname = "_root.data";
|
17622
|
-
} else if (basename && stripBasename(url.pathname, basename) === "/") {
|
17623
|
-
url.pathname = `${basename.replace(/\/$/, "")}/_root.data`;
|
17624
|
-
} else {
|
17625
|
-
url.pathname = `${url.pathname.replace(/\/$/, "")}.data`;
|
17626
|
-
}
|
17627
|
-
return url;
|
17628
|
-
}
|
17629
|
-
function useDataRouterContext2() {
|
17630
|
-
let context = React.useContext(DataRouterContext);
|
17631
|
-
invariant2(
|
17632
|
-
context,
|
17633
|
-
"You must render this element inside a <DataRouterContext.Provider> element"
|
17634
|
-
);
|
17635
|
-
return context;
|
17636
|
-
}
|
17637
|
-
function useDataRouterStateContext() {
|
17638
|
-
let context = React.useContext(DataRouterStateContext);
|
17639
|
-
invariant2(
|
17640
|
-
context,
|
17641
|
-
"You must render this element inside a <DataRouterStateContext.Provider> element"
|
17642
|
-
);
|
17643
|
-
return context;
|
17644
|
-
}
|
17645
|
-
var FrameworkContext = React.createContext(void 0);
|
17646
|
-
FrameworkContext.displayName = "FrameworkContext";
|
17647
|
-
function useFrameworkContext() {
|
17648
|
-
let context = React.useContext(FrameworkContext);
|
17649
|
-
invariant2(
|
17650
|
-
context,
|
17651
|
-
"You must render this element inside a <HydratedRouter> element"
|
17652
|
-
);
|
17653
|
-
return context;
|
17654
|
-
}
|
17655
|
-
function usePrefetchBehavior(prefetch, theirElementProps) {
|
17656
|
-
let frameworkContext = React.useContext(FrameworkContext);
|
17657
|
-
let [maybePrefetch, setMaybePrefetch] = React.useState(false);
|
17658
|
-
let [shouldPrefetch, setShouldPrefetch] = React.useState(false);
|
17659
|
-
let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
|
17660
|
-
let ref = React.useRef(null);
|
17661
|
-
React.useEffect(() => {
|
17662
|
-
if (prefetch === "render") {
|
17663
|
-
setShouldPrefetch(true);
|
17664
|
-
}
|
17665
|
-
if (prefetch === "viewport") {
|
17666
|
-
let callback = (entries) => {
|
17667
|
-
entries.forEach((entry) => {
|
17668
|
-
setShouldPrefetch(entry.isIntersecting);
|
17669
|
-
});
|
17670
|
-
};
|
17671
|
-
let observer = new IntersectionObserver(callback, { threshold: 0.5 });
|
17672
|
-
if (ref.current) observer.observe(ref.current);
|
17673
|
-
return () => {
|
17674
|
-
observer.disconnect();
|
17675
|
-
};
|
17676
|
-
}
|
17677
|
-
}, [prefetch]);
|
17678
|
-
React.useEffect(() => {
|
17679
|
-
if (maybePrefetch) {
|
17680
|
-
let id = setTimeout(() => {
|
17681
|
-
setShouldPrefetch(true);
|
17682
|
-
}, 100);
|
17683
|
-
return () => {
|
17684
|
-
clearTimeout(id);
|
17685
|
-
};
|
17686
|
-
}
|
17687
|
-
}, [maybePrefetch]);
|
17688
|
-
let setIntent = () => {
|
17689
|
-
setMaybePrefetch(true);
|
17690
|
-
};
|
17691
|
-
let cancelIntent = () => {
|
17692
|
-
setMaybePrefetch(false);
|
17693
|
-
setShouldPrefetch(false);
|
17694
|
-
};
|
17695
|
-
if (!frameworkContext) {
|
17696
|
-
return [false, ref, {}];
|
17697
|
-
}
|
17698
|
-
if (prefetch !== "intent") {
|
17699
|
-
return [shouldPrefetch, ref, {}];
|
17700
|
-
}
|
17701
|
-
return [
|
17702
|
-
shouldPrefetch,
|
17703
|
-
ref,
|
17704
|
-
{
|
17705
|
-
onFocus: composeEventHandlers(onFocus, setIntent),
|
17706
|
-
onBlur: composeEventHandlers(onBlur, cancelIntent),
|
17707
|
-
onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
|
17708
|
-
onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
|
17709
|
-
onTouchStart: composeEventHandlers(onTouchStart, setIntent)
|
17710
|
-
}
|
17711
|
-
];
|
17712
|
-
}
|
17713
|
-
function composeEventHandlers(theirHandler, ourHandler) {
|
17714
|
-
return (event) => {
|
17715
|
-
theirHandler && theirHandler(event);
|
17716
|
-
if (!event.defaultPrevented) {
|
17717
|
-
ourHandler(event);
|
17718
|
-
}
|
17719
|
-
};
|
17720
|
-
}
|
17721
|
-
function PrefetchPageLinks({
|
17722
|
-
page,
|
17723
|
-
...dataLinkProps
|
17724
|
-
}) {
|
17725
|
-
let { router } = useDataRouterContext2();
|
17726
|
-
let matches = React.useMemo(
|
17727
|
-
() => matchRoutes(router.routes, page, router.basename),
|
17728
|
-
[router.routes, page, router.basename]
|
17729
|
-
);
|
17730
|
-
if (!matches) {
|
17731
|
-
return null;
|
17732
|
-
}
|
17733
|
-
return /* @__PURE__ */ React.createElement(PrefetchPageLinksImpl, { page, matches, ...dataLinkProps });
|
17734
|
-
}
|
17735
|
-
function useKeyedPrefetchLinks(matches) {
|
17736
|
-
let { manifest, routeModules } = useFrameworkContext();
|
17737
|
-
let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React.useState([]);
|
17738
|
-
React.useEffect(() => {
|
17739
|
-
let interrupted = false;
|
17740
|
-
void getKeyedPrefetchLinks(matches, manifest, routeModules).then(
|
17741
|
-
(links) => {
|
17742
|
-
if (!interrupted) {
|
17743
|
-
setKeyedPrefetchLinks(links);
|
17744
|
-
}
|
17745
|
-
}
|
17746
|
-
);
|
17747
|
-
return () => {
|
17748
|
-
interrupted = true;
|
17749
|
-
};
|
17750
|
-
}, [matches, manifest, routeModules]);
|
17751
|
-
return keyedPrefetchLinks;
|
17752
|
-
}
|
17753
|
-
function PrefetchPageLinksImpl({
|
17754
|
-
page,
|
17755
|
-
matches: nextMatches,
|
17756
|
-
...linkProps
|
17757
|
-
}) {
|
17758
|
-
let location = useLocation();
|
17759
|
-
let { manifest, routeModules } = useFrameworkContext();
|
17760
|
-
let { basename } = useDataRouterContext2();
|
17761
|
-
let { loaderData, matches } = useDataRouterStateContext();
|
17762
|
-
let newMatchesForData = React.useMemo(
|
17763
|
-
() => getNewMatchesForLinks(
|
17764
|
-
page,
|
17765
|
-
nextMatches,
|
17766
|
-
matches,
|
17767
|
-
manifest,
|
17768
|
-
location,
|
17769
|
-
"data"
|
17770
|
-
),
|
17771
|
-
[page, nextMatches, matches, manifest, location]
|
17772
|
-
);
|
17773
|
-
let newMatchesForAssets = React.useMemo(
|
17774
|
-
() => getNewMatchesForLinks(
|
17775
|
-
page,
|
17776
|
-
nextMatches,
|
17777
|
-
matches,
|
17778
|
-
manifest,
|
17779
|
-
location,
|
17780
|
-
"assets"
|
17781
|
-
),
|
17782
|
-
[page, nextMatches, matches, manifest, location]
|
17783
|
-
);
|
17784
|
-
let dataHrefs = React.useMemo(() => {
|
17785
|
-
if (page === location.pathname + location.search + location.hash) {
|
17786
|
-
return [];
|
17787
|
-
}
|
17788
|
-
let routesParams = /* @__PURE__ */ new Set();
|
17789
|
-
let foundOptOutRoute = false;
|
17790
|
-
nextMatches.forEach((m) => {
|
17791
|
-
let manifestRoute = manifest.routes[m.route.id];
|
17792
|
-
if (!manifestRoute || !manifestRoute.hasLoader) {
|
17793
|
-
return;
|
17794
|
-
}
|
17795
|
-
if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && routeModules[m.route.id]?.shouldRevalidate) {
|
17796
|
-
foundOptOutRoute = true;
|
17797
|
-
} else if (manifestRoute.hasClientLoader) {
|
17798
|
-
foundOptOutRoute = true;
|
17799
|
-
} else {
|
17800
|
-
routesParams.add(m.route.id);
|
17801
|
-
}
|
17802
|
-
});
|
17803
|
-
if (routesParams.size === 0) {
|
17804
|
-
return [];
|
17805
|
-
}
|
17806
|
-
let url = singleFetchUrl(page, basename);
|
17807
|
-
if (foundOptOutRoute && routesParams.size > 0) {
|
17808
|
-
url.searchParams.set(
|
17809
|
-
"_routes",
|
17810
|
-
nextMatches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
|
17811
|
-
);
|
17812
|
-
}
|
17813
|
-
return [url.pathname + url.search];
|
17814
|
-
}, [
|
17815
|
-
basename,
|
17816
|
-
loaderData,
|
17817
|
-
location,
|
17818
|
-
manifest,
|
17819
|
-
newMatchesForData,
|
17820
|
-
nextMatches,
|
17821
|
-
page,
|
17822
|
-
routeModules
|
17823
|
-
]);
|
17824
|
-
let moduleHrefs = React.useMemo(
|
17825
|
-
() => getModuleLinkHrefs(newMatchesForAssets, manifest),
|
17826
|
-
[newMatchesForAssets, manifest]
|
17827
|
-
);
|
17828
|
-
let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
|
17829
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, dataHrefs.map((href2) => /* @__PURE__ */ React.createElement("link", { key: href2, rel: "prefetch", as: "fetch", href: href2, ...linkProps })), moduleHrefs.map((href2) => /* @__PURE__ */ React.createElement("link", { key: href2, rel: "modulepreload", href: href2, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
|
17830
|
-
// these don't spread `linkProps` because they are full link descriptors
|
17831
|
-
// already with their own props
|
17832
|
-
/* @__PURE__ */ React.createElement("link", { key, ...link })
|
17833
|
-
)));
|
17834
|
-
}
|
17835
|
-
function mergeRefs(...refs) {
|
17836
|
-
return (value) => {
|
17837
|
-
refs.forEach((ref) => {
|
17838
|
-
if (typeof ref === "function") {
|
17839
|
-
ref(value);
|
17840
|
-
} else if (ref != null) {
|
17841
|
-
ref.current = value;
|
17842
|
-
}
|
17843
|
-
});
|
17844
|
-
};
|
17845
|
-
}
|
17846
|
-
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
17847
|
-
try {
|
17848
|
-
if (isBrowser) {
|
17849
|
-
window.__reactRouterVersion = "7.6.0";
|
17850
|
-
}
|
17851
|
-
} catch (e) {
|
17852
|
-
}
|
17853
|
-
var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
17854
|
-
var Link = React.forwardRef(
|
17855
|
-
function LinkWithRef({
|
17856
|
-
onClick,
|
17857
|
-
discover = "render",
|
17858
|
-
prefetch = "none",
|
17859
|
-
relative,
|
17860
|
-
reloadDocument,
|
17861
|
-
replace: replace2,
|
17862
|
-
state,
|
17863
|
-
target,
|
17864
|
-
to,
|
17865
|
-
preventScrollReset,
|
17866
|
-
viewTransition,
|
17867
|
-
...rest
|
17868
|
-
}, forwardedRef) {
|
17869
|
-
let { basename } = React.useContext(NavigationContext);
|
17870
|
-
let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
|
17871
|
-
let absoluteHref;
|
17872
|
-
let isExternal = false;
|
17873
|
-
if (typeof to === "string" && isAbsolute) {
|
17874
|
-
absoluteHref = to;
|
17875
|
-
if (isBrowser) {
|
17876
|
-
try {
|
17877
|
-
let currentUrl = new URL(window.location.href);
|
17878
|
-
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
|
17879
|
-
let path = stripBasename(targetUrl.pathname, basename);
|
17880
|
-
if (targetUrl.origin === currentUrl.origin && path != null) {
|
17881
|
-
to = path + targetUrl.search + targetUrl.hash;
|
17882
|
-
} else {
|
17883
|
-
isExternal = true;
|
17884
|
-
}
|
17885
|
-
} catch (e) {
|
17886
|
-
warning(
|
17887
|
-
false,
|
17888
|
-
`<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
|
17889
|
-
);
|
17890
|
-
}
|
17891
|
-
}
|
17892
|
-
}
|
17893
|
-
let href2 = useHref(to, { relative });
|
17894
|
-
let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(
|
17895
|
-
prefetch,
|
17896
|
-
rest
|
17897
|
-
);
|
17898
|
-
let internalOnClick = useLinkClickHandler(to, {
|
17899
|
-
replace: replace2,
|
17900
|
-
state,
|
17901
|
-
target,
|
17902
|
-
preventScrollReset,
|
17903
|
-
relative,
|
17904
|
-
viewTransition
|
17905
|
-
});
|
17906
|
-
function handleClick(event) {
|
17907
|
-
if (onClick) onClick(event);
|
17908
|
-
if (!event.defaultPrevented) {
|
17909
|
-
internalOnClick(event);
|
17910
|
-
}
|
17911
|
-
}
|
17912
|
-
let link = (
|
17913
|
-
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
17914
|
-
/* @__PURE__ */ React.createElement(
|
17915
|
-
"a",
|
17916
|
-
{
|
17917
|
-
...rest,
|
17918
|
-
...prefetchHandlers,
|
17919
|
-
href: absoluteHref || href2,
|
17920
|
-
onClick: isExternal || reloadDocument ? onClick : handleClick,
|
17921
|
-
ref: mergeRefs(forwardedRef, prefetchRef),
|
17922
|
-
target,
|
17923
|
-
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
17924
|
-
}
|
17925
|
-
)
|
17926
|
-
);
|
17927
|
-
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(PrefetchPageLinks, { page: href2 })) : link;
|
17928
|
-
}
|
17929
|
-
);
|
17930
|
-
Link.displayName = "Link";
|
17931
|
-
var NavLink = React.forwardRef(
|
17932
|
-
function NavLinkWithRef({
|
17933
|
-
"aria-current": ariaCurrentProp = "page",
|
17934
|
-
caseSensitive = false,
|
17935
|
-
className: classNameProp = "",
|
17936
|
-
end = false,
|
17937
|
-
style: styleProp,
|
17938
|
-
to,
|
17939
|
-
viewTransition,
|
17940
|
-
children,
|
17941
|
-
...rest
|
17942
|
-
}, ref) {
|
17943
|
-
let path = useResolvedPath(to, { relative: rest.relative });
|
17944
|
-
let location = useLocation();
|
17945
|
-
let routerState = React.useContext(DataRouterStateContext);
|
17946
|
-
let { navigator, basename } = React.useContext(NavigationContext);
|
17947
|
-
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
17948
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
17949
|
-
useViewTransitionState(path) && viewTransition === true;
|
17950
|
-
let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
|
17951
|
-
let locationPathname = location.pathname;
|
17952
|
-
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
|
17953
|
-
if (!caseSensitive) {
|
17954
|
-
locationPathname = locationPathname.toLowerCase();
|
17955
|
-
nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
|
17956
|
-
toPathname = toPathname.toLowerCase();
|
17957
|
-
}
|
17958
|
-
if (nextLocationPathname && basename) {
|
17959
|
-
nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
|
17960
|
-
}
|
17961
|
-
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
|
17962
|
-
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
|
17963
|
-
let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
|
17964
|
-
let renderProps = {
|
17965
|
-
isActive,
|
17966
|
-
isPending,
|
17967
|
-
isTransitioning
|
17968
|
-
};
|
17969
|
-
let ariaCurrent = isActive ? ariaCurrentProp : void 0;
|
17970
|
-
let className;
|
17971
|
-
if (typeof classNameProp === "function") {
|
17972
|
-
className = classNameProp(renderProps);
|
17973
|
-
} else {
|
17974
|
-
className = [
|
17975
|
-
classNameProp,
|
17976
|
-
isActive ? "active" : null,
|
17977
|
-
isPending ? "pending" : null,
|
17978
|
-
isTransitioning ? "transitioning" : null
|
17979
|
-
].filter(Boolean).join(" ");
|
17980
|
-
}
|
17981
|
-
let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
|
17982
|
-
return /* @__PURE__ */ React.createElement(
|
17983
|
-
Link,
|
17984
|
-
{
|
17985
|
-
...rest,
|
17986
|
-
"aria-current": ariaCurrent,
|
17987
|
-
className,
|
17988
|
-
ref,
|
17989
|
-
style,
|
17990
|
-
to,
|
17991
|
-
viewTransition
|
17992
|
-
},
|
17993
|
-
typeof children === "function" ? children(renderProps) : children
|
17994
|
-
);
|
17995
|
-
}
|
17996
|
-
);
|
17997
|
-
NavLink.displayName = "NavLink";
|
17998
|
-
var Form = React.forwardRef(
|
17999
|
-
({
|
18000
|
-
discover = "render",
|
18001
|
-
fetcherKey,
|
18002
|
-
navigate,
|
18003
|
-
reloadDocument,
|
18004
|
-
replace: replace2,
|
18005
|
-
state,
|
18006
|
-
method = defaultMethod,
|
18007
|
-
action,
|
18008
|
-
onSubmit,
|
18009
|
-
relative,
|
18010
|
-
preventScrollReset,
|
18011
|
-
viewTransition,
|
18012
|
-
...props
|
18013
|
-
}, forwardedRef) => {
|
18014
|
-
let submit = useSubmit();
|
18015
|
-
let formAction = useFormAction(action, { relative });
|
18016
|
-
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
|
18017
|
-
let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
|
18018
|
-
let submitHandler = (event) => {
|
18019
|
-
onSubmit && onSubmit(event);
|
18020
|
-
if (event.defaultPrevented) return;
|
18021
|
-
event.preventDefault();
|
18022
|
-
let submitter = event.nativeEvent.submitter;
|
18023
|
-
let submitMethod = submitter?.getAttribute("formmethod") || method;
|
18024
|
-
submit(submitter || event.currentTarget, {
|
18025
|
-
fetcherKey,
|
18026
|
-
method: submitMethod,
|
18027
|
-
navigate,
|
18028
|
-
replace: replace2,
|
18029
|
-
state,
|
18030
|
-
relative,
|
18031
|
-
preventScrollReset,
|
18032
|
-
viewTransition
|
18033
|
-
});
|
18034
|
-
};
|
18035
|
-
return /* @__PURE__ */ React.createElement(
|
18036
|
-
"form",
|
18037
|
-
{
|
18038
|
-
ref: forwardedRef,
|
18039
|
-
method: formMethod,
|
18040
|
-
action: formAction,
|
18041
|
-
onSubmit: reloadDocument ? onSubmit : submitHandler,
|
18042
|
-
...props,
|
18043
|
-
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
18044
|
-
}
|
18045
|
-
);
|
18046
|
-
}
|
18047
|
-
);
|
18048
|
-
Form.displayName = "Form";
|
18049
|
-
function getDataRouterConsoleError2(hookName) {
|
18050
|
-
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
18051
|
-
}
|
18052
|
-
function useDataRouterContext3(hookName) {
|
18053
|
-
let ctx = React.useContext(DataRouterContext);
|
18054
|
-
invariant(ctx, getDataRouterConsoleError2(hookName));
|
18055
|
-
return ctx;
|
18056
|
-
}
|
18057
|
-
function useLinkClickHandler(to, {
|
18058
|
-
target,
|
18059
|
-
replace: replaceProp,
|
18060
|
-
state,
|
18061
|
-
preventScrollReset,
|
18062
|
-
relative,
|
18063
|
-
viewTransition
|
18064
|
-
} = {}) {
|
18065
|
-
let navigate = useNavigate();
|
18066
|
-
let location = useLocation();
|
18067
|
-
let path = useResolvedPath(to, { relative });
|
18068
|
-
return React.useCallback(
|
18069
|
-
(event) => {
|
18070
|
-
if (shouldProcessLinkClick(event, target)) {
|
18071
|
-
event.preventDefault();
|
18072
|
-
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
|
18073
|
-
navigate(to, {
|
18074
|
-
replace: replace2,
|
18075
|
-
state,
|
18076
|
-
preventScrollReset,
|
18077
|
-
relative,
|
18078
|
-
viewTransition
|
18079
|
-
});
|
18080
|
-
}
|
18081
|
-
},
|
18082
|
-
[
|
18083
|
-
location,
|
18084
|
-
navigate,
|
18085
|
-
path,
|
18086
|
-
replaceProp,
|
18087
|
-
state,
|
18088
|
-
target,
|
18089
|
-
to,
|
18090
|
-
preventScrollReset,
|
18091
|
-
relative,
|
18092
|
-
viewTransition
|
18093
|
-
]
|
18094
|
-
);
|
18095
|
-
}
|
18096
|
-
var fetcherId = 0;
|
18097
|
-
var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
|
18098
|
-
function useSubmit() {
|
18099
|
-
let { router } = useDataRouterContext3(
|
18100
|
-
"useSubmit"
|
18101
|
-
/* UseSubmit */
|
18102
|
-
);
|
18103
|
-
let { basename } = React.useContext(NavigationContext);
|
18104
|
-
let currentRouteId = useRouteId();
|
18105
|
-
return React.useCallback(
|
18106
|
-
async (target, options = {}) => {
|
18107
|
-
let { action, method, encType, formData, body } = getFormSubmissionInfo(
|
18108
|
-
target,
|
18109
|
-
basename
|
18110
|
-
);
|
18111
|
-
if (options.navigate === false) {
|
18112
|
-
let key = options.fetcherKey || getUniqueFetcherId();
|
18113
|
-
await router.fetch(key, currentRouteId, options.action || action, {
|
18114
|
-
preventScrollReset: options.preventScrollReset,
|
18115
|
-
formData,
|
18116
|
-
body,
|
18117
|
-
formMethod: options.method || method,
|
18118
|
-
formEncType: options.encType || encType,
|
18119
|
-
flushSync: options.flushSync
|
18120
|
-
});
|
18121
|
-
} else {
|
18122
|
-
await router.navigate(options.action || action, {
|
18123
|
-
preventScrollReset: options.preventScrollReset,
|
18124
|
-
formData,
|
18125
|
-
body,
|
18126
|
-
formMethod: options.method || method,
|
18127
|
-
formEncType: options.encType || encType,
|
18128
|
-
replace: options.replace,
|
18129
|
-
state: options.state,
|
18130
|
-
fromRouteId: currentRouteId,
|
18131
|
-
flushSync: options.flushSync,
|
18132
|
-
viewTransition: options.viewTransition
|
18133
|
-
});
|
18134
|
-
}
|
18135
|
-
},
|
18136
|
-
[router, basename, currentRouteId]
|
18137
|
-
);
|
18138
|
-
}
|
18139
|
-
function useFormAction(action, { relative } = {}) {
|
18140
|
-
let { basename } = React.useContext(NavigationContext);
|
18141
|
-
let routeContext = React.useContext(RouteContext);
|
18142
|
-
invariant(routeContext, "useFormAction must be used inside a RouteContext");
|
18143
|
-
let [match] = routeContext.matches.slice(-1);
|
18144
|
-
let path = { ...useResolvedPath(action ? action : ".", { relative }) };
|
18145
|
-
let location = useLocation();
|
18146
|
-
if (action == null) {
|
18147
|
-
path.search = location.search;
|
18148
|
-
let params = new URLSearchParams(path.search);
|
18149
|
-
let indexValues = params.getAll("index");
|
18150
|
-
let hasNakedIndexParam = indexValues.some((v) => v === "");
|
18151
|
-
if (hasNakedIndexParam) {
|
18152
|
-
params.delete("index");
|
18153
|
-
indexValues.filter((v) => v).forEach((v) => params.append("index", v));
|
18154
|
-
let qs = params.toString();
|
18155
|
-
path.search = qs ? `?${qs}` : "";
|
18156
|
-
}
|
18157
|
-
}
|
18158
|
-
if ((!action || action === ".") && match.route.index) {
|
18159
|
-
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
|
18160
|
-
}
|
18161
|
-
if (basename !== "/") {
|
18162
|
-
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
18163
|
-
}
|
18164
|
-
return createPath(path);
|
18165
|
-
}
|
18166
|
-
function useViewTransitionState(to, opts = {}) {
|
18167
|
-
let vtContext = React.useContext(ViewTransitionContext);
|
18168
|
-
invariant(
|
18169
|
-
vtContext != null,
|
18170
|
-
"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
|
18171
|
-
);
|
18172
|
-
let { basename } = useDataRouterContext3(
|
18173
|
-
"useViewTransitionState"
|
18174
|
-
/* useViewTransitionState */
|
18175
|
-
);
|
18176
|
-
let path = useResolvedPath(to, { relative: opts.relative });
|
18177
|
-
if (!vtContext.isTransitioning) {
|
18178
|
-
return false;
|
18179
|
-
}
|
18180
|
-
let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
|
18181
|
-
let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
|
18182
|
-
return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
|
18183
|
-
}
|
18184
|
-
/* @__PURE__ */ new Set([
|
18185
|
-
...NO_BODY_STATUS_CODES,
|
18186
|
-
304
|
18187
|
-
]);
|
18188
|
-
|
18189
16216
|
const userInfo = {
|
18190
16217
|
avatar: "https://img.freepik.com/premium-vector/character-avatar-isolated_729149-194801.jpg?semt=ais_hybrid&w=740",
|
18191
16218
|
name: "username",
|