storybook 10.1.0-alpha.9 → 10.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
- package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
- package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
- package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
- package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
- package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
- package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
- package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
- package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
- package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
- package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
- package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
- package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
- package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
- package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
- package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
- package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
- package/dist/_browser-chunks/chunk-FQ7SLVLR.js +66 -0
- package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
- package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -0
- package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
- package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
- package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
- package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
- package/dist/_browser-chunks/{chunk-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
- package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -0
- package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
- package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
- package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
- package/dist/_browser-chunks/chunk-SS2NHR7W.js +2969 -0
- package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
- package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
- package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
- package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
- package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
- package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
- package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
- package/dist/_browser-chunks/{syntaxhighlighter-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
- package/dist/_node-chunks/{builder-manager-SM3UWERX.js → builder-manager-BDAQHXFI.js} +510 -1019
- package/dist/_node-chunks/camelcase-3C7DZZPX.js +37 -0
- package/dist/_node-chunks/chunk-2IIQTGNE.js +6024 -0
- package/dist/_node-chunks/chunk-56U5LEMP.js +3043 -0
- package/dist/_node-chunks/chunk-7LIRCAQE.js +20 -0
- package/dist/_node-chunks/chunk-7RN6TXKP.js +603 -0
- package/dist/_node-chunks/chunk-7SJ7PZNL.js +4523 -0
- package/dist/_node-chunks/{chunk-HHSTA6QS.js → chunk-BG4RDXG7.js} +8 -10
- package/dist/_node-chunks/chunk-CBQKMXLQ.js +18 -0
- package/dist/_node-chunks/chunk-CN2IW2KQ.js +1564 -0
- package/dist/_node-chunks/chunk-CQMAU6UQ.js +943 -0
- package/dist/_node-chunks/{chunk-EBUEXRH5.js → chunk-D6ND3TVY.js} +116 -276
- package/dist/_node-chunks/chunk-DC355CYB.js +61 -0
- package/dist/_node-chunks/{chunk-SGM3ZCCT.js → chunk-EVK2SBW5.js} +292 -688
- package/dist/_node-chunks/chunk-IXWEUXJ2.js +119 -0
- package/dist/_node-chunks/{chunk-F6EFOEC7.js → chunk-KVRF22SH.js} +469 -983
- package/dist/_node-chunks/chunk-LEDP4QQW.js +919 -0
- package/dist/_node-chunks/{chunk-GHIBZRKD.js → chunk-MMVV6DGG.js} +8133 -8887
- package/dist/_node-chunks/chunk-O5CGEVRI.js +29 -0
- package/dist/_node-chunks/chunk-OZZO56XN.js +299 -0
- package/dist/_node-chunks/chunk-POT2EVGD.js +78 -0
- package/dist/_node-chunks/chunk-R5YGFSTV.js +3781 -0
- package/dist/_node-chunks/chunk-SQCTM2OS.js +23 -0
- package/dist/_node-chunks/chunk-UFOFO5H7.js +54 -0
- package/dist/_node-chunks/chunk-VBF7ALJF.js +72 -0
- package/dist/_node-chunks/chunk-W6MAMTUF.js +70 -0
- package/dist/_node-chunks/chunk-WURL4XOT.js +46662 -0
- package/dist/_node-chunks/chunk-XGK6MVKR.js +61 -0
- package/dist/_node-chunks/chunk-YV3GDSDT.js +765 -0
- package/dist/_node-chunks/{chunk-ATDHMMIZ.js → chunk-YWV55YW3.js} +15 -24
- package/dist/_node-chunks/dist-KEP4IFRN.js +121 -0
- package/dist/_node-chunks/globby-4WUBTDCN.js +3452 -0
- package/dist/_node-chunks/lib-JVOEKTYM.js +366 -0
- package/dist/_node-chunks/mdx-N42X6CFJ-C5WFYYXR.js +14329 -0
- package/dist/_node-chunks/p-limit-LDY632RS.js +116 -0
- package/dist/actions/decorator.js +21 -42
- package/dist/actions/index.js +3 -3
- package/dist/babel/index.d.ts +671 -335
- package/dist/babel/index.js +10 -11
- package/dist/bin/core.js +601 -1548
- package/dist/bin/dispatcher.js +36 -36
- package/dist/bin/loader.js +24 -38
- package/dist/channels/index.js +98 -234
- package/dist/cli/index.d.ts +1479 -133
- package/dist/cli/index.js +30 -8540
- package/dist/client-logger/index.js +31 -61
- package/dist/common/index.d.ts +139 -62
- package/dist/common/index.js +66 -51
- package/dist/components/index.d.ts +575 -273
- package/dist/components/index.js +14863 -4313
- package/dist/core-events/index.js +2 -66
- package/dist/core-server/index.d.ts +3 -2
- package/dist/core-server/index.js +2908 -8518
- package/dist/core-server/presets/common-manager.css +2 -2
- package/dist/core-server/presets/common-manager.js +2521 -5233
- package/dist/core-server/presets/common-override-preset.js +31 -60
- package/dist/core-server/presets/common-preset.js +663 -962
- package/dist/csf/index.js +534 -1179
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +6 -6
- package/dist/highlight/index.js +2 -2
- package/dist/instrumenter/index.js +199 -415
- package/dist/manager/globals-runtime.js +59044 -67141
- package/dist/manager/globals.js +2 -3
- package/dist/manager/manager-stores.d.ts +1 -0
- package/dist/manager/manager-stores.js +23 -0
- package/dist/manager/runtime.js +11511 -10953
- package/dist/manager-api/index.d.ts +1811 -2
- package/dist/manager-api/index.js +1348 -2401
- package/dist/manager-errors.d.ts +9 -0
- package/dist/manager-errors.js +3 -3
- package/dist/mocking-utils/index.d.ts +1126 -0
- package/dist/mocking-utils/index.js +1181 -0
- package/dist/node-logger/index.d.ts +192 -24
- package/dist/node-logger/index.js +23 -4471
- package/dist/preview/globals.js +2 -3
- package/dist/preview/runtime.js +10799 -22393
- package/dist/preview-api/index.d.ts +68 -69
- package/dist/preview-api/index.js +13 -13
- package/dist/preview-errors.d.ts +9 -0
- package/dist/preview-errors.js +4 -4
- package/dist/router/index.js +347 -899
- package/dist/server-errors.d.ts +34 -1
- package/dist/server-errors.js +17 -10
- package/dist/telemetry/index.d.ts +24 -3
- package/dist/telemetry/index.js +25 -24
- package/dist/test/index.js +6131 -11916
- package/dist/theming/create.d.ts +1 -0
- package/dist/theming/create.js +4 -4
- package/dist/theming/index.d.ts +3366 -2599
- package/dist/theming/index.js +501 -1091
- package/dist/types/index.d.ts +72 -8
- package/dist/types/index.js +27 -12
- package/dist/viewport/index.js +3 -3
- package/package.json +26 -17
- package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
- package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
- package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
- package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
- package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
- package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
- package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
- package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
- package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
- package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
- package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
- package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
- package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
- package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
- package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
- package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
- package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
- package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
- package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
- package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
- package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
- package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
- package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
- package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
- package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
- package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
- package/dist/_node-chunks/camelcase-H5QSGQLK.js +0 -18
- package/dist/_node-chunks/chunk-3THWHQOC.js +0 -61
- package/dist/_node-chunks/chunk-45YUOLTU.js +0 -69
- package/dist/_node-chunks/chunk-4QSNCPAU.js +0 -64656
- package/dist/_node-chunks/chunk-744PQSOU.js +0 -79
- package/dist/_node-chunks/chunk-74Z2U7QG.js +0 -1544
- package/dist/_node-chunks/chunk-7MB7TFPO.js +0 -1198
- package/dist/_node-chunks/chunk-A7GS4RFT.js +0 -697
- package/dist/_node-chunks/chunk-BIA3A5UM.js +0 -61
- package/dist/_node-chunks/chunk-C5G7CLWX.js +0 -1657
- package/dist/_node-chunks/chunk-DLFUKMYJ.js +0 -1531
- package/dist/_node-chunks/chunk-EMRGRXKT.js +0 -111
- package/dist/_node-chunks/chunk-EX46EHHY.js +0 -420
- package/dist/_node-chunks/chunk-F76QKNOJ.js +0 -304
- package/dist/_node-chunks/chunk-HDCRUTEF.js +0 -220
- package/dist/_node-chunks/chunk-HUYAOIPH.js +0 -90
- package/dist/_node-chunks/chunk-IBJZQZJC.js +0 -101
- package/dist/_node-chunks/chunk-KZN2RDDT.js +0 -6712
- package/dist/_node-chunks/chunk-LYUNFU3F.js +0 -4741
- package/dist/_node-chunks/chunk-N44SIS6K.js +0 -28
- package/dist/_node-chunks/chunk-NILZM6KR.js +0 -18
- package/dist/_node-chunks/chunk-PC4ZRP6W.js +0 -34
- package/dist/_node-chunks/chunk-TJNGOQUH.js +0 -4272
- package/dist/_node-chunks/chunk-UBSYLHIL.js +0 -1250
- package/dist/_node-chunks/chunk-UTCLXPOC.js +0 -1518
- package/dist/_node-chunks/chunk-WOXXODXP.js +0 -5029
- package/dist/_node-chunks/chunk-XC4MEUA6.js +0 -1586
- package/dist/_node-chunks/chunk-YRXXMKRR.js +0 -2256
- package/dist/_node-chunks/dist-SL73W244.js +0 -175
- package/dist/_node-chunks/globby-ZSHAUQZ5.js +0 -5222
- package/dist/_node-chunks/lib-U2VIPUTI.js +0 -518
- package/dist/_node-chunks/mdx-N42X6CFJ-ZLHD33JK.js +0 -22017
- package/dist/_node-chunks/p-limit-K5BS5MSV.js +0 -168
- package/dist/_node-chunks/plugin-5PD4YIUH.js +0 -129
- package/dist/_node-chunks/plugin-MONDT2WL.js +0 -159
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-EUZJRG3W.js +0 -69102
- package/dist/_node-chunks/webpack-mock-plugin-T4LDXEHE.js +0 -124
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
package/dist/router/index.js
CHANGED
|
@@ -1,141 +1,61 @@
|
|
|
1
1
|
import {
|
|
2
2
|
require_main
|
|
3
|
-
} from "../_browser-chunks/chunk-
|
|
3
|
+
} from "../_browser-chunks/chunk-3OXGAGBE.js";
|
|
4
4
|
import {
|
|
5
5
|
isEqual
|
|
6
|
-
} from "../_browser-chunks/chunk-
|
|
7
|
-
import "../_browser-chunks/chunk-
|
|
6
|
+
} from "../_browser-chunks/chunk-3IAH5M2U.js";
|
|
7
|
+
import "../_browser-chunks/chunk-QKODTO7K.js";
|
|
8
8
|
import {
|
|
9
9
|
isPlainObject
|
|
10
|
-
} from "../_browser-chunks/chunk-
|
|
10
|
+
} from "../_browser-chunks/chunk-GFLS4VP3.js";
|
|
11
11
|
import {
|
|
12
12
|
require_memoizerific
|
|
13
|
-
} from "../_browser-chunks/chunk-
|
|
13
|
+
} from "../_browser-chunks/chunk-WJYERY3R.js";
|
|
14
14
|
import {
|
|
15
15
|
dedent
|
|
16
|
-
} from "../_browser-chunks/chunk-
|
|
16
|
+
} from "../_browser-chunks/chunk-JP7NCOJX.js";
|
|
17
17
|
import {
|
|
18
|
-
__name,
|
|
19
18
|
__toESM
|
|
20
|
-
} from "../_browser-chunks/chunk-
|
|
19
|
+
} from "../_browser-chunks/chunk-A242L54C.js";
|
|
21
20
|
|
|
22
21
|
// src/router/utils.ts
|
|
23
22
|
import { once } from "storybook/internal/client-logger";
|
|
24
|
-
var import_memoizerific = __toESM(require_memoizerific(), 1);
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
var parsePath = (0, import_memoizerific.default)(1e3)((path) => {
|
|
28
|
-
const result = {
|
|
23
|
+
var import_memoizerific = __toESM(require_memoizerific(), 1), import_picoquery = __toESM(require_main(), 1);
|
|
24
|
+
var splitPathRegex = /\/([^/]+)\/(?:(.*)_)?([^/]+)?/, parsePath = (0, import_memoizerific.default)(1e3)((path) => {
|
|
25
|
+
let result = {
|
|
29
26
|
viewMode: void 0,
|
|
30
27
|
storyId: void 0,
|
|
31
28
|
refId: void 0
|
|
32
29
|
};
|
|
33
30
|
if (path) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
}
|
|
31
|
+
let [, viewMode, refId, storyId] = path.toLowerCase().match(splitPathRegex) || [];
|
|
32
|
+
viewMode && Object.assign(result, {
|
|
33
|
+
viewMode,
|
|
34
|
+
storyId,
|
|
35
|
+
refId
|
|
36
|
+
});
|
|
42
37
|
}
|
|
43
38
|
return result;
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
var deepDiff = /* @__PURE__ */ __name((value, update) => {
|
|
47
|
-
if (typeof value !== typeof update) {
|
|
39
|
+
}), DEEPLY_EQUAL = Symbol("Deeply equal"), deepDiff = (value, update) => {
|
|
40
|
+
if (typeof value != typeof update)
|
|
48
41
|
return update;
|
|
49
|
-
|
|
50
|
-
if (isEqual(value, update)) {
|
|
42
|
+
if (isEqual(value, update))
|
|
51
43
|
return DEEPLY_EQUAL;
|
|
52
|
-
}
|
|
53
44
|
if (Array.isArray(value) && Array.isArray(update)) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
acc[index] = diff;
|
|
58
|
-
}
|
|
59
|
-
return acc;
|
|
45
|
+
let res = update.reduce((acc, upd, index) => {
|
|
46
|
+
let diff = deepDiff(value[index], upd);
|
|
47
|
+
return diff !== DEEPLY_EQUAL && (acc[index] = diff), acc;
|
|
60
48
|
}, new Array(update.length));
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
return update;
|
|
73
|
-
}, "deepDiff");
|
|
74
|
-
var VALIDATION_REGEXP = /^[a-zA-Z0-9 _-]*$/;
|
|
75
|
-
var NUMBER_REGEXP = /^-?[0-9]+(\.[0-9]+)?$/;
|
|
76
|
-
var HEX_REGEXP = /^#([a-f0-9]{3,4}|[a-f0-9]{6}|[a-f0-9]{8})$/i;
|
|
77
|
-
var COLOR_REGEXP = /^(rgba?|hsla?)\(([0-9]{1,3}),\s?([0-9]{1,3})%?,\s?([0-9]{1,3})%?,?\s?([0-9](\.[0-9]{1,2})?)?\)$/i;
|
|
78
|
-
var validateArgs = /* @__PURE__ */ __name((key = "", value) => {
|
|
79
|
-
if (key === null) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
if (key === "" || !VALIDATION_REGEXP.test(key)) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
if (value === null || value === void 0) {
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
if (value instanceof Date) {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
if (typeof value === "string") {
|
|
95
|
-
return VALIDATION_REGEXP.test(value) || NUMBER_REGEXP.test(value) || HEX_REGEXP.test(value) || COLOR_REGEXP.test(value);
|
|
96
|
-
}
|
|
97
|
-
if (Array.isArray(value)) {
|
|
98
|
-
return value.every((v) => validateArgs(key, v));
|
|
99
|
-
}
|
|
100
|
-
if (isPlainObject(value)) {
|
|
101
|
-
return Object.entries(value).every(([k, v]) => validateArgs(k, v));
|
|
102
|
-
}
|
|
103
|
-
return false;
|
|
104
|
-
}, "validateArgs");
|
|
105
|
-
var encodeSpecialValues = /* @__PURE__ */ __name((value) => {
|
|
106
|
-
if (value === void 0) {
|
|
107
|
-
return "!undefined";
|
|
108
|
-
}
|
|
109
|
-
if (value === null) {
|
|
110
|
-
return "!null";
|
|
111
|
-
}
|
|
112
|
-
if (typeof value === "string") {
|
|
113
|
-
if (HEX_REGEXP.test(value)) {
|
|
114
|
-
return `!hex(${value.slice(1)})`;
|
|
115
|
-
}
|
|
116
|
-
if (COLOR_REGEXP.test(value)) {
|
|
117
|
-
return `!${value.replace(/[\s%]/g, "")}`;
|
|
118
|
-
}
|
|
119
|
-
return value;
|
|
120
|
-
}
|
|
121
|
-
if (typeof value === "boolean") {
|
|
122
|
-
return `!${value}`;
|
|
123
|
-
}
|
|
124
|
-
if (value instanceof Date) {
|
|
125
|
-
return `!date(${value.toISOString()})`;
|
|
126
|
-
}
|
|
127
|
-
if (Array.isArray(value)) {
|
|
128
|
-
return value.map(encodeSpecialValues);
|
|
129
|
-
}
|
|
130
|
-
if (isPlainObject(value)) {
|
|
131
|
-
return Object.entries(value).reduce(
|
|
132
|
-
(acc, [key, val]) => Object.assign(acc, { [key]: encodeSpecialValues(val) }),
|
|
133
|
-
{}
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
return value;
|
|
137
|
-
}, "encodeSpecialValues");
|
|
138
|
-
var decodeKnownQueryChar = /* @__PURE__ */ __name((chr) => {
|
|
49
|
+
return update.length >= value.length ? res : res.concat(new Array(value.length - update.length).fill(void 0));
|
|
50
|
+
}
|
|
51
|
+
return isPlainObject(value) && isPlainObject(update) ? Object.keys({ ...value, ...update }).reduce((acc, key) => {
|
|
52
|
+
let diff = deepDiff(value?.[key], update?.[key]);
|
|
53
|
+
return diff === DEEPLY_EQUAL ? acc : Object.assign(acc, { [key]: diff });
|
|
54
|
+
}, {}) : update;
|
|
55
|
+
}, VALIDATION_REGEXP = /^[a-zA-Z0-9 _-]*$/, NUMBER_REGEXP = /^-?[0-9]+(\.[0-9]+)?$/, HEX_REGEXP = /^#([a-f0-9]{3,4}|[a-f0-9]{6}|[a-f0-9]{8})$/i, COLOR_REGEXP = /^(rgba?|hsla?)\(([0-9]{1,3}),\s?([0-9]{1,3})%?,\s?([0-9]{1,3})%?,?\s?([0-9](\.[0-9]{1,2})?)?\)$/i, validateArgs = (key = "", value) => key === null || key === "" || !VALIDATION_REGEXP.test(key) ? !1 : value == null || value instanceof Date || typeof value == "number" || typeof value == "boolean" ? !0 : typeof value == "string" ? VALIDATION_REGEXP.test(value) || NUMBER_REGEXP.test(value) || HEX_REGEXP.test(value) || COLOR_REGEXP.test(value) : Array.isArray(value) ? value.every((v) => validateArgs(key, v)) : isPlainObject(value) ? Object.entries(value).every(([k, v]) => validateArgs(k, v)) : !1, encodeSpecialValues = (value) => value === void 0 ? "!undefined" : value === null ? "!null" : typeof value == "string" ? HEX_REGEXP.test(value) ? `!hex(${value.slice(1)})` : COLOR_REGEXP.test(value) ? `!${value.replace(/[\s%]/g, "")}` : value : typeof value == "boolean" ? `!${value}` : value instanceof Date ? `!date(${value.toISOString()})` : Array.isArray(value) ? value.map(encodeSpecialValues) : isPlainObject(value) ? Object.entries(value).reduce(
|
|
56
|
+
(acc, [key, val]) => Object.assign(acc, { [key]: encodeSpecialValues(val) }),
|
|
57
|
+
{}
|
|
58
|
+
) : value, decodeKnownQueryChar = (chr) => {
|
|
139
59
|
switch (chr) {
|
|
140
60
|
case "%20":
|
|
141
61
|
return "+";
|
|
@@ -149,57 +69,33 @@ var decodeKnownQueryChar = /* @__PURE__ */ __name((chr) => {
|
|
|
149
69
|
return ":";
|
|
150
70
|
}
|
|
151
71
|
return chr;
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const update = deepDiff(initialArgs, args);
|
|
156
|
-
if (!update || update === DEEPLY_EQUAL) {
|
|
72
|
+
}, knownQueryChar = /%[0-9A-F]{2}/g, buildArgsParam = (initialArgs, args) => {
|
|
73
|
+
let update = deepDiff(initialArgs, args);
|
|
74
|
+
if (!update || update === DEEPLY_EQUAL)
|
|
157
75
|
return "";
|
|
158
|
-
}
|
|
159
|
-
const object = Object.entries(update).reduce((acc, [key, value]) => {
|
|
160
|
-
if (validateArgs(key, value)) {
|
|
161
|
-
return Object.assign(acc, { [key]: value });
|
|
162
|
-
}
|
|
163
|
-
once.warn(dedent`
|
|
76
|
+
let object = Object.entries(update).reduce((acc, [key, value]) => validateArgs(key, value) ? Object.assign(acc, { [key]: value }) : (once.warn(dedent`
|
|
164
77
|
Omitted potentially unsafe URL args.
|
|
165
78
|
|
|
166
79
|
More info: https://storybook.js.org/docs/writing-stories/args?ref=error#setting-args-through-the-url
|
|
167
|
-
`);
|
|
168
|
-
return acc;
|
|
169
|
-
}, {});
|
|
80
|
+
`), acc), {});
|
|
170
81
|
return (0, import_picoquery.stringify)(encodeSpecialValues(object), {
|
|
171
82
|
delimiter: ";",
|
|
172
83
|
// we don't actually create multiple query params
|
|
173
|
-
nesting:
|
|
84
|
+
nesting: !0,
|
|
174
85
|
nestingSyntax: "js"
|
|
175
86
|
// encode objects using dot notation: obj.key=val
|
|
176
87
|
}).replace(knownQueryChar, decodeKnownQueryChar).split(";").map((part) => part.replace("=", ":")).join(";");
|
|
177
|
-
}, "
|
|
178
|
-
|
|
179
|
-
var queryFromLocation = /* @__PURE__ */ __name((location) => {
|
|
180
|
-
return queryFromString(location.search ? location.search.slice(1) : "");
|
|
181
|
-
}, "queryFromLocation");
|
|
182
|
-
var stringifyQuery = /* @__PURE__ */ __name((query) => {
|
|
183
|
-
const queryStr = (0, import_picoquery.stringify)(query);
|
|
88
|
+
}, queryFromString = (0, import_memoizerific.default)(1e3)((s) => s !== void 0 ? (0, import_picoquery.parse)(s) : {}), queryFromLocation = (location) => queryFromString(location.search ? location.search.slice(1) : ""), stringifyQuery = (query) => {
|
|
89
|
+
let queryStr = (0, import_picoquery.stringify)(query);
|
|
184
90
|
return queryStr ? "?" + queryStr : "";
|
|
185
|
-
},
|
|
186
|
-
var getMatch = (0, import_memoizerific.default)(1e3)((current, target, startsWith = true) => {
|
|
91
|
+
}, getMatch = (0, import_memoizerific.default)(1e3)((current, target, startsWith = !0) => {
|
|
187
92
|
if (startsWith) {
|
|
188
|
-
if (typeof target
|
|
93
|
+
if (typeof target != "string")
|
|
189
94
|
throw new Error("startsWith only works with string targets");
|
|
190
|
-
}
|
|
191
|
-
const startsWithTarget = current && current.startsWith(target);
|
|
192
|
-
if (startsWithTarget) {
|
|
193
|
-
return { path: current };
|
|
194
|
-
}
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
const currentIsTarget = typeof target === "string" && current === target;
|
|
198
|
-
const matchTarget = current && target && current.match(target);
|
|
199
|
-
if (currentIsTarget || matchTarget) {
|
|
200
|
-
return { path: current };
|
|
95
|
+
return current && current.startsWith(target) ? { path: current } : null;
|
|
201
96
|
}
|
|
202
|
-
|
|
97
|
+
let currentIsTarget = typeof target == "string" && current === target, matchTarget = current && target && current.match(target);
|
|
98
|
+
return currentIsTarget || matchTarget ? { path: current } : null;
|
|
203
99
|
});
|
|
204
100
|
|
|
205
101
|
// src/router/router.tsx
|
|
@@ -214,31 +110,22 @@ import * as React from "react";
|
|
|
214
110
|
|
|
215
111
|
// ../node_modules/@remix-run/router/dist/router.js
|
|
216
112
|
function _extends() {
|
|
217
|
-
_extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
113
|
+
return _extends = Object.assign ? Object.assign.bind() : function(target) {
|
|
218
114
|
for (var i = 1; i < arguments.length; i++) {
|
|
219
115
|
var source = arguments[i];
|
|
220
|
-
for (var key in source)
|
|
221
|
-
|
|
222
|
-
target[key] = source[key];
|
|
223
|
-
}
|
|
224
|
-
}
|
|
116
|
+
for (var key in source)
|
|
117
|
+
Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
|
|
225
118
|
}
|
|
226
119
|
return target;
|
|
227
|
-
};
|
|
228
|
-
return _extends.apply(this, arguments);
|
|
120
|
+
}, _extends.apply(this, arguments);
|
|
229
121
|
}
|
|
230
|
-
__name(_extends, "_extends");
|
|
231
122
|
var Action;
|
|
232
123
|
(function(Action2) {
|
|
233
|
-
Action2
|
|
234
|
-
Action2["Push"] = "PUSH";
|
|
235
|
-
Action2["Replace"] = "REPLACE";
|
|
124
|
+
Action2.Pop = "POP", Action2.Push = "PUSH", Action2.Replace = "REPLACE";
|
|
236
125
|
})(Action || (Action = {}));
|
|
237
126
|
var PopStateEventType = "popstate";
|
|
238
127
|
function createBrowserHistory(options) {
|
|
239
|
-
|
|
240
|
-
options = {};
|
|
241
|
-
}
|
|
128
|
+
options === void 0 && (options = {});
|
|
242
129
|
function createBrowserLocation(window2, globalHistory) {
|
|
243
130
|
let {
|
|
244
131
|
pathname,
|
|
@@ -257,34 +144,27 @@ function createBrowserHistory(options) {
|
|
|
257
144
|
globalHistory.state && globalHistory.state.key || "default"
|
|
258
145
|
);
|
|
259
146
|
}
|
|
260
|
-
__name(createBrowserLocation, "createBrowserLocation");
|
|
261
147
|
function createBrowserHref(window2, to) {
|
|
262
|
-
return typeof to
|
|
148
|
+
return typeof to == "string" ? to : createPath(to);
|
|
263
149
|
}
|
|
264
|
-
__name(createBrowserHref, "createBrowserHref");
|
|
265
150
|
return getUrlBasedHistory(createBrowserLocation, createBrowserHref, null, options);
|
|
266
151
|
}
|
|
267
|
-
__name(createBrowserHistory, "createBrowserHistory");
|
|
268
152
|
function invariant(value, message) {
|
|
269
|
-
if (value ===
|
|
153
|
+
if (value === !1 || value === null || typeof value > "u")
|
|
270
154
|
throw new Error(message);
|
|
271
|
-
}
|
|
272
155
|
}
|
|
273
|
-
__name(invariant, "invariant");
|
|
274
156
|
function warning(cond, message) {
|
|
275
157
|
if (!cond) {
|
|
276
|
-
|
|
158
|
+
typeof console < "u" && console.warn(message);
|
|
277
159
|
try {
|
|
278
160
|
throw new Error(message);
|
|
279
|
-
} catch
|
|
161
|
+
} catch {
|
|
280
162
|
}
|
|
281
163
|
}
|
|
282
164
|
}
|
|
283
|
-
__name(warning, "warning");
|
|
284
165
|
function createKey() {
|
|
285
166
|
return Math.random().toString(36).substr(2, 8);
|
|
286
167
|
}
|
|
287
|
-
__name(createKey, "createKey");
|
|
288
168
|
function getHistoryState(location, index) {
|
|
289
169
|
return {
|
|
290
170
|
usr: location.state,
|
|
@@ -292,16 +172,12 @@ function getHistoryState(location, index) {
|
|
|
292
172
|
idx: index
|
|
293
173
|
};
|
|
294
174
|
}
|
|
295
|
-
__name(getHistoryState, "getHistoryState");
|
|
296
175
|
function createLocation(current, to, state, key) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
let location = _extends({
|
|
301
|
-
pathname: typeof current === "string" ? current : current.pathname,
|
|
176
|
+
return state === void 0 && (state = null), _extends({
|
|
177
|
+
pathname: typeof current == "string" ? current : current.pathname,
|
|
302
178
|
search: "",
|
|
303
179
|
hash: ""
|
|
304
|
-
}, typeof to
|
|
180
|
+
}, typeof to == "string" ? parsePath2(to) : to, {
|
|
305
181
|
state,
|
|
306
182
|
// TODO: This could be cleaned up. push/replace should probably just take
|
|
307
183
|
// full Locations now and avoid the need to run through this flow at all
|
|
@@ -309,127 +185,81 @@ function createLocation(current, to, state, key) {
|
|
|
309
185
|
// keep as is for the time being and just let any incoming keys take precedence
|
|
310
186
|
key: to && to.key || key || createKey()
|
|
311
187
|
});
|
|
312
|
-
return location;
|
|
313
188
|
}
|
|
314
|
-
__name(createLocation, "createLocation");
|
|
315
189
|
function createPath(_ref) {
|
|
316
190
|
let {
|
|
317
191
|
pathname = "/",
|
|
318
192
|
search = "",
|
|
319
193
|
hash = ""
|
|
320
194
|
} = _ref;
|
|
321
|
-
|
|
322
|
-
if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
|
|
323
|
-
return pathname;
|
|
195
|
+
return search && search !== "?" && (pathname += search.charAt(0) === "?" ? search : "?" + search), hash && hash !== "#" && (pathname += hash.charAt(0) === "#" ? hash : "#" + hash), pathname;
|
|
324
196
|
}
|
|
325
|
-
__name(createPath, "createPath");
|
|
326
197
|
function parsePath2(path) {
|
|
327
198
|
let parsedPath = {};
|
|
328
199
|
if (path) {
|
|
329
200
|
let hashIndex = path.indexOf("#");
|
|
330
|
-
|
|
331
|
-
parsedPath.hash = path.substr(hashIndex);
|
|
332
|
-
path = path.substr(0, hashIndex);
|
|
333
|
-
}
|
|
201
|
+
hashIndex >= 0 && (parsedPath.hash = path.substr(hashIndex), path = path.substr(0, hashIndex));
|
|
334
202
|
let searchIndex = path.indexOf("?");
|
|
335
|
-
|
|
336
|
-
parsedPath.search = path.substr(searchIndex);
|
|
337
|
-
path = path.substr(0, searchIndex);
|
|
338
|
-
}
|
|
339
|
-
if (path) {
|
|
340
|
-
parsedPath.pathname = path;
|
|
341
|
-
}
|
|
203
|
+
searchIndex >= 0 && (parsedPath.search = path.substr(searchIndex), path = path.substr(0, searchIndex)), path && (parsedPath.pathname = path);
|
|
342
204
|
}
|
|
343
205
|
return parsedPath;
|
|
344
206
|
}
|
|
345
|
-
__name(parsePath2, "parsePath");
|
|
346
207
|
function getUrlBasedHistory(getLocation, createHref, validateLocation, options) {
|
|
347
|
-
|
|
348
|
-
options = {};
|
|
349
|
-
}
|
|
208
|
+
options === void 0 && (options = {});
|
|
350
209
|
let {
|
|
351
210
|
window: window2 = document.defaultView,
|
|
352
|
-
v5Compat =
|
|
353
|
-
} = options;
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
let index = getIndex();
|
|
358
|
-
if (index == null) {
|
|
359
|
-
index = 0;
|
|
360
|
-
globalHistory.replaceState(_extends({}, globalHistory.state, {
|
|
361
|
-
idx: index
|
|
362
|
-
}), "");
|
|
363
|
-
}
|
|
211
|
+
v5Compat = !1
|
|
212
|
+
} = options, globalHistory = window2.history, action = Action.Pop, listener = null, index = getIndex();
|
|
213
|
+
index == null && (index = 0, globalHistory.replaceState(_extends({}, globalHistory.state, {
|
|
214
|
+
idx: index
|
|
215
|
+
}), ""));
|
|
364
216
|
function getIndex() {
|
|
365
|
-
|
|
217
|
+
return (globalHistory.state || {
|
|
366
218
|
idx: null
|
|
367
|
-
};
|
|
368
|
-
return state.idx;
|
|
219
|
+
}).idx;
|
|
369
220
|
}
|
|
370
|
-
__name(getIndex, "getIndex");
|
|
371
221
|
function handlePop() {
|
|
372
222
|
action = Action.Pop;
|
|
373
|
-
let nextIndex = getIndex();
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
location: history.location,
|
|
380
|
-
delta
|
|
381
|
-
});
|
|
382
|
-
}
|
|
223
|
+
let nextIndex = getIndex(), delta = nextIndex == null ? null : nextIndex - index;
|
|
224
|
+
index = nextIndex, listener && listener({
|
|
225
|
+
action,
|
|
226
|
+
location: history.location,
|
|
227
|
+
delta
|
|
228
|
+
});
|
|
383
229
|
}
|
|
384
|
-
__name(handlePop, "handlePop");
|
|
385
230
|
function push(to, state) {
|
|
386
231
|
action = Action.Push;
|
|
387
232
|
let location = createLocation(history.location, to, state);
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
let historyState = getHistoryState(location, index);
|
|
391
|
-
let url = history.createHref(location);
|
|
233
|
+
validateLocation && validateLocation(location, to), index = getIndex() + 1;
|
|
234
|
+
let historyState = getHistoryState(location, index), url = history.createHref(location);
|
|
392
235
|
try {
|
|
393
236
|
globalHistory.pushState(historyState, "", url);
|
|
394
237
|
} catch (error) {
|
|
395
|
-
if (error instanceof DOMException && error.name === "DataCloneError")
|
|
238
|
+
if (error instanceof DOMException && error.name === "DataCloneError")
|
|
396
239
|
throw error;
|
|
397
|
-
}
|
|
398
240
|
window2.location.assign(url);
|
|
399
241
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
});
|
|
406
|
-
}
|
|
242
|
+
v5Compat && listener && listener({
|
|
243
|
+
action,
|
|
244
|
+
location: history.location,
|
|
245
|
+
delta: 1
|
|
246
|
+
});
|
|
407
247
|
}
|
|
408
|
-
__name(push, "push");
|
|
409
248
|
function replace(to, state) {
|
|
410
249
|
action = Action.Replace;
|
|
411
250
|
let location = createLocation(history.location, to, state);
|
|
412
|
-
|
|
413
|
-
index =
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
action,
|
|
420
|
-
location: history.location,
|
|
421
|
-
delta: 0
|
|
422
|
-
});
|
|
423
|
-
}
|
|
251
|
+
validateLocation && validateLocation(location, to), index = getIndex();
|
|
252
|
+
let historyState = getHistoryState(location, index), url = history.createHref(location);
|
|
253
|
+
globalHistory.replaceState(historyState, "", url), v5Compat && listener && listener({
|
|
254
|
+
action,
|
|
255
|
+
location: history.location,
|
|
256
|
+
delta: 0
|
|
257
|
+
});
|
|
424
258
|
}
|
|
425
|
-
__name(replace, "replace");
|
|
426
259
|
function createURL(to) {
|
|
427
|
-
let base = window2.location.origin !== "null" ? window2.location.origin : window2.location.href;
|
|
428
|
-
|
|
429
|
-
invariant(base, "No window.location.(origin|href) available to create URL for href: " + href);
|
|
430
|
-
return new URL(href, base);
|
|
260
|
+
let base = window2.location.origin !== "null" ? window2.location.origin : window2.location.href, href = typeof to == "string" ? to : createPath(to);
|
|
261
|
+
return invariant(base, "No window.location.(origin|href) available to create URL for href: " + href), new URL(href, base);
|
|
431
262
|
}
|
|
432
|
-
__name(createURL, "createURL");
|
|
433
263
|
let history = {
|
|
434
264
|
get action() {
|
|
435
265
|
return action;
|
|
@@ -438,14 +268,10 @@ function getUrlBasedHistory(getLocation, createHref, validateLocation, options)
|
|
|
438
268
|
return getLocation(window2, globalHistory);
|
|
439
269
|
},
|
|
440
270
|
listen(fn) {
|
|
441
|
-
if (listener)
|
|
271
|
+
if (listener)
|
|
442
272
|
throw new Error("A history only accepts one active listener");
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
listener = fn;
|
|
446
|
-
return () => {
|
|
447
|
-
window2.removeEventListener(PopStateEventType, handlePop);
|
|
448
|
-
listener = null;
|
|
273
|
+
return window2.addEventListener(PopStateEventType, handlePop), listener = fn, () => {
|
|
274
|
+
window2.removeEventListener(PopStateEventType, handlePop), listener = null;
|
|
449
275
|
};
|
|
450
276
|
},
|
|
451
277
|
createHref(to) {
|
|
@@ -468,306 +294,197 @@ function getUrlBasedHistory(getLocation, createHref, validateLocation, options)
|
|
|
468
294
|
};
|
|
469
295
|
return history;
|
|
470
296
|
}
|
|
471
|
-
__name(getUrlBasedHistory, "getUrlBasedHistory");
|
|
472
297
|
var ResultType;
|
|
473
298
|
(function(ResultType2) {
|
|
474
|
-
ResultType2
|
|
475
|
-
ResultType2["deferred"] = "deferred";
|
|
476
|
-
ResultType2["redirect"] = "redirect";
|
|
477
|
-
ResultType2["error"] = "error";
|
|
299
|
+
ResultType2.data = "data", ResultType2.deferred = "deferred", ResultType2.redirect = "redirect", ResultType2.error = "error";
|
|
478
300
|
})(ResultType || (ResultType = {}));
|
|
479
301
|
function stripBasename(pathname, basename) {
|
|
480
302
|
if (basename === "/") return pathname;
|
|
481
|
-
if (!pathname.toLowerCase().startsWith(basename.toLowerCase()))
|
|
303
|
+
if (!pathname.toLowerCase().startsWith(basename.toLowerCase()))
|
|
482
304
|
return null;
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
let nextChar = pathname.charAt(startIndex);
|
|
486
|
-
if (nextChar && nextChar !== "/") {
|
|
487
|
-
return null;
|
|
488
|
-
}
|
|
489
|
-
return pathname.slice(startIndex) || "/";
|
|
305
|
+
let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length, nextChar = pathname.charAt(startIndex);
|
|
306
|
+
return nextChar && nextChar !== "/" ? null : pathname.slice(startIndex) || "/";
|
|
490
307
|
}
|
|
491
|
-
__name(stripBasename, "stripBasename");
|
|
492
308
|
function resolvePath(to, fromPathname) {
|
|
493
|
-
|
|
494
|
-
fromPathname = "/";
|
|
495
|
-
}
|
|
309
|
+
fromPathname === void 0 && (fromPathname = "/");
|
|
496
310
|
let {
|
|
497
311
|
pathname: toPathname,
|
|
498
312
|
search = "",
|
|
499
313
|
hash = ""
|
|
500
|
-
} = typeof to
|
|
501
|
-
let pathname = toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname(toPathname, fromPathname) : fromPathname;
|
|
314
|
+
} = typeof to == "string" ? parsePath2(to) : to;
|
|
502
315
|
return {
|
|
503
|
-
pathname,
|
|
316
|
+
pathname: toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname(toPathname, fromPathname) : fromPathname,
|
|
504
317
|
search: normalizeSearch(search),
|
|
505
318
|
hash: normalizeHash(hash)
|
|
506
319
|
};
|
|
507
320
|
}
|
|
508
|
-
__name(resolvePath, "resolvePath");
|
|
509
321
|
function resolvePathname(relativePath, fromPathname) {
|
|
510
322
|
let segments = fromPathname.replace(/\/+$/, "").split("/");
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if (segments.length > 1) segments.pop();
|
|
515
|
-
} else if (segment !== ".") {
|
|
516
|
-
segments.push(segment);
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
return segments.length > 1 ? segments.join("/") : "/";
|
|
323
|
+
return relativePath.split("/").forEach((segment) => {
|
|
324
|
+
segment === ".." ? segments.length > 1 && segments.pop() : segment !== "." && segments.push(segment);
|
|
325
|
+
}), segments.length > 1 ? segments.join("/") : "/";
|
|
520
326
|
}
|
|
521
|
-
__name(resolvePathname, "resolvePathname");
|
|
522
327
|
function getInvalidPathError(char, field, dest, path) {
|
|
523
328
|
return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path) + "]. Please separate it out to the ") + ("`to." + dest + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.';
|
|
524
329
|
}
|
|
525
|
-
__name(getInvalidPathError, "getInvalidPathError");
|
|
526
330
|
function getPathContributingMatches(matches) {
|
|
527
331
|
return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0);
|
|
528
332
|
}
|
|
529
|
-
__name(getPathContributingMatches, "getPathContributingMatches");
|
|
530
333
|
function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) {
|
|
531
|
-
|
|
532
|
-
isPathRelative = false;
|
|
533
|
-
}
|
|
334
|
+
isPathRelative === void 0 && (isPathRelative = !1);
|
|
534
335
|
let to;
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
to = _extends({}, toArg);
|
|
539
|
-
invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
|
|
540
|
-
invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
|
|
541
|
-
invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
|
|
542
|
-
}
|
|
543
|
-
let isEmptyPath = toArg === "" || to.pathname === "";
|
|
544
|
-
let toPathname = isEmptyPath ? "/" : to.pathname;
|
|
545
|
-
let from;
|
|
546
|
-
if (isPathRelative || toPathname == null) {
|
|
336
|
+
typeof toArg == "string" ? to = parsePath2(toArg) : (to = _extends({}, toArg), invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to)), invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to)), invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to)));
|
|
337
|
+
let isEmptyPath = toArg === "" || to.pathname === "", toPathname = isEmptyPath ? "/" : to.pathname, from;
|
|
338
|
+
if (isPathRelative || toPathname == null)
|
|
547
339
|
from = locationPathname;
|
|
548
|
-
|
|
340
|
+
else {
|
|
549
341
|
let routePathnameIndex = routePathnames.length - 1;
|
|
550
342
|
if (toPathname.startsWith("..")) {
|
|
551
343
|
let toSegments = toPathname.split("/");
|
|
552
|
-
|
|
553
|
-
toSegments.shift();
|
|
554
|
-
routePathnameIndex -= 1;
|
|
555
|
-
}
|
|
344
|
+
for (; toSegments[0] === ".."; )
|
|
345
|
+
toSegments.shift(), routePathnameIndex -= 1;
|
|
556
346
|
to.pathname = toSegments.join("/");
|
|
557
347
|
}
|
|
558
348
|
from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
|
|
559
349
|
}
|
|
560
|
-
let path = resolvePath(to, from);
|
|
561
|
-
|
|
562
|
-
let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
|
|
563
|
-
if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
|
|
564
|
-
path.pathname += "/";
|
|
565
|
-
}
|
|
566
|
-
return path;
|
|
350
|
+
let path = resolvePath(to, from), hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/"), hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
|
|
351
|
+
return !path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash) && (path.pathname += "/"), path;
|
|
567
352
|
}
|
|
568
|
-
|
|
569
|
-
var
|
|
570
|
-
var normalizeSearch = /* @__PURE__ */ __name((search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search, "normalizeSearch");
|
|
571
|
-
var normalizeHash = /* @__PURE__ */ __name((hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash, "normalizeHash");
|
|
353
|
+
var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
|
|
354
|
+
var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search, normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
|
572
355
|
function isRouteErrorResponse(error) {
|
|
573
|
-
return error != null && typeof error.status
|
|
356
|
+
return error != null && typeof error.status == "number" && typeof error.statusText == "string" && typeof error.internal == "boolean" && "data" in error;
|
|
574
357
|
}
|
|
575
|
-
|
|
576
|
-
var validMutationMethodsArr = ["post", "put", "patch", "delete"];
|
|
577
|
-
var validMutationMethods = new Set(validMutationMethodsArr);
|
|
578
|
-
var validRequestMethodsArr = ["get", ...validMutationMethodsArr];
|
|
579
|
-
var validRequestMethods = new Set(validRequestMethodsArr);
|
|
358
|
+
var validMutationMethodsArr = ["post", "put", "patch", "delete"], validMutationMethods = new Set(validMutationMethodsArr), validRequestMethodsArr = ["get", ...validMutationMethodsArr], validRequestMethods = new Set(validRequestMethodsArr);
|
|
580
359
|
var UNSAFE_DEFERRED_SYMBOL = Symbol("deferred");
|
|
581
360
|
|
|
582
361
|
// ../node_modules/react-router/dist/index.js
|
|
583
362
|
function _extends2() {
|
|
584
|
-
_extends2 = Object.assign ? Object.assign.bind() : function(target) {
|
|
363
|
+
return _extends2 = Object.assign ? Object.assign.bind() : function(target) {
|
|
585
364
|
for (var i = 1; i < arguments.length; i++) {
|
|
586
365
|
var source = arguments[i];
|
|
587
|
-
for (var key in source)
|
|
588
|
-
|
|
589
|
-
target[key] = source[key];
|
|
590
|
-
}
|
|
591
|
-
}
|
|
366
|
+
for (var key in source)
|
|
367
|
+
Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
|
|
592
368
|
}
|
|
593
369
|
return target;
|
|
594
|
-
};
|
|
595
|
-
return _extends2.apply(this, arguments);
|
|
370
|
+
}, _extends2.apply(this, arguments);
|
|
596
371
|
}
|
|
597
|
-
__name(_extends2, "_extends");
|
|
598
372
|
var DataRouterContext = React.createContext(null);
|
|
599
|
-
|
|
600
|
-
DataRouterContext.displayName = "DataRouter";
|
|
601
|
-
}
|
|
373
|
+
process.env.NODE_ENV !== "production" && (DataRouterContext.displayName = "DataRouter");
|
|
602
374
|
var DataRouterStateContext = React.createContext(null);
|
|
603
|
-
|
|
604
|
-
DataRouterStateContext.displayName = "DataRouterState";
|
|
605
|
-
}
|
|
375
|
+
process.env.NODE_ENV !== "production" && (DataRouterStateContext.displayName = "DataRouterState");
|
|
606
376
|
var AwaitContext = React.createContext(null);
|
|
607
|
-
|
|
608
|
-
AwaitContext.displayName = "Await";
|
|
609
|
-
}
|
|
377
|
+
process.env.NODE_ENV !== "production" && (AwaitContext.displayName = "Await");
|
|
610
378
|
var NavigationContext = React.createContext(null);
|
|
611
|
-
|
|
612
|
-
NavigationContext.displayName = "Navigation";
|
|
613
|
-
}
|
|
379
|
+
process.env.NODE_ENV !== "production" && (NavigationContext.displayName = "Navigation");
|
|
614
380
|
var LocationContext = React.createContext(null);
|
|
615
|
-
|
|
616
|
-
LocationContext.displayName = "Location";
|
|
617
|
-
}
|
|
381
|
+
process.env.NODE_ENV !== "production" && (LocationContext.displayName = "Location");
|
|
618
382
|
var RouteContext = React.createContext({
|
|
619
383
|
outlet: null,
|
|
620
384
|
matches: [],
|
|
621
|
-
isDataRoute:
|
|
385
|
+
isDataRoute: !1
|
|
622
386
|
});
|
|
623
|
-
|
|
624
|
-
RouteContext.displayName = "Route";
|
|
625
|
-
}
|
|
387
|
+
process.env.NODE_ENV !== "production" && (RouteContext.displayName = "Route");
|
|
626
388
|
var RouteErrorContext = React.createContext(null);
|
|
627
|
-
|
|
628
|
-
RouteErrorContext.displayName = "RouteError";
|
|
629
|
-
}
|
|
389
|
+
process.env.NODE_ENV !== "production" && (RouteErrorContext.displayName = "RouteError");
|
|
630
390
|
function useHref(to, _temp) {
|
|
631
391
|
let {
|
|
632
392
|
relative
|
|
633
393
|
} = _temp === void 0 ? {} : _temp;
|
|
634
|
-
|
|
635
|
-
|
|
394
|
+
useInRouterContext() || (process.env.NODE_ENV !== "production" ? invariant(
|
|
395
|
+
!1,
|
|
636
396
|
// TODO: This error is probably because they somehow have 2 versions of the
|
|
637
397
|
// router loaded. We can help them understand how to avoid that.
|
|
638
398
|
"useHref() may be used only in the context of a <Router> component."
|
|
639
|
-
) : invariant(
|
|
399
|
+
) : invariant(!1));
|
|
640
400
|
let {
|
|
641
401
|
basename,
|
|
642
402
|
navigator
|
|
643
|
-
} = React.useContext(NavigationContext)
|
|
644
|
-
let {
|
|
403
|
+
} = React.useContext(NavigationContext), {
|
|
645
404
|
hash,
|
|
646
405
|
pathname,
|
|
647
406
|
search
|
|
648
407
|
} = useResolvedPath(to, {
|
|
649
408
|
relative
|
|
650
|
-
});
|
|
651
|
-
|
|
652
|
-
if (basename !== "/") {
|
|
653
|
-
joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
|
|
654
|
-
}
|
|
655
|
-
return navigator.createHref({
|
|
409
|
+
}), joinedPathname = pathname;
|
|
410
|
+
return basename !== "/" && (joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname])), navigator.createHref({
|
|
656
411
|
pathname: joinedPathname,
|
|
657
412
|
search,
|
|
658
413
|
hash
|
|
659
414
|
});
|
|
660
415
|
}
|
|
661
|
-
__name(useHref, "useHref");
|
|
662
416
|
function useInRouterContext() {
|
|
663
417
|
return React.useContext(LocationContext) != null;
|
|
664
418
|
}
|
|
665
|
-
__name(useInRouterContext, "useInRouterContext");
|
|
666
419
|
function useLocation() {
|
|
667
|
-
|
|
668
|
-
|
|
420
|
+
return useInRouterContext() || (process.env.NODE_ENV !== "production" ? invariant(
|
|
421
|
+
!1,
|
|
669
422
|
// TODO: This error is probably because they somehow have 2 versions of the
|
|
670
423
|
// router loaded. We can help them understand how to avoid that.
|
|
671
424
|
"useLocation() may be used only in the context of a <Router> component."
|
|
672
|
-
) : invariant(
|
|
673
|
-
return React.useContext(LocationContext).location;
|
|
425
|
+
) : invariant(!1)), React.useContext(LocationContext).location;
|
|
674
426
|
}
|
|
675
|
-
__name(useLocation, "useLocation");
|
|
676
427
|
var navigateEffectWarning = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
|
|
677
428
|
function useIsomorphicLayoutEffect(cb) {
|
|
678
|
-
|
|
679
|
-
if (!isStatic) {
|
|
680
|
-
React.useLayoutEffect(cb);
|
|
681
|
-
}
|
|
429
|
+
React.useContext(NavigationContext).static || React.useLayoutEffect(cb);
|
|
682
430
|
}
|
|
683
|
-
__name(useIsomorphicLayoutEffect, "useIsomorphicLayoutEffect");
|
|
684
431
|
function useNavigate() {
|
|
685
432
|
let {
|
|
686
433
|
isDataRoute
|
|
687
434
|
} = React.useContext(RouteContext);
|
|
688
435
|
return isDataRoute ? useNavigateStable() : useNavigateUnstable();
|
|
689
436
|
}
|
|
690
|
-
__name(useNavigate, "useNavigate");
|
|
691
437
|
function useNavigateUnstable() {
|
|
692
|
-
|
|
693
|
-
|
|
438
|
+
useInRouterContext() || (process.env.NODE_ENV !== "production" ? invariant(
|
|
439
|
+
!1,
|
|
694
440
|
// TODO: This error is probably because they somehow have 2 versions of the
|
|
695
441
|
// router loaded. We can help them understand how to avoid that.
|
|
696
442
|
"useNavigate() may be used only in the context of a <Router> component."
|
|
697
|
-
) : invariant(
|
|
698
|
-
let dataRouterContext = React.useContext(DataRouterContext)
|
|
699
|
-
let {
|
|
443
|
+
) : invariant(!1));
|
|
444
|
+
let dataRouterContext = React.useContext(DataRouterContext), {
|
|
700
445
|
basename,
|
|
701
446
|
navigator
|
|
702
|
-
} = React.useContext(NavigationContext)
|
|
703
|
-
let {
|
|
447
|
+
} = React.useContext(NavigationContext), {
|
|
704
448
|
matches
|
|
705
|
-
} = React.useContext(RouteContext)
|
|
706
|
-
let {
|
|
449
|
+
} = React.useContext(RouteContext), {
|
|
707
450
|
pathname: locationPathname
|
|
708
|
-
} = useLocation();
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
activeRef.current
|
|
713
|
-
|
|
714
|
-
let navigate = React.useCallback(function(to, options) {
|
|
715
|
-
if (options === void 0) {
|
|
716
|
-
options = {};
|
|
717
|
-
}
|
|
718
|
-
process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
|
|
719
|
-
if (!activeRef.current) return;
|
|
720
|
-
if (typeof to === "number") {
|
|
451
|
+
} = useLocation(), routePathnamesJson = JSON.stringify(getPathContributingMatches(matches).map((match) => match.pathnameBase)), activeRef = React.useRef(!1);
|
|
452
|
+
return useIsomorphicLayoutEffect(() => {
|
|
453
|
+
activeRef.current = !0;
|
|
454
|
+
}), React.useCallback(function(to, options) {
|
|
455
|
+
if (options === void 0 && (options = {}), process.env.NODE_ENV !== "production" && warning(activeRef.current, navigateEffectWarning), !activeRef.current) return;
|
|
456
|
+
if (typeof to == "number") {
|
|
721
457
|
navigator.go(to);
|
|
722
458
|
return;
|
|
723
459
|
}
|
|
724
460
|
let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
|
|
725
|
-
|
|
726
|
-
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
|
727
|
-
}
|
|
728
|
-
(!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
|
|
461
|
+
dataRouterContext == null && basename !== "/" && (path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname])), (options.replace ? navigator.replace : navigator.push)(path, options.state, options);
|
|
729
462
|
}, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
|
|
730
|
-
return navigate;
|
|
731
463
|
}
|
|
732
|
-
__name(useNavigateUnstable, "useNavigateUnstable");
|
|
733
464
|
var OutletContext = React.createContext(null);
|
|
734
465
|
function useResolvedPath(to, _temp2) {
|
|
735
466
|
let {
|
|
736
467
|
relative
|
|
737
|
-
} = _temp2 === void 0 ? {} : _temp2
|
|
738
|
-
let {
|
|
468
|
+
} = _temp2 === void 0 ? {} : _temp2, {
|
|
739
469
|
matches
|
|
740
|
-
} = React.useContext(RouteContext)
|
|
741
|
-
let {
|
|
470
|
+
} = React.useContext(RouteContext), {
|
|
742
471
|
pathname: locationPathname
|
|
743
|
-
} = useLocation();
|
|
744
|
-
let routePathnamesJson = JSON.stringify(getPathContributingMatches(matches).map((match) => match.pathnameBase));
|
|
472
|
+
} = useLocation(), routePathnamesJson = JSON.stringify(getPathContributingMatches(matches).map((match) => match.pathnameBase));
|
|
745
473
|
return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
|
|
746
474
|
}
|
|
747
|
-
__name(useResolvedPath, "useResolvedPath");
|
|
748
475
|
function DefaultErrorComponent() {
|
|
749
|
-
let error = useRouteError()
|
|
750
|
-
let message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error);
|
|
751
|
-
let stack = error instanceof Error ? error.stack : null;
|
|
752
|
-
let lightgrey = "rgba(200,200,200, 0.5)";
|
|
753
|
-
let preStyles = {
|
|
476
|
+
let error = useRouteError(), message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error), stack = error instanceof Error ? error.stack : null, lightgrey = "rgba(200,200,200, 0.5)", preStyles = {
|
|
754
477
|
padding: "0.5rem",
|
|
755
478
|
backgroundColor: lightgrey
|
|
756
|
-
}
|
|
757
|
-
let codeStyles = {
|
|
479
|
+
}, codeStyles = {
|
|
758
480
|
padding: "2px 4px",
|
|
759
481
|
backgroundColor: lightgrey
|
|
760
|
-
};
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
}, "ErrorBoundary"), " or", " ", React.createElement("code", {
|
|
767
|
-
style: codeStyles
|
|
768
|
-
}, "errorElement"), " prop on your route."));
|
|
769
|
-
}
|
|
770
|
-
return React.createElement(React.Fragment, null, React.createElement("h2", null, "Unexpected Application Error!"), React.createElement("h3", {
|
|
482
|
+
}, devInfo = null;
|
|
483
|
+
return process.env.NODE_ENV !== "production" && (console.error("Error handled by React Router default ErrorBoundary:", error), devInfo = React.createElement(React.Fragment, null, React.createElement("p", null, "\u{1F4BF} Hey developer \u{1F44B}"), React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", React.createElement("code", {
|
|
484
|
+
style: codeStyles
|
|
485
|
+
}, "ErrorBoundary"), " or", " ", React.createElement("code", {
|
|
486
|
+
style: codeStyles
|
|
487
|
+
}, "errorElement"), " prop on your route."))), React.createElement(React.Fragment, null, React.createElement("h2", null, "Unexpected Application Error!"), React.createElement("h3", {
|
|
771
488
|
style: {
|
|
772
489
|
fontStyle: "italic"
|
|
773
490
|
}
|
|
@@ -775,65 +492,37 @@ function DefaultErrorComponent() {
|
|
|
775
492
|
style: preStyles
|
|
776
493
|
}, stack) : null, devInfo);
|
|
777
494
|
}
|
|
778
|
-
__name(DefaultErrorComponent, "DefaultErrorComponent");
|
|
779
495
|
var defaultErrorElement = React.createElement(DefaultErrorComponent, null);
|
|
780
|
-
var DataRouterHook = function(DataRouterHook3) {
|
|
781
|
-
DataRouterHook3
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
}(DataRouterHook || {});
|
|
786
|
-
var DataRouterStateHook = function(DataRouterStateHook3) {
|
|
787
|
-
DataRouterStateHook3["UseBlocker"] = "useBlocker";
|
|
788
|
-
DataRouterStateHook3["UseLoaderData"] = "useLoaderData";
|
|
789
|
-
DataRouterStateHook3["UseActionData"] = "useActionData";
|
|
790
|
-
DataRouterStateHook3["UseRouteError"] = "useRouteError";
|
|
791
|
-
DataRouterStateHook3["UseNavigation"] = "useNavigation";
|
|
792
|
-
DataRouterStateHook3["UseRouteLoaderData"] = "useRouteLoaderData";
|
|
793
|
-
DataRouterStateHook3["UseMatches"] = "useMatches";
|
|
794
|
-
DataRouterStateHook3["UseRevalidator"] = "useRevalidator";
|
|
795
|
-
DataRouterStateHook3["UseNavigateStable"] = "useNavigate";
|
|
796
|
-
DataRouterStateHook3["UseRouteId"] = "useRouteId";
|
|
797
|
-
return DataRouterStateHook3;
|
|
798
|
-
}(DataRouterStateHook || {});
|
|
496
|
+
var DataRouterHook = (function(DataRouterHook3) {
|
|
497
|
+
return DataRouterHook3.UseBlocker = "useBlocker", DataRouterHook3.UseRevalidator = "useRevalidator", DataRouterHook3.UseNavigateStable = "useNavigate", DataRouterHook3;
|
|
498
|
+
})(DataRouterHook || {}), DataRouterStateHook = (function(DataRouterStateHook3) {
|
|
499
|
+
return DataRouterStateHook3.UseBlocker = "useBlocker", DataRouterStateHook3.UseLoaderData = "useLoaderData", DataRouterStateHook3.UseActionData = "useActionData", DataRouterStateHook3.UseRouteError = "useRouteError", DataRouterStateHook3.UseNavigation = "useNavigation", DataRouterStateHook3.UseRouteLoaderData = "useRouteLoaderData", DataRouterStateHook3.UseMatches = "useMatches", DataRouterStateHook3.UseRevalidator = "useRevalidator", DataRouterStateHook3.UseNavigateStable = "useNavigate", DataRouterStateHook3.UseRouteId = "useRouteId", DataRouterStateHook3;
|
|
500
|
+
})(DataRouterStateHook || {});
|
|
799
501
|
function getDataRouterConsoleError(hookName) {
|
|
800
502
|
return hookName + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router.";
|
|
801
503
|
}
|
|
802
|
-
__name(getDataRouterConsoleError, "getDataRouterConsoleError");
|
|
803
504
|
function useDataRouterContext(hookName) {
|
|
804
505
|
let ctx = React.useContext(DataRouterContext);
|
|
805
|
-
|
|
806
|
-
return ctx;
|
|
506
|
+
return ctx || (process.env.NODE_ENV !== "production" ? invariant(!1, getDataRouterConsoleError(hookName)) : invariant(!1)), ctx;
|
|
807
507
|
}
|
|
808
|
-
__name(useDataRouterContext, "useDataRouterContext");
|
|
809
508
|
function useDataRouterState(hookName) {
|
|
810
509
|
let state = React.useContext(DataRouterStateContext);
|
|
811
|
-
|
|
812
|
-
return state;
|
|
510
|
+
return state || (process.env.NODE_ENV !== "production" ? invariant(!1, getDataRouterConsoleError(hookName)) : invariant(!1)), state;
|
|
813
511
|
}
|
|
814
|
-
__name(useDataRouterState, "useDataRouterState");
|
|
815
512
|
function useRouteContext(hookName) {
|
|
816
513
|
let route = React.useContext(RouteContext);
|
|
817
|
-
|
|
818
|
-
return route;
|
|
514
|
+
return route || (process.env.NODE_ENV !== "production" ? invariant(!1, getDataRouterConsoleError(hookName)) : invariant(!1)), route;
|
|
819
515
|
}
|
|
820
|
-
__name(useRouteContext, "useRouteContext");
|
|
821
516
|
function useCurrentRouteId(hookName) {
|
|
822
|
-
let route = useRouteContext(hookName);
|
|
823
|
-
|
|
824
|
-
!thisRoute.route.id ? process.env.NODE_ENV !== "production" ? invariant(false, hookName + ' can only be used on routes that contain a unique "id"') : invariant(false) : void 0;
|
|
825
|
-
return thisRoute.route.id;
|
|
517
|
+
let route = useRouteContext(hookName), thisRoute = route.matches[route.matches.length - 1];
|
|
518
|
+
return thisRoute.route.id || (process.env.NODE_ENV !== "production" ? invariant(!1, hookName + ' can only be used on routes that contain a unique "id"') : invariant(!1)), thisRoute.route.id;
|
|
826
519
|
}
|
|
827
|
-
__name(useCurrentRouteId, "useCurrentRouteId");
|
|
828
520
|
function useRouteId() {
|
|
829
521
|
return useCurrentRouteId(DataRouterStateHook.UseRouteId);
|
|
830
522
|
}
|
|
831
|
-
__name(useRouteId, "useRouteId");
|
|
832
523
|
function useNavigation() {
|
|
833
|
-
|
|
834
|
-
return state.navigation;
|
|
524
|
+
return useDataRouterState(DataRouterStateHook.UseNavigation).navigation;
|
|
835
525
|
}
|
|
836
|
-
__name(useNavigation, "useNavigation");
|
|
837
526
|
function useMatches() {
|
|
838
527
|
let {
|
|
839
528
|
matches,
|
|
@@ -853,46 +542,24 @@ function useMatches() {
|
|
|
853
542
|
};
|
|
854
543
|
}), [matches, loaderData]);
|
|
855
544
|
}
|
|
856
|
-
__name(useMatches, "useMatches");
|
|
857
545
|
function useRouteError() {
|
|
858
546
|
var _state$errors;
|
|
859
|
-
let error = React.useContext(RouteErrorContext);
|
|
860
|
-
|
|
861
|
-
let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError);
|
|
862
|
-
if (error) {
|
|
863
|
-
return error;
|
|
864
|
-
}
|
|
865
|
-
return (_state$errors = state.errors) == null ? void 0 : _state$errors[routeId];
|
|
547
|
+
let error = React.useContext(RouteErrorContext), state = useDataRouterState(DataRouterStateHook.UseRouteError), routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError);
|
|
548
|
+
return error || ((_state$errors = state.errors) == null ? void 0 : _state$errors[routeId]);
|
|
866
549
|
}
|
|
867
|
-
__name(useRouteError, "useRouteError");
|
|
868
550
|
function useNavigateStable() {
|
|
869
551
|
let {
|
|
870
552
|
router
|
|
871
|
-
} = useDataRouterContext(DataRouterHook.UseNavigateStable);
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
activeRef.current
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
if (options === void 0) {
|
|
879
|
-
options = {};
|
|
880
|
-
}
|
|
881
|
-
process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
|
|
882
|
-
if (!activeRef.current) return;
|
|
883
|
-
if (typeof to === "number") {
|
|
884
|
-
router.navigate(to);
|
|
885
|
-
} else {
|
|
886
|
-
router.navigate(to, _extends2({
|
|
887
|
-
fromRouteId: id
|
|
888
|
-
}, options));
|
|
889
|
-
}
|
|
553
|
+
} = useDataRouterContext(DataRouterHook.UseNavigateStable), id = useCurrentRouteId(DataRouterStateHook.UseNavigateStable), activeRef = React.useRef(!1);
|
|
554
|
+
return useIsomorphicLayoutEffect(() => {
|
|
555
|
+
activeRef.current = !0;
|
|
556
|
+
}), React.useCallback(function(to, options) {
|
|
557
|
+
options === void 0 && (options = {}), process.env.NODE_ENV !== "production" && warning(activeRef.current, navigateEffectWarning), activeRef.current && (typeof to == "number" ? router.navigate(to) : router.navigate(to, _extends2({
|
|
558
|
+
fromRouteId: id
|
|
559
|
+
}, options)));
|
|
890
560
|
}, [router, id]);
|
|
891
|
-
return navigate;
|
|
892
561
|
}
|
|
893
|
-
|
|
894
|
-
var START_TRANSITION = "startTransition";
|
|
895
|
-
var startTransitionImpl = React[START_TRANSITION];
|
|
562
|
+
var START_TRANSITION = "startTransition", startTransitionImpl = React[START_TRANSITION];
|
|
896
563
|
function Router(_ref5) {
|
|
897
564
|
let {
|
|
898
565
|
basename: basenameProp = "/",
|
|
@@ -900,31 +567,24 @@ function Router(_ref5) {
|
|
|
900
567
|
location: locationProp,
|
|
901
568
|
navigationType = Action.Pop,
|
|
902
569
|
navigator,
|
|
903
|
-
static: staticProp =
|
|
570
|
+
static: staticProp = !1
|
|
904
571
|
} = _ref5;
|
|
905
|
-
|
|
906
|
-
let basename = basenameProp.replace(/^\/*/, "/")
|
|
907
|
-
let navigationContext = React.useMemo(() => ({
|
|
572
|
+
useInRouterContext() && (process.env.NODE_ENV !== "production" ? invariant(!1, "You cannot render a <Router> inside another <Router>. You should never have more than one in your app.") : invariant(!1));
|
|
573
|
+
let basename = basenameProp.replace(/^\/*/, "/"), navigationContext = React.useMemo(() => ({
|
|
908
574
|
basename,
|
|
909
575
|
navigator,
|
|
910
576
|
static: staticProp
|
|
911
577
|
}), [basename, navigator, staticProp]);
|
|
912
|
-
|
|
913
|
-
locationProp = parsePath2(locationProp);
|
|
914
|
-
}
|
|
578
|
+
typeof locationProp == "string" && (locationProp = parsePath2(locationProp));
|
|
915
579
|
let {
|
|
916
580
|
pathname = "/",
|
|
917
581
|
search = "",
|
|
918
582
|
hash = "",
|
|
919
583
|
state = null,
|
|
920
584
|
key = "default"
|
|
921
|
-
} = locationProp
|
|
922
|
-
let locationContext = React.useMemo(() => {
|
|
585
|
+
} = locationProp, locationContext = React.useMemo(() => {
|
|
923
586
|
let trailingPathname = stripBasename(pathname, basename);
|
|
924
|
-
|
|
925
|
-
return null;
|
|
926
|
-
}
|
|
927
|
-
return {
|
|
587
|
+
return trailingPathname == null ? null : {
|
|
928
588
|
location: {
|
|
929
589
|
pathname: trailingPathname,
|
|
930
590
|
search,
|
|
@@ -935,133 +595,86 @@ function Router(_ref5) {
|
|
|
935
595
|
navigationType
|
|
936
596
|
};
|
|
937
597
|
}, [basename, pathname, search, hash, state, key, navigationType]);
|
|
938
|
-
process.env.NODE_ENV !== "production"
|
|
939
|
-
if (locationContext == null) {
|
|
940
|
-
return null;
|
|
941
|
-
}
|
|
942
|
-
return React.createElement(NavigationContext.Provider, {
|
|
598
|
+
return process.env.NODE_ENV !== "production" && warning(locationContext != null, '<Router basename="' + basename + '"> is not able to match the URL ' + ('"' + pathname + search + hash + '" because it does not start with the ') + "basename, so the <Router> won't render anything."), locationContext == null ? null : React.createElement(NavigationContext.Provider, {
|
|
943
599
|
value: navigationContext
|
|
944
600
|
}, React.createElement(LocationContext.Provider, {
|
|
945
601
|
children,
|
|
946
602
|
value: locationContext
|
|
947
603
|
}));
|
|
948
604
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
AwaitRenderStatus2[AwaitRenderStatus2["success"] = 1] = "success";
|
|
953
|
-
AwaitRenderStatus2[AwaitRenderStatus2["error"] = 2] = "error";
|
|
954
|
-
return AwaitRenderStatus2;
|
|
955
|
-
}(AwaitRenderStatus || {});
|
|
956
|
-
var neverSettledPromise = new Promise(() => {
|
|
605
|
+
var AwaitRenderStatus = (function(AwaitRenderStatus2) {
|
|
606
|
+
return AwaitRenderStatus2[AwaitRenderStatus2.pending = 0] = "pending", AwaitRenderStatus2[AwaitRenderStatus2.success = 1] = "success", AwaitRenderStatus2[AwaitRenderStatus2.error = 2] = "error", AwaitRenderStatus2;
|
|
607
|
+
})(AwaitRenderStatus || {}), neverSettledPromise = new Promise(() => {
|
|
957
608
|
});
|
|
958
609
|
|
|
959
610
|
// ../node_modules/react-router-dom/dist/index.js
|
|
960
611
|
function _extends3() {
|
|
961
|
-
_extends3 = Object.assign ? Object.assign.bind() : function(target) {
|
|
612
|
+
return _extends3 = Object.assign ? Object.assign.bind() : function(target) {
|
|
962
613
|
for (var i = 1; i < arguments.length; i++) {
|
|
963
614
|
var source = arguments[i];
|
|
964
|
-
for (var key in source)
|
|
965
|
-
|
|
966
|
-
target[key] = source[key];
|
|
967
|
-
}
|
|
968
|
-
}
|
|
615
|
+
for (var key in source)
|
|
616
|
+
Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
|
|
969
617
|
}
|
|
970
618
|
return target;
|
|
971
|
-
};
|
|
972
|
-
return _extends3.apply(this, arguments);
|
|
619
|
+
}, _extends3.apply(this, arguments);
|
|
973
620
|
}
|
|
974
|
-
__name(_extends3, "_extends");
|
|
975
621
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
976
622
|
if (source == null) return {};
|
|
977
|
-
var target = {};
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
981
|
-
key = sourceKeys[i];
|
|
982
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
983
|
-
target[key] = source[key];
|
|
984
|
-
}
|
|
623
|
+
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
624
|
+
for (i = 0; i < sourceKeys.length; i++)
|
|
625
|
+
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
985
626
|
return target;
|
|
986
627
|
}
|
|
987
|
-
|
|
988
|
-
var defaultMethod = "get";
|
|
989
|
-
var defaultEncType = "application/x-www-form-urlencoded";
|
|
628
|
+
var defaultMethod = "get", defaultEncType = "application/x-www-form-urlencoded";
|
|
990
629
|
function isHtmlElement(object) {
|
|
991
|
-
return object != null && typeof object.tagName
|
|
630
|
+
return object != null && typeof object.tagName == "string";
|
|
992
631
|
}
|
|
993
|
-
__name(isHtmlElement, "isHtmlElement");
|
|
994
632
|
function isButtonElement(object) {
|
|
995
633
|
return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
|
|
996
634
|
}
|
|
997
|
-
__name(isButtonElement, "isButtonElement");
|
|
998
635
|
function isFormElement(object) {
|
|
999
636
|
return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
|
|
1000
637
|
}
|
|
1001
|
-
__name(isFormElement, "isFormElement");
|
|
1002
638
|
function isInputElement(object) {
|
|
1003
639
|
return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
|
|
1004
640
|
}
|
|
1005
|
-
__name(isInputElement, "isInputElement");
|
|
1006
641
|
function isModifiedEvent(event) {
|
|
1007
642
|
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
|
1008
643
|
}
|
|
1009
|
-
__name(isModifiedEvent, "isModifiedEvent");
|
|
1010
644
|
function shouldProcessLinkClick(event, target) {
|
|
1011
645
|
return event.button === 0 && // Ignore everything but left clicks
|
|
1012
646
|
(!target || target === "_self") && // Let browser handle "target=_blank" etc.
|
|
1013
647
|
!isModifiedEvent(event);
|
|
1014
648
|
}
|
|
1015
|
-
__name(shouldProcessLinkClick, "shouldProcessLinkClick");
|
|
1016
649
|
var _formDataSupportsSubmitter = null;
|
|
1017
650
|
function isFormDataSubmitterSupported() {
|
|
1018
|
-
if (_formDataSupportsSubmitter === null)
|
|
651
|
+
if (_formDataSupportsSubmitter === null)
|
|
1019
652
|
try {
|
|
1020
653
|
new FormData(
|
|
1021
654
|
document.createElement("form"),
|
|
1022
655
|
// @ts-expect-error if FormData supports the submitter parameter, this will throw
|
|
1023
656
|
0
|
|
1024
|
-
);
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
_formDataSupportsSubmitter = true;
|
|
657
|
+
), _formDataSupportsSubmitter = !1;
|
|
658
|
+
} catch {
|
|
659
|
+
_formDataSupportsSubmitter = !0;
|
|
1028
660
|
}
|
|
1029
|
-
}
|
|
1030
661
|
return _formDataSupportsSubmitter;
|
|
1031
662
|
}
|
|
1032
|
-
__name(isFormDataSubmitterSupported, "isFormDataSubmitterSupported");
|
|
1033
663
|
var supportedFormEncTypes = /* @__PURE__ */ new Set(["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]);
|
|
1034
664
|
function getFormEncType(encType) {
|
|
1035
|
-
|
|
1036
|
-
process.env.NODE_ENV !== "production" ? warning(false, '"' + encType + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + defaultEncType + '"')) : void 0;
|
|
1037
|
-
return null;
|
|
1038
|
-
}
|
|
1039
|
-
return encType;
|
|
665
|
+
return encType != null && !supportedFormEncTypes.has(encType) ? (process.env.NODE_ENV !== "production" && warning(!1, '"' + encType + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + defaultEncType + '"')), null) : encType;
|
|
1040
666
|
}
|
|
1041
|
-
__name(getFormEncType, "getFormEncType");
|
|
1042
667
|
function getFormSubmissionInfo(target, basename) {
|
|
1043
|
-
let method;
|
|
1044
|
-
let action;
|
|
1045
|
-
let encType;
|
|
1046
|
-
let formData;
|
|
1047
|
-
let body;
|
|
668
|
+
let method, action, encType, formData, body;
|
|
1048
669
|
if (isFormElement(target)) {
|
|
1049
670
|
let attr = target.getAttribute("action");
|
|
1050
|
-
action = attr ? stripBasename(attr, basename) : null;
|
|
1051
|
-
method = target.getAttribute("method") || defaultMethod;
|
|
1052
|
-
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
|
|
1053
|
-
formData = new FormData(target);
|
|
671
|
+
action = attr ? stripBasename(attr, basename) : null, method = target.getAttribute("method") || defaultMethod, encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType, formData = new FormData(target);
|
|
1054
672
|
} else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
|
|
1055
673
|
let form = target.form;
|
|
1056
|
-
if (form == null)
|
|
674
|
+
if (form == null)
|
|
1057
675
|
throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');
|
|
1058
|
-
}
|
|
1059
676
|
let attr = target.getAttribute("formaction") || form.getAttribute("action");
|
|
1060
|
-
action = attr ? stripBasename(attr, basename) : null
|
|
1061
|
-
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
|
|
1062
|
-
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
|
|
1063
|
-
formData = new FormData(form, target);
|
|
1064
|
-
if (!isFormDataSubmitterSupported()) {
|
|
677
|
+
if (action = attr ? stripBasename(attr, basename) : null, method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod, encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType, formData = new FormData(form, target), !isFormDataSubmitterSupported()) {
|
|
1065
678
|
let {
|
|
1066
679
|
name,
|
|
1067
680
|
type,
|
|
@@ -1069,25 +682,15 @@ function getFormSubmissionInfo(target, basename) {
|
|
|
1069
682
|
} = target;
|
|
1070
683
|
if (type === "image") {
|
|
1071
684
|
let prefix = name ? name + "." : "";
|
|
1072
|
-
formData.append(prefix + "x", "0");
|
|
1073
|
-
|
|
1074
|
-
} else if (name) {
|
|
1075
|
-
formData.append(name, value);
|
|
1076
|
-
}
|
|
685
|
+
formData.append(prefix + "x", "0"), formData.append(prefix + "y", "0");
|
|
686
|
+
} else name && formData.append(name, value);
|
|
1077
687
|
}
|
|
1078
|
-
} else if (isHtmlElement(target)) {
|
|
1079
|
-
throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');
|
|
1080
688
|
} else {
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
encType = defaultEncType;
|
|
1084
|
-
body = target;
|
|
1085
|
-
}
|
|
1086
|
-
if (formData && encType === "text/plain") {
|
|
1087
|
-
body = formData;
|
|
1088
|
-
formData = void 0;
|
|
689
|
+
if (isHtmlElement(target))
|
|
690
|
+
throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');
|
|
691
|
+
method = defaultMethod, action = null, encType = defaultEncType, body = target;
|
|
1089
692
|
}
|
|
1090
|
-
return {
|
|
693
|
+
return formData && encType === "text/plain" && (body = formData, formData = void 0), {
|
|
1091
694
|
action,
|
|
1092
695
|
method: method.toLowerCase(),
|
|
1093
696
|
encType,
|
|
@@ -1095,39 +698,28 @@ function getFormSubmissionInfo(target, basename) {
|
|
|
1095
698
|
body
|
|
1096
699
|
};
|
|
1097
700
|
}
|
|
1098
|
-
|
|
1099
|
-
var
|
|
1100
|
-
var _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "children"];
|
|
1101
|
-
var _excluded3 = ["reloadDocument", "replace", "state", "method", "action", "onSubmit", "submit", "relative", "preventScrollReset"];
|
|
1102
|
-
var START_TRANSITION2 = "startTransition";
|
|
1103
|
-
var startTransitionImpl2 = React2[START_TRANSITION2];
|
|
701
|
+
var _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset"], _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "children"], _excluded3 = ["reloadDocument", "replace", "state", "method", "action", "onSubmit", "submit", "relative", "preventScrollReset"];
|
|
702
|
+
var START_TRANSITION2 = "startTransition", startTransitionImpl2 = React2[START_TRANSITION2];
|
|
1104
703
|
function BrowserRouter(_ref) {
|
|
1105
704
|
let {
|
|
1106
705
|
basename,
|
|
1107
706
|
children,
|
|
1108
707
|
future,
|
|
1109
708
|
window: window2
|
|
1110
|
-
} = _ref;
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
});
|
|
1117
|
-
}
|
|
1118
|
-
let history = historyRef.current;
|
|
1119
|
-
let [state, setStateImpl] = React2.useState({
|
|
709
|
+
} = _ref, historyRef = React2.useRef();
|
|
710
|
+
historyRef.current == null && (historyRef.current = createBrowserHistory({
|
|
711
|
+
window: window2,
|
|
712
|
+
v5Compat: !0
|
|
713
|
+
}));
|
|
714
|
+
let history = historyRef.current, [state, setStateImpl] = React2.useState({
|
|
1120
715
|
action: history.action,
|
|
1121
716
|
location: history.location
|
|
1122
|
-
})
|
|
1123
|
-
let {
|
|
717
|
+
}), {
|
|
1124
718
|
v7_startTransition
|
|
1125
|
-
} = future || {}
|
|
1126
|
-
let setState = React2.useCallback((newState) => {
|
|
719
|
+
} = future || {}, setState = React2.useCallback((newState) => {
|
|
1127
720
|
v7_startTransition && startTransitionImpl2 ? startTransitionImpl2(() => setStateImpl(newState)) : setStateImpl(newState);
|
|
1128
721
|
}, [setStateImpl, v7_startTransition]);
|
|
1129
|
-
React2.useLayoutEffect(() => history.listen(setState), [history, setState])
|
|
1130
|
-
return React2.createElement(Router, {
|
|
722
|
+
return React2.useLayoutEffect(() => history.listen(setState), [history, setState]), React2.createElement(Router, {
|
|
1131
723
|
basename,
|
|
1132
724
|
children,
|
|
1133
725
|
location: state.location,
|
|
@@ -1135,26 +727,21 @@ function BrowserRouter(_ref) {
|
|
|
1135
727
|
navigator: history
|
|
1136
728
|
});
|
|
1137
729
|
}
|
|
1138
|
-
__name(BrowserRouter, "BrowserRouter");
|
|
1139
730
|
function HistoryRouter(_ref3) {
|
|
1140
731
|
let {
|
|
1141
732
|
basename,
|
|
1142
733
|
children,
|
|
1143
734
|
future,
|
|
1144
735
|
history
|
|
1145
|
-
} = _ref3
|
|
1146
|
-
let [state, setStateImpl] = React2.useState({
|
|
736
|
+
} = _ref3, [state, setStateImpl] = React2.useState({
|
|
1147
737
|
action: history.action,
|
|
1148
738
|
location: history.location
|
|
1149
|
-
})
|
|
1150
|
-
let {
|
|
739
|
+
}), {
|
|
1151
740
|
v7_startTransition
|
|
1152
|
-
} = future || {}
|
|
1153
|
-
let setState = React2.useCallback((newState) => {
|
|
741
|
+
} = future || {}, setState = React2.useCallback((newState) => {
|
|
1154
742
|
v7_startTransition && startTransitionImpl2 ? startTransitionImpl2(() => setStateImpl(newState)) : setStateImpl(newState);
|
|
1155
743
|
}, [setStateImpl, v7_startTransition]);
|
|
1156
|
-
React2.useLayoutEffect(() => history.listen(setState), [history, setState])
|
|
1157
|
-
return React2.createElement(Router, {
|
|
744
|
+
return React2.useLayoutEffect(() => history.listen(setState), [history, setState]), React2.createElement(Router, {
|
|
1158
745
|
basename,
|
|
1159
746
|
children,
|
|
1160
747
|
location: state.location,
|
|
@@ -1162,13 +749,8 @@ function HistoryRouter(_ref3) {
|
|
|
1162
749
|
navigator: history
|
|
1163
750
|
});
|
|
1164
751
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
HistoryRouter.displayName = "unstable_HistoryRouter";
|
|
1168
|
-
}
|
|
1169
|
-
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
1170
|
-
var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
1171
|
-
var Link = React2.forwardRef(/* @__PURE__ */ __name(function LinkWithRef(_ref4, ref) {
|
|
752
|
+
process.env.NODE_ENV !== "production" && (HistoryRouter.displayName = "unstable_HistoryRouter");
|
|
753
|
+
var isBrowser = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, Link = React2.forwardRef(function(_ref4, ref) {
|
|
1172
754
|
let {
|
|
1173
755
|
onClick,
|
|
1174
756
|
relative,
|
|
@@ -1178,33 +760,19 @@ var Link = React2.forwardRef(/* @__PURE__ */ __name(function LinkWithRef(_ref4,
|
|
|
1178
760
|
target,
|
|
1179
761
|
to,
|
|
1180
762
|
preventScrollReset
|
|
1181
|
-
} = _ref4, rest = _objectWithoutPropertiesLoose(_ref4, _excluded)
|
|
1182
|
-
let {
|
|
763
|
+
} = _ref4, rest = _objectWithoutPropertiesLoose(_ref4, _excluded), {
|
|
1183
764
|
basename
|
|
1184
|
-
} = React2.useContext(NavigationContext);
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
let currentUrl = new URL(window.location.href);
|
|
1192
|
-
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
|
|
1193
|
-
let path = stripBasename(targetUrl.pathname, basename);
|
|
1194
|
-
if (targetUrl.origin === currentUrl.origin && path != null) {
|
|
1195
|
-
to = path + targetUrl.search + targetUrl.hash;
|
|
1196
|
-
} else {
|
|
1197
|
-
isExternal = true;
|
|
1198
|
-
}
|
|
1199
|
-
} catch (e) {
|
|
1200
|
-
process.env.NODE_ENV !== "production" ? warning(false, '<Link to="' + to + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.') : void 0;
|
|
1201
|
-
}
|
|
765
|
+
} = React2.useContext(NavigationContext), absoluteHref, isExternal = !1;
|
|
766
|
+
if (typeof to == "string" && ABSOLUTE_URL_REGEX.test(to) && (absoluteHref = to, isBrowser))
|
|
767
|
+
try {
|
|
768
|
+
let currentUrl = new URL(window.location.href), targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to), path = stripBasename(targetUrl.pathname, basename);
|
|
769
|
+
targetUrl.origin === currentUrl.origin && path != null ? to = path + targetUrl.search + targetUrl.hash : isExternal = !0;
|
|
770
|
+
} catch {
|
|
771
|
+
process.env.NODE_ENV !== "production" && warning(!1, '<Link to="' + to + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.');
|
|
1202
772
|
}
|
|
1203
|
-
}
|
|
1204
773
|
let href = useHref(to, {
|
|
1205
774
|
relative
|
|
1206
|
-
})
|
|
1207
|
-
let internalOnClick = useLinkClickHandler(to, {
|
|
775
|
+
}), internalOnClick = useLinkClickHandler(to, {
|
|
1208
776
|
replace,
|
|
1209
777
|
state,
|
|
1210
778
|
target,
|
|
@@ -1212,12 +780,8 @@ var Link = React2.forwardRef(/* @__PURE__ */ __name(function LinkWithRef(_ref4,
|
|
|
1212
780
|
relative
|
|
1213
781
|
});
|
|
1214
782
|
function handleClick(event) {
|
|
1215
|
-
|
|
1216
|
-
if (!event.defaultPrevented) {
|
|
1217
|
-
internalOnClick(event);
|
|
1218
|
-
}
|
|
783
|
+
onClick && onClick(event), event.defaultPrevented || internalOnClick(event);
|
|
1219
784
|
}
|
|
1220
|
-
__name(handleClick, "handleClick");
|
|
1221
785
|
return (
|
|
1222
786
|
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
1223
787
|
React2.createElement("a", _extends3({}, rest, {
|
|
@@ -1227,49 +791,29 @@ var Link = React2.forwardRef(/* @__PURE__ */ __name(function LinkWithRef(_ref4,
|
|
|
1227
791
|
target
|
|
1228
792
|
}))
|
|
1229
793
|
);
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
}
|
|
1234
|
-
var NavLink = React2.forwardRef(/* @__PURE__ */ __name(function NavLinkWithRef(_ref5, ref) {
|
|
794
|
+
});
|
|
795
|
+
process.env.NODE_ENV !== "production" && (Link.displayName = "Link");
|
|
796
|
+
var NavLink = React2.forwardRef(function(_ref5, ref) {
|
|
1235
797
|
let {
|
|
1236
798
|
"aria-current": ariaCurrentProp = "page",
|
|
1237
|
-
caseSensitive =
|
|
799
|
+
caseSensitive = !1,
|
|
1238
800
|
className: classNameProp = "",
|
|
1239
|
-
end =
|
|
801
|
+
end = !1,
|
|
1240
802
|
style: styleProp,
|
|
1241
803
|
to,
|
|
1242
804
|
children
|
|
1243
|
-
} = _ref5, rest = _objectWithoutPropertiesLoose(_ref5, _excluded2)
|
|
1244
|
-
let path = useResolvedPath(to, {
|
|
805
|
+
} = _ref5, rest = _objectWithoutPropertiesLoose(_ref5, _excluded2), path = useResolvedPath(to, {
|
|
1245
806
|
relative: rest.relative
|
|
1246
|
-
})
|
|
1247
|
-
let location = useLocation();
|
|
1248
|
-
let routerState = React2.useContext(DataRouterStateContext);
|
|
1249
|
-
let {
|
|
807
|
+
}), location = useLocation(), routerState = React2.useContext(DataRouterStateContext), {
|
|
1250
808
|
navigator
|
|
1251
|
-
} = React2.useContext(NavigationContext);
|
|
1252
|
-
|
|
1253
|
-
let locationPathname =
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
}
|
|
1260
|
-
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(toPathname.length) === "/";
|
|
1261
|
-
let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
|
|
1262
|
-
let ariaCurrent = isActive ? ariaCurrentProp : void 0;
|
|
1263
|
-
let className;
|
|
1264
|
-
if (typeof classNameProp === "function") {
|
|
1265
|
-
className = classNameProp({
|
|
1266
|
-
isActive,
|
|
1267
|
-
isPending
|
|
1268
|
-
});
|
|
1269
|
-
} else {
|
|
1270
|
-
className = [classNameProp, isActive ? "active" : null, isPending ? "pending" : null].filter(Boolean).join(" ");
|
|
1271
|
-
}
|
|
1272
|
-
let style = typeof styleProp === "function" ? styleProp({
|
|
809
|
+
} = React2.useContext(NavigationContext), toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname, locationPathname = location.pathname, nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
|
|
810
|
+
caseSensitive || (locationPathname = locationPathname.toLowerCase(), nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null, toPathname = toPathname.toLowerCase());
|
|
811
|
+
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(toPathname.length) === "/", isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/"), ariaCurrent = isActive ? ariaCurrentProp : void 0, className;
|
|
812
|
+
typeof classNameProp == "function" ? className = classNameProp({
|
|
813
|
+
isActive,
|
|
814
|
+
isPending
|
|
815
|
+
}) : className = [classNameProp, isActive ? "active" : null, isPending ? "pending" : null].filter(Boolean).join(" ");
|
|
816
|
+
let style = typeof styleProp == "function" ? styleProp({
|
|
1273
817
|
isActive,
|
|
1274
818
|
isPending
|
|
1275
819
|
}) : styleProp;
|
|
@@ -1279,14 +823,12 @@ var NavLink = React2.forwardRef(/* @__PURE__ */ __name(function NavLinkWithRef(_
|
|
|
1279
823
|
ref,
|
|
1280
824
|
style,
|
|
1281
825
|
to
|
|
1282
|
-
}), typeof children
|
|
826
|
+
}), typeof children == "function" ? children({
|
|
1283
827
|
isActive,
|
|
1284
828
|
isPending
|
|
1285
829
|
}) : children);
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
NavLink.displayName = "NavLink";
|
|
1289
|
-
}
|
|
830
|
+
});
|
|
831
|
+
process.env.NODE_ENV !== "production" && (NavLink.displayName = "NavLink");
|
|
1290
832
|
var Form = React2.forwardRef((props, ref) => {
|
|
1291
833
|
let submit = useSubmit();
|
|
1292
834
|
return React2.createElement(FormImpl, _extends3({}, props, {
|
|
@@ -1294,9 +836,7 @@ var Form = React2.forwardRef((props, ref) => {
|
|
|
1294
836
|
ref
|
|
1295
837
|
}));
|
|
1296
838
|
});
|
|
1297
|
-
|
|
1298
|
-
Form.displayName = "Form";
|
|
1299
|
-
}
|
|
839
|
+
process.env.NODE_ENV !== "production" && (Form.displayName = "Form");
|
|
1300
840
|
var FormImpl = React2.forwardRef((_ref6, forwardedRef) => {
|
|
1301
841
|
let {
|
|
1302
842
|
reloadDocument,
|
|
@@ -1308,78 +848,58 @@ var FormImpl = React2.forwardRef((_ref6, forwardedRef) => {
|
|
|
1308
848
|
submit,
|
|
1309
849
|
relative,
|
|
1310
850
|
preventScrollReset
|
|
1311
|
-
} = _ref6, props = _objectWithoutPropertiesLoose(_ref6, _excluded3)
|
|
1312
|
-
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
|
|
1313
|
-
let formAction = useFormAction(action, {
|
|
851
|
+
} = _ref6, props = _objectWithoutPropertiesLoose(_ref6, _excluded3), formMethod = method.toLowerCase() === "get" ? "get" : "post", formAction = useFormAction(action, {
|
|
1314
852
|
relative
|
|
1315
853
|
});
|
|
1316
|
-
let submitHandler = /* @__PURE__ */ __name((event) => {
|
|
1317
|
-
onSubmit && onSubmit(event);
|
|
1318
|
-
if (event.defaultPrevented) return;
|
|
1319
|
-
event.preventDefault();
|
|
1320
|
-
let submitter = event.nativeEvent.submitter;
|
|
1321
|
-
let submitMethod = (submitter == null ? void 0 : submitter.getAttribute("formmethod")) || method;
|
|
1322
|
-
submit(submitter || event.currentTarget, {
|
|
1323
|
-
method: submitMethod,
|
|
1324
|
-
replace,
|
|
1325
|
-
state,
|
|
1326
|
-
relative,
|
|
1327
|
-
preventScrollReset
|
|
1328
|
-
});
|
|
1329
|
-
}, "submitHandler");
|
|
1330
854
|
return React2.createElement("form", _extends3({
|
|
1331
855
|
ref: forwardedRef,
|
|
1332
856
|
method: formMethod,
|
|
1333
857
|
action: formAction,
|
|
1334
|
-
onSubmit: reloadDocument ? onSubmit :
|
|
858
|
+
onSubmit: reloadDocument ? onSubmit : (event) => {
|
|
859
|
+
if (onSubmit && onSubmit(event), event.defaultPrevented) return;
|
|
860
|
+
event.preventDefault();
|
|
861
|
+
let submitter = event.nativeEvent.submitter, submitMethod = submitter?.getAttribute("formmethod") || method;
|
|
862
|
+
submit(submitter || event.currentTarget, {
|
|
863
|
+
method: submitMethod,
|
|
864
|
+
replace,
|
|
865
|
+
state,
|
|
866
|
+
relative,
|
|
867
|
+
preventScrollReset
|
|
868
|
+
});
|
|
869
|
+
}
|
|
1335
870
|
}, props));
|
|
1336
871
|
});
|
|
1337
|
-
|
|
1338
|
-
FormImpl.displayName = "FormImpl";
|
|
1339
|
-
}
|
|
872
|
+
process.env.NODE_ENV !== "production" && (FormImpl.displayName = "FormImpl");
|
|
1340
873
|
function ScrollRestoration(_ref7) {
|
|
1341
874
|
let {
|
|
1342
875
|
getKey,
|
|
1343
876
|
storageKey
|
|
1344
877
|
} = _ref7;
|
|
1345
|
-
useScrollRestoration({
|
|
878
|
+
return useScrollRestoration({
|
|
1346
879
|
getKey,
|
|
1347
880
|
storageKey
|
|
1348
|
-
});
|
|
1349
|
-
return null;
|
|
1350
|
-
}
|
|
1351
|
-
__name(ScrollRestoration, "ScrollRestoration");
|
|
1352
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1353
|
-
ScrollRestoration.displayName = "ScrollRestoration";
|
|
881
|
+
}), null;
|
|
1354
882
|
}
|
|
883
|
+
process.env.NODE_ENV !== "production" && (ScrollRestoration.displayName = "ScrollRestoration");
|
|
1355
884
|
var DataRouterHook2;
|
|
1356
885
|
(function(DataRouterHook3) {
|
|
1357
|
-
DataRouterHook3
|
|
1358
|
-
DataRouterHook3["UseSubmit"] = "useSubmit";
|
|
1359
|
-
DataRouterHook3["UseSubmitFetcher"] = "useSubmitFetcher";
|
|
1360
|
-
DataRouterHook3["UseFetcher"] = "useFetcher";
|
|
886
|
+
DataRouterHook3.UseScrollRestoration = "useScrollRestoration", DataRouterHook3.UseSubmit = "useSubmit", DataRouterHook3.UseSubmitFetcher = "useSubmitFetcher", DataRouterHook3.UseFetcher = "useFetcher";
|
|
1361
887
|
})(DataRouterHook2 || (DataRouterHook2 = {}));
|
|
1362
888
|
var DataRouterStateHook2;
|
|
1363
889
|
(function(DataRouterStateHook3) {
|
|
1364
|
-
DataRouterStateHook3
|
|
1365
|
-
DataRouterStateHook3["UseScrollRestoration"] = "useScrollRestoration";
|
|
890
|
+
DataRouterStateHook3.UseFetchers = "useFetchers", DataRouterStateHook3.UseScrollRestoration = "useScrollRestoration";
|
|
1366
891
|
})(DataRouterStateHook2 || (DataRouterStateHook2 = {}));
|
|
1367
892
|
function getDataRouterConsoleError2(hookName) {
|
|
1368
893
|
return hookName + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router.";
|
|
1369
894
|
}
|
|
1370
|
-
__name(getDataRouterConsoleError2, "getDataRouterConsoleError");
|
|
1371
895
|
function useDataRouterContext2(hookName) {
|
|
1372
896
|
let ctx = React2.useContext(DataRouterContext);
|
|
1373
|
-
|
|
1374
|
-
return ctx;
|
|
897
|
+
return ctx || (process.env.NODE_ENV !== "production" ? invariant(!1, getDataRouterConsoleError2(hookName)) : invariant(!1)), ctx;
|
|
1375
898
|
}
|
|
1376
|
-
__name(useDataRouterContext2, "useDataRouterContext");
|
|
1377
899
|
function useDataRouterState2(hookName) {
|
|
1378
900
|
let state = React2.useContext(DataRouterStateContext);
|
|
1379
|
-
|
|
1380
|
-
return state;
|
|
901
|
+
return state || (process.env.NODE_ENV !== "production" ? invariant(!1, getDataRouterConsoleError2(hookName)) : invariant(!1)), state;
|
|
1381
902
|
}
|
|
1382
|
-
__name(useDataRouterState2, "useDataRouterState");
|
|
1383
903
|
function useLinkClickHandler(to, _temp) {
|
|
1384
904
|
let {
|
|
1385
905
|
target,
|
|
@@ -1387,10 +907,7 @@ function useLinkClickHandler(to, _temp) {
|
|
|
1387
907
|
state,
|
|
1388
908
|
preventScrollReset,
|
|
1389
909
|
relative
|
|
1390
|
-
} = _temp === void 0 ? {} : _temp
|
|
1391
|
-
let navigate = useNavigate();
|
|
1392
|
-
let location = useLocation();
|
|
1393
|
-
let path = useResolvedPath(to, {
|
|
910
|
+
} = _temp === void 0 ? {} : _temp, navigate = useNavigate(), location = useLocation(), path = useResolvedPath(to, {
|
|
1394
911
|
relative
|
|
1395
912
|
});
|
|
1396
913
|
return React2.useCallback((event) => {
|
|
@@ -1406,26 +923,18 @@ function useLinkClickHandler(to, _temp) {
|
|
|
1406
923
|
}
|
|
1407
924
|
}, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative]);
|
|
1408
925
|
}
|
|
1409
|
-
__name(useLinkClickHandler, "useLinkClickHandler");
|
|
1410
926
|
function validateClientSideSubmission() {
|
|
1411
|
-
if (typeof document
|
|
927
|
+
if (typeof document > "u")
|
|
1412
928
|
throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");
|
|
1413
|
-
}
|
|
1414
929
|
}
|
|
1415
|
-
__name(validateClientSideSubmission, "validateClientSideSubmission");
|
|
1416
930
|
function useSubmit() {
|
|
1417
931
|
let {
|
|
1418
932
|
router
|
|
1419
|
-
} = useDataRouterContext2(DataRouterHook2.UseSubmit)
|
|
1420
|
-
let {
|
|
933
|
+
} = useDataRouterContext2(DataRouterHook2.UseSubmit), {
|
|
1421
934
|
basename
|
|
1422
|
-
} = React2.useContext(NavigationContext);
|
|
1423
|
-
let currentRouteId = useRouteId();
|
|
935
|
+
} = React2.useContext(NavigationContext), currentRouteId = useRouteId();
|
|
1424
936
|
return React2.useCallback(function(target, options) {
|
|
1425
|
-
|
|
1426
|
-
options = {};
|
|
1427
|
-
}
|
|
1428
|
-
validateClientSideSubmission();
|
|
937
|
+
options === void 0 && (options = {}), validateClientSideSubmission();
|
|
1429
938
|
let {
|
|
1430
939
|
action,
|
|
1431
940
|
method,
|
|
@@ -1445,98 +954,61 @@ function useSubmit() {
|
|
|
1445
954
|
});
|
|
1446
955
|
}, [router, basename, currentRouteId]);
|
|
1447
956
|
}
|
|
1448
|
-
__name(useSubmit, "useSubmit");
|
|
1449
957
|
function useFormAction(action, _temp2) {
|
|
1450
958
|
let {
|
|
1451
959
|
relative
|
|
1452
|
-
} = _temp2 === void 0 ? {} : _temp2
|
|
1453
|
-
let {
|
|
960
|
+
} = _temp2 === void 0 ? {} : _temp2, {
|
|
1454
961
|
basename
|
|
1455
|
-
} = React2.useContext(NavigationContext);
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
let [match] = routeContext.matches.slice(-1);
|
|
1459
|
-
let path = _extends3({}, useResolvedPath(action ? action : ".", {
|
|
962
|
+
} = React2.useContext(NavigationContext), routeContext = React2.useContext(RouteContext);
|
|
963
|
+
routeContext || (process.env.NODE_ENV !== "production" ? invariant(!1, "useFormAction must be used inside a RouteContext") : invariant(!1));
|
|
964
|
+
let [match] = routeContext.matches.slice(-1), path = _extends3({}, useResolvedPath(action || ".", {
|
|
1460
965
|
relative
|
|
1461
|
-
}));
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
path.search =
|
|
1465
|
-
if (match.route.index) {
|
|
1466
|
-
let params = new URLSearchParams(path.search);
|
|
1467
|
-
params.delete("index");
|
|
1468
|
-
path.search = params.toString() ? "?" + params.toString() : "";
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
if ((!action || action === ".") && match.route.index) {
|
|
1472
|
-
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
|
|
1473
|
-
}
|
|
1474
|
-
if (basename !== "/") {
|
|
1475
|
-
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
|
966
|
+
})), location = useLocation();
|
|
967
|
+
if (action == null && (path.search = location.search, match.route.index)) {
|
|
968
|
+
let params = new URLSearchParams(path.search);
|
|
969
|
+
params.delete("index"), path.search = params.toString() ? "?" + params.toString() : "";
|
|
1476
970
|
}
|
|
1477
|
-
return createPath(path);
|
|
971
|
+
return (!action || action === ".") && match.route.index && (path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index"), basename !== "/" && (path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname])), createPath(path);
|
|
1478
972
|
}
|
|
1479
|
-
|
|
1480
|
-
var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
|
|
1481
|
-
var savedScrollPositions = {};
|
|
973
|
+
var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions", savedScrollPositions = {};
|
|
1482
974
|
function useScrollRestoration(_temp3) {
|
|
1483
975
|
let {
|
|
1484
976
|
getKey,
|
|
1485
977
|
storageKey
|
|
1486
|
-
} = _temp3 === void 0 ? {} : _temp3
|
|
1487
|
-
let {
|
|
978
|
+
} = _temp3 === void 0 ? {} : _temp3, {
|
|
1488
979
|
router
|
|
1489
|
-
} = useDataRouterContext2(DataRouterHook2.UseScrollRestoration)
|
|
1490
|
-
let {
|
|
980
|
+
} = useDataRouterContext2(DataRouterHook2.UseScrollRestoration), {
|
|
1491
981
|
restoreScrollPosition,
|
|
1492
982
|
preventScrollReset
|
|
1493
|
-
} = useDataRouterState2(DataRouterStateHook2.UseScrollRestoration)
|
|
1494
|
-
let {
|
|
983
|
+
} = useDataRouterState2(DataRouterStateHook2.UseScrollRestoration), {
|
|
1495
984
|
basename
|
|
1496
|
-
} = React2.useContext(NavigationContext);
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
React2.useEffect(() => {
|
|
1501
|
-
window.history.scrollRestoration = "manual";
|
|
1502
|
-
return () => {
|
|
1503
|
-
window.history.scrollRestoration = "auto";
|
|
1504
|
-
};
|
|
1505
|
-
}, []);
|
|
1506
|
-
usePageHide(React2.useCallback(() => {
|
|
985
|
+
} = React2.useContext(NavigationContext), location = useLocation(), matches = useMatches(), navigation = useNavigation();
|
|
986
|
+
React2.useEffect(() => (window.history.scrollRestoration = "manual", () => {
|
|
987
|
+
window.history.scrollRestoration = "auto";
|
|
988
|
+
}), []), usePageHide(React2.useCallback(() => {
|
|
1507
989
|
if (navigation.state === "idle") {
|
|
1508
990
|
let key = (getKey ? getKey(location, matches) : null) || location.key;
|
|
1509
991
|
savedScrollPositions[key] = window.scrollY;
|
|
1510
992
|
}
|
|
1511
|
-
sessionStorage.setItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY, JSON.stringify(savedScrollPositions));
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
matches2
|
|
1531
|
-
) : getKey;
|
|
1532
|
-
let disableScrollRestoration = router == null ? void 0 : router.enableScrollRestoration(savedScrollPositions, () => window.scrollY, getKeyWithoutBasename);
|
|
1533
|
-
return () => disableScrollRestoration && disableScrollRestoration();
|
|
1534
|
-
}, [router, basename, getKey]);
|
|
1535
|
-
React2.useLayoutEffect(() => {
|
|
1536
|
-
if (restoreScrollPosition === false) {
|
|
1537
|
-
return;
|
|
1538
|
-
}
|
|
1539
|
-
if (typeof restoreScrollPosition === "number") {
|
|
993
|
+
sessionStorage.setItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY, JSON.stringify(savedScrollPositions)), window.history.scrollRestoration = "auto";
|
|
994
|
+
}, [storageKey, getKey, navigation.state, location, matches])), typeof document < "u" && (React2.useLayoutEffect(() => {
|
|
995
|
+
try {
|
|
996
|
+
let sessionPositions = sessionStorage.getItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY);
|
|
997
|
+
sessionPositions && (savedScrollPositions = JSON.parse(sessionPositions));
|
|
998
|
+
} catch {
|
|
999
|
+
}
|
|
1000
|
+
}, [storageKey]), React2.useLayoutEffect(() => {
|
|
1001
|
+
let getKeyWithoutBasename = getKey && basename !== "/" ? (location2, matches2) => getKey(
|
|
1002
|
+
// Strip the basename to match useLocation()
|
|
1003
|
+
_extends3({}, location2, {
|
|
1004
|
+
pathname: stripBasename(location2.pathname, basename) || location2.pathname
|
|
1005
|
+
}),
|
|
1006
|
+
matches2
|
|
1007
|
+
) : getKey, disableScrollRestoration = router?.enableScrollRestoration(savedScrollPositions, () => window.scrollY, getKeyWithoutBasename);
|
|
1008
|
+
return () => disableScrollRestoration && disableScrollRestoration();
|
|
1009
|
+
}, [router, basename, getKey]), React2.useLayoutEffect(() => {
|
|
1010
|
+
if (restoreScrollPosition !== !1) {
|
|
1011
|
+
if (typeof restoreScrollPosition == "number") {
|
|
1540
1012
|
window.scrollTo(0, restoreScrollPosition);
|
|
1541
1013
|
return;
|
|
1542
1014
|
}
|
|
@@ -1547,14 +1019,10 @@ function useScrollRestoration(_temp3) {
|
|
|
1547
1019
|
return;
|
|
1548
1020
|
}
|
|
1549
1021
|
}
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
window.scrollTo(0, 0);
|
|
1554
|
-
}, [location, restoreScrollPosition, preventScrollReset]);
|
|
1555
|
-
}
|
|
1022
|
+
preventScrollReset !== !0 && window.scrollTo(0, 0);
|
|
1023
|
+
}
|
|
1024
|
+
}, [location, restoreScrollPosition, preventScrollReset]));
|
|
1556
1025
|
}
|
|
1557
|
-
__name(useScrollRestoration, "useScrollRestoration");
|
|
1558
1026
|
function usePageHide(callback, options) {
|
|
1559
1027
|
let {
|
|
1560
1028
|
capture
|
|
@@ -1563,44 +1031,31 @@ function usePageHide(callback, options) {
|
|
|
1563
1031
|
let opts = capture != null ? {
|
|
1564
1032
|
capture
|
|
1565
1033
|
} : void 0;
|
|
1566
|
-
window.addEventListener("pagehide", callback, opts)
|
|
1567
|
-
return () => {
|
|
1034
|
+
return window.addEventListener("pagehide", callback, opts), () => {
|
|
1568
1035
|
window.removeEventListener("pagehide", callback, opts);
|
|
1569
1036
|
};
|
|
1570
1037
|
}, [callback, capture]);
|
|
1571
1038
|
}
|
|
1572
|
-
__name(usePageHide, "usePageHide");
|
|
1573
1039
|
|
|
1574
1040
|
// src/router/router.tsx
|
|
1575
|
-
var { document: document2 } = global
|
|
1576
|
-
|
|
1577
|
-
var useNavigate2 = /* @__PURE__ */ __name(() => {
|
|
1578
|
-
const navigate = useNavigate();
|
|
1041
|
+
var { document: document2 } = global, getBase = () => `${document2.location.pathname}?`, useNavigate2 = () => {
|
|
1042
|
+
let navigate = useNavigate();
|
|
1579
1043
|
return useCallback3((to, { plain, ...options } = {}) => {
|
|
1580
|
-
if (typeof to
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
} else {
|
|
1584
|
-
document2.location.hash = to;
|
|
1585
|
-
}
|
|
1586
|
-
return void 0;
|
|
1044
|
+
if (typeof to == "string" && to.startsWith("#")) {
|
|
1045
|
+
to === "#" ? navigate(document2.location.search) : document2.location.hash = to;
|
|
1046
|
+
return;
|
|
1587
1047
|
}
|
|
1588
|
-
if (typeof to
|
|
1589
|
-
|
|
1048
|
+
if (typeof to == "string") {
|
|
1049
|
+
let target = plain ? to : `?path=${to}`;
|
|
1590
1050
|
return navigate(target, options);
|
|
1591
1051
|
}
|
|
1592
|
-
if (typeof to
|
|
1052
|
+
if (typeof to == "number")
|
|
1593
1053
|
return navigate(to);
|
|
1594
|
-
}
|
|
1595
|
-
return void 0;
|
|
1596
1054
|
}, []);
|
|
1597
|
-
},
|
|
1598
|
-
var Link2 = /* @__PURE__ */ __name(({ to, children, ...rest }) => React3.createElement(Link, { to: `${getBase()}path=${to}`, ...rest }, children), "Link");
|
|
1055
|
+
}, Link2 = ({ to, children, ...rest }) => React3.createElement(Link, { to: `${getBase()}path=${to}`, ...rest }, children);
|
|
1599
1056
|
Link2.displayName = "QueryLink";
|
|
1600
|
-
var Location =
|
|
1601
|
-
|
|
1602
|
-
const { path, singleStory } = queryFromLocation(location);
|
|
1603
|
-
const { viewMode, storyId, refId } = parsePath(path);
|
|
1057
|
+
var Location = ({ children }) => {
|
|
1058
|
+
let location = useLocation(), { path, singleStory } = queryFromLocation(location), { viewMode, storyId, refId } = parsePath(path);
|
|
1604
1059
|
return React3.createElement(React3.Fragment, null, children({
|
|
1605
1060
|
path: path || "/",
|
|
1606
1061
|
location,
|
|
@@ -1609,32 +1064,25 @@ var Location = /* @__PURE__ */ __name(({ children }) => {
|
|
|
1609
1064
|
refId,
|
|
1610
1065
|
singleStory: singleStory === "true"
|
|
1611
1066
|
}));
|
|
1612
|
-
}
|
|
1067
|
+
};
|
|
1613
1068
|
Location.displayName = "QueryLocation";
|
|
1614
1069
|
function Match({
|
|
1615
1070
|
children,
|
|
1616
1071
|
path: targetPath,
|
|
1617
|
-
startsWith =
|
|
1072
|
+
startsWith = !1
|
|
1618
1073
|
}) {
|
|
1619
1074
|
return React3.createElement(Location, null, ({ path: urlPath, ...rest }) => children({
|
|
1620
1075
|
match: getMatch(urlPath, targetPath, startsWith),
|
|
1621
1076
|
...rest
|
|
1622
1077
|
}));
|
|
1623
1078
|
}
|
|
1624
|
-
__name(Match, "Match");
|
|
1625
1079
|
Match.displayName = "QueryMatch";
|
|
1626
1080
|
function Route2(input) {
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
rest.startsWith = false;
|
|
1630
|
-
}
|
|
1631
|
-
const matchProps = rest;
|
|
1632
|
-
return React3.createElement(Match, { ...matchProps }, ({ match }) => match ? children : null);
|
|
1081
|
+
let { children, ...rest } = input;
|
|
1082
|
+
return rest.startsWith === void 0 && (rest.startsWith = !1), React3.createElement(Match, { ...rest }, ({ match }) => match ? children : null);
|
|
1633
1083
|
}
|
|
1634
|
-
__name(Route2, "Route");
|
|
1635
1084
|
Route2.displayName = "Route";
|
|
1636
|
-
var LocationProvider =
|
|
1637
|
-
var BaseLocationProvider = /* @__PURE__ */ __name((...args) => Router(...args), "BaseLocationProvider");
|
|
1085
|
+
var LocationProvider = (...args) => BrowserRouter(...args), BaseLocationProvider = (...args) => Router(...args);
|
|
1638
1086
|
export {
|
|
1639
1087
|
BaseLocationProvider,
|
|
1640
1088
|
DEEPLY_EQUAL,
|