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