warqadui 0.0.69 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +204 -2610
- package/dist/index.mjs +219 -2624
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1408,8 +1408,8 @@ var useModal = (initialState = false) => {
|
|
|
1408
1408
|
resetState();
|
|
1409
1409
|
}, []);
|
|
1410
1410
|
const toggle = useCallback2(() => setIsOpen((prev) => !prev), []);
|
|
1411
|
-
const openState = useCallback2((
|
|
1412
|
-
setState(
|
|
1411
|
+
const openState = useCallback2((data) => {
|
|
1412
|
+
setState(data);
|
|
1413
1413
|
open();
|
|
1414
1414
|
}, []);
|
|
1415
1415
|
const ModalComponent = useMemo2(() => {
|
|
@@ -2104,7 +2104,7 @@ var useApi = () => {
|
|
|
2104
2104
|
withCredentials: true
|
|
2105
2105
|
});
|
|
2106
2106
|
}, [configApi]);
|
|
2107
|
-
const [
|
|
2107
|
+
const [data, setData] = useState13();
|
|
2108
2108
|
const [isLoading, setIsLoading] = useState13(false);
|
|
2109
2109
|
const [pdfLoading, setPdfLoading] = useState13(false);
|
|
2110
2110
|
const [error, setError] = useState13(null);
|
|
@@ -2244,7 +2244,7 @@ var useApi = () => {
|
|
|
2244
2244
|
}
|
|
2245
2245
|
};
|
|
2246
2246
|
return {
|
|
2247
|
-
data
|
|
2247
|
+
data,
|
|
2248
2248
|
error,
|
|
2249
2249
|
isLoading,
|
|
2250
2250
|
pdfLoading,
|
|
@@ -3065,7 +3065,7 @@ import { ChevronDown as ChevronDown4, Search as Search2 } from "lucide-react";
|
|
|
3065
3065
|
import { Fragment as Fragment6, jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3066
3066
|
function DataTable({
|
|
3067
3067
|
columns: userColumns,
|
|
3068
|
-
data
|
|
3068
|
+
data,
|
|
3069
3069
|
isLoading = false,
|
|
3070
3070
|
pageRows,
|
|
3071
3071
|
searchPlaceholder = "Search all columns...",
|
|
@@ -3113,8 +3113,8 @@ function DataTable({
|
|
|
3113
3113
|
}, [pageRows]);
|
|
3114
3114
|
const [expanded, setExpanded] = useState16(() => {
|
|
3115
3115
|
const initialState = {};
|
|
3116
|
-
if (defaultExpanded && renderSubComponent &&
|
|
3117
|
-
|
|
3116
|
+
if (defaultExpanded && renderSubComponent && data) {
|
|
3117
|
+
data.forEach((row, idx) => {
|
|
3118
3118
|
if (hasSubComponent(row)) {
|
|
3119
3119
|
initialState[idx] = true;
|
|
3120
3120
|
}
|
|
@@ -3145,7 +3145,7 @@ function DataTable({
|
|
|
3145
3145
|
];
|
|
3146
3146
|
}, [userColumns, index, selectable]);
|
|
3147
3147
|
const table = useReactTable({
|
|
3148
|
-
data
|
|
3148
|
+
data,
|
|
3149
3149
|
columns,
|
|
3150
3150
|
onSortingChange: setSorting,
|
|
3151
3151
|
onColumnFiltersChange: setColumnFilters,
|
|
@@ -3505,16 +3505,16 @@ function PostTable({
|
|
|
3505
3505
|
});
|
|
3506
3506
|
const [internalData, setInternalData] = useState17(controlledData || []);
|
|
3507
3507
|
const isControlled = controlledData !== void 0;
|
|
3508
|
-
const
|
|
3508
|
+
const data = isControlled ? controlledData : internalData;
|
|
3509
3509
|
const entryRowRef = useRef5(null);
|
|
3510
3510
|
useEffect11(() => {
|
|
3511
|
-
if (defaultExpanded && renderSubComponent && (
|
|
3511
|
+
if (defaultExpanded && renderSubComponent && (data || []).length > 0) {
|
|
3512
3512
|
setExpanded((prev) => {
|
|
3513
3513
|
const isAllExpanded = prev === true;
|
|
3514
3514
|
if (isAllExpanded) return prev;
|
|
3515
3515
|
const newState = typeof prev === "object" ? { ...prev } : {};
|
|
3516
3516
|
let changed = false;
|
|
3517
|
-
|
|
3517
|
+
data.forEach((row, idx) => {
|
|
3518
3518
|
const id = idx.toString();
|
|
3519
3519
|
if (hasSubComponent(row) && newState[id] === void 0) {
|
|
3520
3520
|
newState[id] = true;
|
|
@@ -3524,7 +3524,7 @@ function PostTable({
|
|
|
3524
3524
|
return changed ? newState : prev;
|
|
3525
3525
|
});
|
|
3526
3526
|
}
|
|
3527
|
-
}, [
|
|
3527
|
+
}, [data, defaultExpanded, hasSubComponent, renderSubComponent]);
|
|
3528
3528
|
const focusAndScrollEntryRow = () => {
|
|
3529
3529
|
setTimeout(() => {
|
|
3530
3530
|
if (entryRowRef.current) {
|
|
@@ -3549,7 +3549,7 @@ function PostTable({
|
|
|
3549
3549
|
const [isSavingAsync, setIsSavingAsync] = useState17(false);
|
|
3550
3550
|
const [fieldErrors, setFieldErrors] = useState17({});
|
|
3551
3551
|
const latestStateRef = useRef5({
|
|
3552
|
-
data
|
|
3552
|
+
data,
|
|
3553
3553
|
entryData,
|
|
3554
3554
|
editingIndex,
|
|
3555
3555
|
isSavingAsync,
|
|
@@ -3562,7 +3562,7 @@ function PostTable({
|
|
|
3562
3562
|
});
|
|
3563
3563
|
useEffect11(() => {
|
|
3564
3564
|
latestStateRef.current = {
|
|
3565
|
-
data
|
|
3565
|
+
data,
|
|
3566
3566
|
entryData,
|
|
3567
3567
|
editingIndex,
|
|
3568
3568
|
isSavingAsync,
|
|
@@ -3575,11 +3575,11 @@ function PostTable({
|
|
|
3575
3575
|
};
|
|
3576
3576
|
});
|
|
3577
3577
|
const handleSaveField = useCallback3(async () => {
|
|
3578
|
-
const { data:
|
|
3578
|
+
const { data: data2, entryData: entryData2, editingIndex: editingIndex2, onChange: onChange2 } = latestStateRef.current;
|
|
3579
3579
|
if (Object.keys(entryData2).length === 0) return;
|
|
3580
3580
|
const actionType = editingIndex2 !== null ? "edit" : "add";
|
|
3581
3581
|
const entryToSave = { ...entryData2 };
|
|
3582
|
-
const updated = [...
|
|
3582
|
+
const updated = [...data2];
|
|
3583
3583
|
let entryToPass;
|
|
3584
3584
|
if (actionType === "edit" && editingIndex2 !== null) {
|
|
3585
3585
|
updated[editingIndex2] = {
|
|
@@ -3655,9 +3655,9 @@ function PostTable({
|
|
|
3655
3655
|
}, []);
|
|
3656
3656
|
const handleDelete = useCallback3(
|
|
3657
3657
|
async (index2) => {
|
|
3658
|
-
const { data:
|
|
3659
|
-
const rowToDelete =
|
|
3660
|
-
const updated =
|
|
3658
|
+
const { data: data2, editingIndex: editingIndex2, onChange: onChange2, onDelete: onDelete2 } = latestStateRef.current;
|
|
3659
|
+
const rowToDelete = data2[index2];
|
|
3660
|
+
const updated = data2.filter((_, i) => i !== index2);
|
|
3661
3661
|
if (onChange2) {
|
|
3662
3662
|
setIsSavingAsync(true);
|
|
3663
3663
|
try {
|
|
@@ -3773,7 +3773,7 @@ function PostTable({
|
|
|
3773
3773
|
return finalColumns;
|
|
3774
3774
|
}, [userColumns, actionColumn, index, renderSubComponent, hasSubComponent]);
|
|
3775
3775
|
const table = useReactTable2({
|
|
3776
|
-
data
|
|
3776
|
+
data,
|
|
3777
3777
|
columns,
|
|
3778
3778
|
onSortingChange: setSorting,
|
|
3779
3779
|
onColumnFiltersChange: setColumnFilters,
|
|
@@ -4087,7 +4087,7 @@ import {
|
|
|
4087
4087
|
import { jsx as jsx26, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4088
4088
|
function SimpleTable({
|
|
4089
4089
|
columns: userColumns,
|
|
4090
|
-
data
|
|
4090
|
+
data,
|
|
4091
4091
|
className = "",
|
|
4092
4092
|
renderFooter: componentFooter,
|
|
4093
4093
|
rowPadding = "py-3",
|
|
@@ -4122,7 +4122,7 @@ function SimpleTable({
|
|
|
4122
4122
|
return cols;
|
|
4123
4123
|
}, [userColumns, index, startIndex]);
|
|
4124
4124
|
const table = useReactTable3({
|
|
4125
|
-
data
|
|
4125
|
+
data,
|
|
4126
4126
|
columns,
|
|
4127
4127
|
getCoreRowModel: getCoreRowModel3()
|
|
4128
4128
|
});
|
|
@@ -4162,7 +4162,7 @@ function SimpleTable({
|
|
|
4162
4162
|
},
|
|
4163
4163
|
headerGroup.id
|
|
4164
4164
|
)) }),
|
|
4165
|
-
/* @__PURE__ */ jsx26("tbody", { className: "text-black dark:text-white font-semibold font-sans tabular-nums", children: isLoading &&
|
|
4165
|
+
/* @__PURE__ */ jsx26("tbody", { className: "text-black dark:text-white font-semibold font-sans tabular-nums", children: isLoading && data.length === 0 ? Array.from({ length: skeletonCount }).map((_, i) => /* @__PURE__ */ jsx26(
|
|
4166
4166
|
"tr",
|
|
4167
4167
|
{
|
|
4168
4168
|
className: `border-b ${verticalLines ? "border-black dark:border-white" : "border-gray-100 dark:border-zinc-800/60 last:border-0"}`,
|
|
@@ -4181,7 +4181,7 @@ function SimpleTable({
|
|
|
4181
4181
|
))
|
|
4182
4182
|
},
|
|
4183
4183
|
`skeleton-row-${i}`
|
|
4184
|
-
)) :
|
|
4184
|
+
)) : data.length === 0 && !isLoading ? /* @__PURE__ */ jsx26("tr", { children: /* @__PURE__ */ jsx26(
|
|
4185
4185
|
"td",
|
|
4186
4186
|
{
|
|
4187
4187
|
colSpan: columns.length,
|
|
@@ -5259,7 +5259,7 @@ var useA4StatementView = ({
|
|
|
5259
5259
|
renderFooter: (value) => value.reduce((acc, item) => acc + item.amount, 0)
|
|
5260
5260
|
}
|
|
5261
5261
|
],
|
|
5262
|
-
data
|
|
5262
|
+
data = [],
|
|
5263
5263
|
error = apiError,
|
|
5264
5264
|
info,
|
|
5265
5265
|
index,
|
|
@@ -5282,7 +5282,7 @@ var useA4StatementView = ({
|
|
|
5282
5282
|
const [currentPageIndex, setCurrentPageIndex] = useState21(0);
|
|
5283
5283
|
const [pageSearch, setPageSearch] = useState21("");
|
|
5284
5284
|
const displayColumnsForSearch = columns.filter((col) => !col.hide);
|
|
5285
|
-
const filteredDisplayData =
|
|
5285
|
+
const filteredDisplayData = data.filter((row) => {
|
|
5286
5286
|
if (!globalFilter) return true;
|
|
5287
5287
|
const lowerFilter = globalFilter.toLowerCase();
|
|
5288
5288
|
return displayColumnsForSearch.some((col) => {
|
|
@@ -5425,7 +5425,7 @@ var useA4StatementView = ({
|
|
|
5425
5425
|
isLoading: isActuallyLoading
|
|
5426
5426
|
}
|
|
5427
5427
|
) }) : null;
|
|
5428
|
-
const statusOverlay = isActuallyLoading || error || !
|
|
5428
|
+
const statusOverlay = isActuallyLoading || error || !data || data.length === 0 ? /* @__PURE__ */ jsx35("div", { className: "flex flex-col relative w-full items-center justify-center py-12 min-h-[400px]", children: /* @__PURE__ */ jsxs27("div", { className: "flex flex-col items-center justify-center p-8 bg-gray-50/50 dark:bg-zinc-900/30 rounded-2xl border border-dashed border-gray-300 dark:border-zinc-700 w-full max-w-lg text-center shadow-sm", children: [
|
|
5429
5429
|
isActuallyLoading ? /* @__PURE__ */ jsx35("div", { className: "mb-4", children: /* @__PURE__ */ jsx35(ClassicSpin, {}) }) : error ? /* @__PURE__ */ jsx35("div", { className: "w-14 h-14 bg-red-100 dark:bg-red-500/10 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ jsx35(AlertCircle2, { className: "w-7 h-7 text-red-600 dark:text-red-500" }) }) : /* @__PURE__ */ jsx35("div", { className: "w-14 h-14 bg-gray-200 dark:bg-zinc-800 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ jsx35(FileX, { className: "w-7 h-7 text-gray-500 dark:text-gray-400" }) }),
|
|
5430
5430
|
/* @__PURE__ */ jsx35("h3", { className: "text-lg font-bold text-gray-900 dark:text-white mb-2", children: isActuallyLoading ? "Loading data..." : error ? "Failed to Load Statement" : "No Records Found" }),
|
|
5431
5431
|
/* @__PURE__ */ jsx35("p", { className: "text-sm text-gray-500 dark:text-gray-400 max-w-xs mb-6 leading-relaxed", children: isActuallyLoading ? "Please wait while we prepare your statement." : error ? typeof error === "string" ? error : "An unexpected error occurred while fetching the statement data." : "There are no transactions or records available in this requested statement." }),
|
|
@@ -5675,7 +5675,7 @@ var useA4CategoryView = ({
|
|
|
5675
5675
|
getData();
|
|
5676
5676
|
}, [url, v, JSON.stringify(params), delay]);
|
|
5677
5677
|
const A4CategoryView = ({
|
|
5678
|
-
data
|
|
5678
|
+
data,
|
|
5679
5679
|
groups: incomingGroups,
|
|
5680
5680
|
error = apiError,
|
|
5681
5681
|
info,
|
|
@@ -5698,7 +5698,7 @@ var useA4CategoryView = ({
|
|
|
5698
5698
|
const [pageSearch, setPageSearch] = useState22("");
|
|
5699
5699
|
const groups = incomingGroups ? [...incomingGroups].sort(
|
|
5700
5700
|
(a, b) => a.title.localeCompare(b.title)
|
|
5701
|
-
) :
|
|
5701
|
+
) : data ? [{ title: gridTitle, items: data }] : [];
|
|
5702
5702
|
const flattenedNodes = groups.map((group) => {
|
|
5703
5703
|
const sortedItems = [...group.items].sort(
|
|
5704
5704
|
(a, b) => String(a.name).localeCompare(String(b.name))
|
|
@@ -6043,7 +6043,7 @@ var useTransaction = ({
|
|
|
6043
6043
|
hide: true
|
|
6044
6044
|
}
|
|
6045
6045
|
],
|
|
6046
|
-
data
|
|
6046
|
+
data = [],
|
|
6047
6047
|
error = apiError,
|
|
6048
6048
|
pageRows,
|
|
6049
6049
|
searchPlaceholder = "Search transactions...",
|
|
@@ -6060,7 +6060,7 @@ var useTransaction = ({
|
|
|
6060
6060
|
createTitle = "Add New",
|
|
6061
6061
|
...rest
|
|
6062
6062
|
}) => {
|
|
6063
|
-
const emptyState = !isLoading && (error || !
|
|
6063
|
+
const emptyState = !isLoading && (error || !data || data.length === 0) ? /* @__PURE__ */ jsx37(
|
|
6064
6064
|
"div",
|
|
6065
6065
|
{
|
|
6066
6066
|
className: `flex flex-col relative w-full items-center justify-center py-12 min-h-[300px] ${className}`,
|
|
@@ -6127,7 +6127,7 @@ var useTransaction = ({
|
|
|
6127
6127
|
DataTable,
|
|
6128
6128
|
{
|
|
6129
6129
|
columns,
|
|
6130
|
-
data
|
|
6130
|
+
data,
|
|
6131
6131
|
isLoading,
|
|
6132
6132
|
pageRows,
|
|
6133
6133
|
searchPlaceholder,
|
|
@@ -7833,11 +7833,11 @@ var useAuthStore = create((set, get) => ({
|
|
|
7833
7833
|
isLoggedIn: false,
|
|
7834
7834
|
isFetched: true
|
|
7835
7835
|
}),
|
|
7836
|
-
updateAuth: (
|
|
7837
|
-
auth: state.auth ? { ...state.auth, ...
|
|
7836
|
+
updateAuth: (data) => set((state) => ({
|
|
7837
|
+
auth: state.auth ? { ...state.auth, ...data } : state.auth
|
|
7838
7838
|
})),
|
|
7839
|
-
updateAccount: (
|
|
7840
|
-
account: state.account ? { ...state.account, ...
|
|
7839
|
+
updateAccount: (data) => set((state) => ({
|
|
7840
|
+
account: state.account ? { ...state.account, ...data } : state.account
|
|
7841
7841
|
})),
|
|
7842
7842
|
hasPermission: (key) => !!get().auth?.permissions?.[key]
|
|
7843
7843
|
}));
|
|
@@ -7881,13 +7881,13 @@ var useAuth = () => {
|
|
|
7881
7881
|
setIsLoggedIn,
|
|
7882
7882
|
setIsFetched,
|
|
7883
7883
|
setAuth,
|
|
7884
|
-
login: (
|
|
7885
|
-
if (
|
|
7886
|
-
setAuth(
|
|
7887
|
-
} else if (
|
|
7888
|
-
setAuth(
|
|
7884
|
+
login: (data) => {
|
|
7885
|
+
if (data?.auth && data?.account) {
|
|
7886
|
+
setAuth(data.auth, data.account);
|
|
7887
|
+
} else if (data?.user && data?.account) {
|
|
7888
|
+
setAuth(data.user, data.account);
|
|
7889
7889
|
} else {
|
|
7890
|
-
setAuth(
|
|
7890
|
+
setAuth(data, data?.account || data);
|
|
7891
7891
|
}
|
|
7892
7892
|
},
|
|
7893
7893
|
updateAuth,
|
|
@@ -7961,28 +7961,28 @@ function Accounts({ v, url }) {
|
|
|
7961
7961
|
const [deleteAccount, setDeleteAccount] = useState25(null);
|
|
7962
7962
|
const { isLoading, remove } = useApis_default();
|
|
7963
7963
|
const isEmployee = type === "employee";
|
|
7964
|
-
const { data
|
|
7964
|
+
const { data, TransactionViewComponent, reload } = useTransaction_default({
|
|
7965
7965
|
url: url || `/accounts/get/${type}`,
|
|
7966
7966
|
v,
|
|
7967
7967
|
dateFilter: false
|
|
7968
7968
|
});
|
|
7969
7969
|
const { Modal: Modal2 } = useModal();
|
|
7970
7970
|
const navigate = useNavigate4();
|
|
7971
|
-
const items = (
|
|
7971
|
+
const items = (data2) => [
|
|
7972
7972
|
{
|
|
7973
7973
|
label: `Edit ${type}`,
|
|
7974
7974
|
icon: /* @__PURE__ */ jsx42(FilePenLine, { size: 16 }),
|
|
7975
|
-
onClick: () => navigate(`update?id=${
|
|
7975
|
+
onClick: () => navigate(`update?id=${data2?._id}`)
|
|
7976
7976
|
},
|
|
7977
7977
|
{
|
|
7978
7978
|
label: `Delete ${type}`,
|
|
7979
7979
|
icon: /* @__PURE__ */ jsx42(Trash22, { className: "text-red-500", size: 16 }),
|
|
7980
|
-
onClick: () => setDeleteAccount(
|
|
7980
|
+
onClick: () => setDeleteAccount(data2)
|
|
7981
7981
|
},
|
|
7982
|
-
isEmployee && !
|
|
7982
|
+
isEmployee && !data2?.user && {
|
|
7983
7983
|
label: `Link User`,
|
|
7984
7984
|
icon: /* @__PURE__ */ jsx42(Cable, { size: 16 }),
|
|
7985
|
-
onClick: () => navigate(`link-user?id=${
|
|
7985
|
+
onClick: () => navigate(`link-user?id=${data2?._id}`)
|
|
7986
7986
|
}
|
|
7987
7987
|
].filter(Boolean);
|
|
7988
7988
|
const columns = [
|
|
@@ -8030,12 +8030,12 @@ function Accounts({ v, url }) {
|
|
|
8030
8030
|
accessorKey: "actions",
|
|
8031
8031
|
header: "Actions",
|
|
8032
8032
|
cell: ({ row }) => {
|
|
8033
|
-
const
|
|
8033
|
+
const data2 = row.original;
|
|
8034
8034
|
return /* @__PURE__ */ jsx42(
|
|
8035
8035
|
Dropdown,
|
|
8036
8036
|
{
|
|
8037
8037
|
className: "cursor-pointer w-[150px]",
|
|
8038
|
-
items: items(
|
|
8038
|
+
items: items(data2),
|
|
8039
8039
|
triggerMode: "hover",
|
|
8040
8040
|
children: /* @__PURE__ */ jsx42(EllipsisVertical, {})
|
|
8041
8041
|
}
|
|
@@ -8043,7 +8043,7 @@ function Accounts({ v, url }) {
|
|
|
8043
8043
|
}
|
|
8044
8044
|
}
|
|
8045
8045
|
].filter(Boolean);
|
|
8046
|
-
const accounts =
|
|
8046
|
+
const accounts = data?.data || [];
|
|
8047
8047
|
const onDelete = async (id) => {
|
|
8048
8048
|
try {
|
|
8049
8049
|
await remove({ url: `/accounts/delete/${id}` });
|
|
@@ -8088,2504 +8088,114 @@ function Accounts({ v, url }) {
|
|
|
8088
8088
|
}
|
|
8089
8089
|
var Accounts_default = Accounts;
|
|
8090
8090
|
|
|
8091
|
-
//
|
|
8092
|
-
import
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
import * as React52 from "react";
|
|
8101
|
-
import * as React102 from "react";
|
|
8102
|
-
import * as React112 from "react";
|
|
8103
|
-
function invariant(value, message13) {
|
|
8104
|
-
if (value === false || value === null || typeof value === "undefined") {
|
|
8105
|
-
throw new Error(message13);
|
|
8106
|
-
}
|
|
8107
|
-
}
|
|
8108
|
-
function warning3(cond, message13) {
|
|
8109
|
-
if (!cond) {
|
|
8110
|
-
if (typeof console !== "undefined") console.warn(message13);
|
|
8111
|
-
try {
|
|
8112
|
-
throw new Error(message13);
|
|
8113
|
-
} catch (e) {
|
|
8114
|
-
}
|
|
8115
|
-
}
|
|
8116
|
-
}
|
|
8117
|
-
function createPath({
|
|
8118
|
-
pathname = "/",
|
|
8119
|
-
search = "",
|
|
8120
|
-
hash = ""
|
|
8121
|
-
}) {
|
|
8122
|
-
if (search && search !== "?")
|
|
8123
|
-
pathname += search.charAt(0) === "?" ? search : "?" + search;
|
|
8124
|
-
if (hash && hash !== "#")
|
|
8125
|
-
pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
|
|
8126
|
-
return pathname;
|
|
8127
|
-
}
|
|
8128
|
-
function parsePath(path) {
|
|
8129
|
-
let parsedPath = {};
|
|
8130
|
-
if (path) {
|
|
8131
|
-
let hashIndex = path.indexOf("#");
|
|
8132
|
-
if (hashIndex >= 0) {
|
|
8133
|
-
parsedPath.hash = path.substring(hashIndex);
|
|
8134
|
-
path = path.substring(0, hashIndex);
|
|
8135
|
-
}
|
|
8136
|
-
let searchIndex = path.indexOf("?");
|
|
8137
|
-
if (searchIndex >= 0) {
|
|
8138
|
-
parsedPath.search = path.substring(searchIndex);
|
|
8139
|
-
path = path.substring(0, searchIndex);
|
|
8140
|
-
}
|
|
8141
|
-
if (path) {
|
|
8142
|
-
parsedPath.pathname = path;
|
|
8143
|
-
}
|
|
8144
|
-
}
|
|
8145
|
-
return parsedPath;
|
|
8146
|
-
}
|
|
8147
|
-
var _map;
|
|
8148
|
-
_map = /* @__PURE__ */ new WeakMap();
|
|
8149
|
-
function matchRoutes(routes, locationArg, basename = "/") {
|
|
8150
|
-
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
8151
|
-
}
|
|
8152
|
-
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
8153
|
-
let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
8154
|
-
let pathname = stripBasename(location.pathname || "/", basename);
|
|
8155
|
-
if (pathname == null) {
|
|
8156
|
-
return null;
|
|
8157
|
-
}
|
|
8158
|
-
let branches = flattenRoutes(routes);
|
|
8159
|
-
rankRouteBranches(branches);
|
|
8160
|
-
let matches = null;
|
|
8161
|
-
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
8162
|
-
let decoded = decodePath(pathname);
|
|
8163
|
-
matches = matchRouteBranch(
|
|
8164
|
-
branches[i],
|
|
8165
|
-
decoded,
|
|
8166
|
-
allowPartial
|
|
8167
|
-
);
|
|
8168
|
-
}
|
|
8169
|
-
return matches;
|
|
8170
|
-
}
|
|
8171
|
-
function convertRouteMatchToUiMatch(match, loaderData) {
|
|
8172
|
-
let { route, pathname, params } = match;
|
|
8173
|
-
return {
|
|
8174
|
-
id: route.id,
|
|
8175
|
-
pathname,
|
|
8176
|
-
params,
|
|
8177
|
-
data: loaderData[route.id],
|
|
8178
|
-
loaderData: loaderData[route.id],
|
|
8179
|
-
handle: route.handle
|
|
8180
|
-
};
|
|
8181
|
-
}
|
|
8182
|
-
function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
|
|
8183
|
-
let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
|
|
8184
|
-
let meta = {
|
|
8185
|
-
relativePath: relativePath === void 0 ? route.path || "" : relativePath,
|
|
8186
|
-
caseSensitive: route.caseSensitive === true,
|
|
8187
|
-
childrenIndex: index,
|
|
8188
|
-
route
|
|
8189
|
-
};
|
|
8190
|
-
if (meta.relativePath.startsWith("/")) {
|
|
8191
|
-
if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
|
|
8192
|
-
return;
|
|
8193
|
-
}
|
|
8194
|
-
invariant(
|
|
8195
|
-
meta.relativePath.startsWith(parentPath),
|
|
8196
|
-
`Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
|
|
8197
|
-
);
|
|
8198
|
-
meta.relativePath = meta.relativePath.slice(parentPath.length);
|
|
8199
|
-
}
|
|
8200
|
-
let path = joinPaths([parentPath, meta.relativePath]);
|
|
8201
|
-
let routesMeta = parentsMeta.concat(meta);
|
|
8202
|
-
if (route.children && route.children.length > 0) {
|
|
8203
|
-
invariant(
|
|
8204
|
-
// Our types know better, but runtime JS may not!
|
|
8205
|
-
// @ts-expect-error
|
|
8206
|
-
route.index !== true,
|
|
8207
|
-
`Index routes must not have child routes. Please remove all child routes from route path "${path}".`
|
|
8208
|
-
);
|
|
8209
|
-
flattenRoutes(
|
|
8210
|
-
route.children,
|
|
8211
|
-
branches,
|
|
8212
|
-
routesMeta,
|
|
8213
|
-
path,
|
|
8214
|
-
hasParentOptionalSegments
|
|
8215
|
-
);
|
|
8216
|
-
}
|
|
8217
|
-
if (route.path == null && !route.index) {
|
|
8218
|
-
return;
|
|
8219
|
-
}
|
|
8220
|
-
branches.push({
|
|
8221
|
-
path,
|
|
8222
|
-
score: computeScore(path, route.index),
|
|
8223
|
-
routesMeta
|
|
8224
|
-
});
|
|
8091
|
+
// src/hooks/useApp.tsx
|
|
8092
|
+
import { useNavigate as useNavigate5, useParams as useParams2, useSearchParams } from "react-router-dom";
|
|
8093
|
+
var useApp = () => {
|
|
8094
|
+
const [searchParams] = useSearchParams();
|
|
8095
|
+
const navigate = useNavigate5();
|
|
8096
|
+
const getParams = (key) => {
|
|
8097
|
+
const params = useParams2();
|
|
8098
|
+
if (key) return params[key];
|
|
8099
|
+
return params;
|
|
8225
8100
|
};
|
|
8226
|
-
|
|
8227
|
-
if (
|
|
8228
|
-
|
|
8229
|
-
} else {
|
|
8230
|
-
for (let exploded of explodeOptionalSegments(route.path)) {
|
|
8231
|
-
flattenRoute(route, index, true, exploded);
|
|
8232
|
-
}
|
|
8233
|
-
}
|
|
8234
|
-
});
|
|
8235
|
-
return branches;
|
|
8236
|
-
}
|
|
8237
|
-
function explodeOptionalSegments(path) {
|
|
8238
|
-
let segments = path.split("/");
|
|
8239
|
-
if (segments.length === 0) return [];
|
|
8240
|
-
let [first, ...rest] = segments;
|
|
8241
|
-
let isOptional = first.endsWith("?");
|
|
8242
|
-
let required = first.replace(/\?$/, "");
|
|
8243
|
-
if (rest.length === 0) {
|
|
8244
|
-
return isOptional ? [required, ""] : [required];
|
|
8245
|
-
}
|
|
8246
|
-
let restExploded = explodeOptionalSegments(rest.join("/"));
|
|
8247
|
-
let result = [];
|
|
8248
|
-
result.push(
|
|
8249
|
-
...restExploded.map(
|
|
8250
|
-
(subpath) => subpath === "" ? required : [required, subpath].join("/")
|
|
8251
|
-
)
|
|
8252
|
-
);
|
|
8253
|
-
if (isOptional) {
|
|
8254
|
-
result.push(...restExploded);
|
|
8255
|
-
}
|
|
8256
|
-
return result.map(
|
|
8257
|
-
(exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded
|
|
8258
|
-
);
|
|
8259
|
-
}
|
|
8260
|
-
function rankRouteBranches(branches) {
|
|
8261
|
-
branches.sort(
|
|
8262
|
-
(a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(
|
|
8263
|
-
a.routesMeta.map((meta) => meta.childrenIndex),
|
|
8264
|
-
b.routesMeta.map((meta) => meta.childrenIndex)
|
|
8265
|
-
)
|
|
8266
|
-
);
|
|
8267
|
-
}
|
|
8268
|
-
var paramRe = /^:[\w-]+$/;
|
|
8269
|
-
var dynamicSegmentValue = 3;
|
|
8270
|
-
var indexRouteValue = 2;
|
|
8271
|
-
var emptySegmentValue = 1;
|
|
8272
|
-
var staticSegmentValue = 10;
|
|
8273
|
-
var splatPenalty = -2;
|
|
8274
|
-
var isSplat = (s) => s === "*";
|
|
8275
|
-
function computeScore(path, index) {
|
|
8276
|
-
let segments = path.split("/");
|
|
8277
|
-
let initialScore = segments.length;
|
|
8278
|
-
if (segments.some(isSplat)) {
|
|
8279
|
-
initialScore += splatPenalty;
|
|
8280
|
-
}
|
|
8281
|
-
if (index) {
|
|
8282
|
-
initialScore += indexRouteValue;
|
|
8283
|
-
}
|
|
8284
|
-
return segments.filter((s) => !isSplat(s)).reduce(
|
|
8285
|
-
(score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
|
|
8286
|
-
initialScore
|
|
8287
|
-
);
|
|
8288
|
-
}
|
|
8289
|
-
function compareIndexes(a, b) {
|
|
8290
|
-
let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
|
|
8291
|
-
return siblings ? (
|
|
8292
|
-
// If two routes are siblings, we should try to match the earlier sibling
|
|
8293
|
-
// first. This allows people to have fine-grained control over the matching
|
|
8294
|
-
// behavior by simply putting routes with identical paths in the order they
|
|
8295
|
-
// want them tried.
|
|
8296
|
-
a[a.length - 1] - b[b.length - 1]
|
|
8297
|
-
) : (
|
|
8298
|
-
// Otherwise, it doesn't really make sense to rank non-siblings by index,
|
|
8299
|
-
// so they sort equally.
|
|
8300
|
-
0
|
|
8301
|
-
);
|
|
8302
|
-
}
|
|
8303
|
-
function matchRouteBranch(branch, pathname, allowPartial = false) {
|
|
8304
|
-
let { routesMeta } = branch;
|
|
8305
|
-
let matchedParams = {};
|
|
8306
|
-
let matchedPathname = "/";
|
|
8307
|
-
let matches = [];
|
|
8308
|
-
for (let i = 0; i < routesMeta.length; ++i) {
|
|
8309
|
-
let meta = routesMeta[i];
|
|
8310
|
-
let end = i === routesMeta.length - 1;
|
|
8311
|
-
let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
|
|
8312
|
-
let match = matchPath(
|
|
8313
|
-
{ path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
|
|
8314
|
-
remainingPathname
|
|
8315
|
-
);
|
|
8316
|
-
let route = meta.route;
|
|
8317
|
-
if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
|
|
8318
|
-
match = matchPath(
|
|
8319
|
-
{
|
|
8320
|
-
path: meta.relativePath,
|
|
8321
|
-
caseSensitive: meta.caseSensitive,
|
|
8322
|
-
end: false
|
|
8323
|
-
},
|
|
8324
|
-
remainingPathname
|
|
8325
|
-
);
|
|
8326
|
-
}
|
|
8327
|
-
if (!match) {
|
|
8328
|
-
return null;
|
|
8329
|
-
}
|
|
8330
|
-
Object.assign(matchedParams, match.params);
|
|
8331
|
-
matches.push({
|
|
8332
|
-
// TODO: Can this as be avoided?
|
|
8333
|
-
params: matchedParams,
|
|
8334
|
-
pathname: joinPaths([matchedPathname, match.pathname]),
|
|
8335
|
-
pathnameBase: normalizePathname(
|
|
8336
|
-
joinPaths([matchedPathname, match.pathnameBase])
|
|
8337
|
-
),
|
|
8338
|
-
route
|
|
8339
|
-
});
|
|
8340
|
-
if (match.pathnameBase !== "/") {
|
|
8341
|
-
matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
|
|
8342
|
-
}
|
|
8343
|
-
}
|
|
8344
|
-
return matches;
|
|
8345
|
-
}
|
|
8346
|
-
function matchPath(pattern, pathname) {
|
|
8347
|
-
if (typeof pattern === "string") {
|
|
8348
|
-
pattern = { path: pattern, caseSensitive: false, end: true };
|
|
8349
|
-
}
|
|
8350
|
-
let [matcher, compiledParams] = compilePath(
|
|
8351
|
-
pattern.path,
|
|
8352
|
-
pattern.caseSensitive,
|
|
8353
|
-
pattern.end
|
|
8354
|
-
);
|
|
8355
|
-
let match = pathname.match(matcher);
|
|
8356
|
-
if (!match) return null;
|
|
8357
|
-
let matchedPathname = match[0];
|
|
8358
|
-
let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
|
|
8359
|
-
let captureGroups = match.slice(1);
|
|
8360
|
-
let params = compiledParams.reduce(
|
|
8361
|
-
(memo2, { paramName, isOptional }, index) => {
|
|
8362
|
-
if (paramName === "*") {
|
|
8363
|
-
let splatValue = captureGroups[index] || "";
|
|
8364
|
-
pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
|
|
8365
|
-
}
|
|
8366
|
-
const value = captureGroups[index];
|
|
8367
|
-
if (isOptional && !value) {
|
|
8368
|
-
memo2[paramName] = void 0;
|
|
8369
|
-
} else {
|
|
8370
|
-
memo2[paramName] = (value || "").replace(/%2F/g, "/");
|
|
8371
|
-
}
|
|
8372
|
-
return memo2;
|
|
8373
|
-
},
|
|
8374
|
-
{}
|
|
8375
|
-
);
|
|
8376
|
-
return {
|
|
8377
|
-
params,
|
|
8378
|
-
pathname: matchedPathname,
|
|
8379
|
-
pathnameBase,
|
|
8380
|
-
pattern
|
|
8101
|
+
const getQuery = (key) => {
|
|
8102
|
+
if (key) return searchParams.get(key);
|
|
8103
|
+
return Object.fromEntries(searchParams.entries());
|
|
8381
8104
|
};
|
|
8382
|
-
}
|
|
8383
|
-
function compilePath(path, caseSensitive = false, end = true) {
|
|
8384
|
-
warning3(
|
|
8385
|
-
path === "*" || !path.endsWith("*") || path.endsWith("/*"),
|
|
8386
|
-
`Route path "${path}" will be treated as if it were "${path.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${path.replace(/\*$/, "/*")}".`
|
|
8387
|
-
);
|
|
8388
|
-
let params = [];
|
|
8389
|
-
let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(
|
|
8390
|
-
/\/:([\w-]+)(\?)?/g,
|
|
8391
|
-
(match, paramName, isOptional, index, str) => {
|
|
8392
|
-
params.push({ paramName, isOptional: isOptional != null });
|
|
8393
|
-
if (isOptional) {
|
|
8394
|
-
let nextChar = str.charAt(index + match.length);
|
|
8395
|
-
if (nextChar && nextChar !== "/") {
|
|
8396
|
-
return "/([^\\/]*)";
|
|
8397
|
-
}
|
|
8398
|
-
return "(?:/([^\\/]*))?";
|
|
8399
|
-
}
|
|
8400
|
-
return "/([^\\/]+)";
|
|
8401
|
-
}
|
|
8402
|
-
).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
|
|
8403
|
-
if (path.endsWith("*")) {
|
|
8404
|
-
params.push({ paramName: "*" });
|
|
8405
|
-
regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
|
|
8406
|
-
} else if (end) {
|
|
8407
|
-
regexpSource += "\\/*$";
|
|
8408
|
-
} else if (path !== "" && path !== "/") {
|
|
8409
|
-
regexpSource += "(?:(?=\\/|$))";
|
|
8410
|
-
} else {
|
|
8411
|
-
}
|
|
8412
|
-
let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
|
|
8413
|
-
return [matcher, params];
|
|
8414
|
-
}
|
|
8415
|
-
function decodePath(value) {
|
|
8416
|
-
try {
|
|
8417
|
-
return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
|
|
8418
|
-
} catch (error) {
|
|
8419
|
-
warning3(
|
|
8420
|
-
false,
|
|
8421
|
-
`The URL path "${value}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`
|
|
8422
|
-
);
|
|
8423
|
-
return value;
|
|
8424
|
-
}
|
|
8425
|
-
}
|
|
8426
|
-
function stripBasename(pathname, basename) {
|
|
8427
|
-
if (basename === "/") return pathname;
|
|
8428
|
-
if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
|
|
8429
|
-
return null;
|
|
8430
|
-
}
|
|
8431
|
-
let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
|
|
8432
|
-
let nextChar = pathname.charAt(startIndex);
|
|
8433
|
-
if (nextChar && nextChar !== "/") {
|
|
8434
|
-
return null;
|
|
8435
|
-
}
|
|
8436
|
-
return pathname.slice(startIndex) || "/";
|
|
8437
|
-
}
|
|
8438
|
-
var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
8439
|
-
function resolvePath(to, fromPathname = "/") {
|
|
8440
|
-
let {
|
|
8441
|
-
pathname: toPathname,
|
|
8442
|
-
search = "",
|
|
8443
|
-
hash = ""
|
|
8444
|
-
} = typeof to === "string" ? parsePath(to) : to;
|
|
8445
|
-
let pathname;
|
|
8446
|
-
if (toPathname) {
|
|
8447
|
-
toPathname = toPathname.replace(/\/\/+/g, "/");
|
|
8448
|
-
if (toPathname.startsWith("/")) {
|
|
8449
|
-
pathname = resolvePathname(toPathname.substring(1), "/");
|
|
8450
|
-
} else {
|
|
8451
|
-
pathname = resolvePathname(toPathname, fromPathname);
|
|
8452
|
-
}
|
|
8453
|
-
} else {
|
|
8454
|
-
pathname = fromPathname;
|
|
8455
|
-
}
|
|
8456
8105
|
return {
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8106
|
+
navigate,
|
|
8107
|
+
getQuery,
|
|
8108
|
+
getParams
|
|
8460
8109
|
};
|
|
8461
|
-
}
|
|
8462
|
-
function resolvePathname(relativePath, fromPathname) {
|
|
8463
|
-
let segments = fromPathname.replace(/\/+$/, "").split("/");
|
|
8464
|
-
let relativeSegments = relativePath.split("/");
|
|
8465
|
-
relativeSegments.forEach((segment) => {
|
|
8466
|
-
if (segment === "..") {
|
|
8467
|
-
if (segments.length > 1) segments.pop();
|
|
8468
|
-
} else if (segment !== ".") {
|
|
8469
|
-
segments.push(segment);
|
|
8470
|
-
}
|
|
8471
|
-
});
|
|
8472
|
-
return segments.length > 1 ? segments.join("/") : "/";
|
|
8473
|
-
}
|
|
8474
|
-
function getInvalidPathError(char, field, dest, path) {
|
|
8475
|
-
return `Cannot include a '${char}' character in a manually specified \`to.${field}\` field [${JSON.stringify(
|
|
8476
|
-
path
|
|
8477
|
-
)}]. 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.`;
|
|
8478
|
-
}
|
|
8479
|
-
function getPathContributingMatches(matches) {
|
|
8480
|
-
return matches.filter(
|
|
8481
|
-
(match, index) => index === 0 || match.route.path && match.route.path.length > 0
|
|
8482
|
-
);
|
|
8483
|
-
}
|
|
8484
|
-
function getResolveToMatches(matches) {
|
|
8485
|
-
let pathMatches = getPathContributingMatches(matches);
|
|
8486
|
-
return pathMatches.map(
|
|
8487
|
-
(match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase
|
|
8488
|
-
);
|
|
8489
|
-
}
|
|
8490
|
-
function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = false) {
|
|
8491
|
-
let to;
|
|
8492
|
-
if (typeof toArg === "string") {
|
|
8493
|
-
to = parsePath(toArg);
|
|
8494
|
-
} else {
|
|
8495
|
-
to = { ...toArg };
|
|
8496
|
-
invariant(
|
|
8497
|
-
!to.pathname || !to.pathname.includes("?"),
|
|
8498
|
-
getInvalidPathError("?", "pathname", "search", to)
|
|
8499
|
-
);
|
|
8500
|
-
invariant(
|
|
8501
|
-
!to.pathname || !to.pathname.includes("#"),
|
|
8502
|
-
getInvalidPathError("#", "pathname", "hash", to)
|
|
8503
|
-
);
|
|
8504
|
-
invariant(
|
|
8505
|
-
!to.search || !to.search.includes("#"),
|
|
8506
|
-
getInvalidPathError("#", "search", "hash", to)
|
|
8507
|
-
);
|
|
8508
|
-
}
|
|
8509
|
-
let isEmptyPath = toArg === "" || to.pathname === "";
|
|
8510
|
-
let toPathname = isEmptyPath ? "/" : to.pathname;
|
|
8511
|
-
let from;
|
|
8512
|
-
if (toPathname == null) {
|
|
8513
|
-
from = locationPathname;
|
|
8514
|
-
} else {
|
|
8515
|
-
let routePathnameIndex = routePathnames.length - 1;
|
|
8516
|
-
if (!isPathRelative && toPathname.startsWith("..")) {
|
|
8517
|
-
let toSegments = toPathname.split("/");
|
|
8518
|
-
while (toSegments[0] === "..") {
|
|
8519
|
-
toSegments.shift();
|
|
8520
|
-
routePathnameIndex -= 1;
|
|
8521
|
-
}
|
|
8522
|
-
to.pathname = toSegments.join("/");
|
|
8523
|
-
}
|
|
8524
|
-
from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
|
|
8525
|
-
}
|
|
8526
|
-
let path = resolvePath(to, from);
|
|
8527
|
-
let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
|
|
8528
|
-
let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
|
|
8529
|
-
if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
|
|
8530
|
-
path.pathname += "/";
|
|
8531
|
-
}
|
|
8532
|
-
return path;
|
|
8533
|
-
}
|
|
8534
|
-
var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
|
|
8535
|
-
var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
|
|
8536
|
-
var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
|
|
8537
|
-
var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
|
8538
|
-
var ErrorResponseImpl = class {
|
|
8539
|
-
constructor(status, statusText, data2, internal = false) {
|
|
8540
|
-
this.status = status;
|
|
8541
|
-
this.statusText = statusText || "";
|
|
8542
|
-
this.internal = internal;
|
|
8543
|
-
if (data2 instanceof Error) {
|
|
8544
|
-
this.data = data2.toString();
|
|
8545
|
-
this.error = data2;
|
|
8546
|
-
} else {
|
|
8547
|
-
this.data = data2;
|
|
8548
|
-
}
|
|
8549
|
-
}
|
|
8550
8110
|
};
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
}
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8111
|
+
var useApp_default = useApp;
|
|
8112
|
+
|
|
8113
|
+
// src/utils/Enums.ts
|
|
8114
|
+
var Enums = {
|
|
8115
|
+
roles: ["admin", "staff"],
|
|
8116
|
+
sex: ["male", "female"],
|
|
8117
|
+
accountTypes: ["employee", "supplier", "customer", "investor"],
|
|
8118
|
+
verificationTypes: ["email_verification", "password_reset"],
|
|
8119
|
+
auditActions: ["create", "update", "delete", "login", "logout"]
|
|
8120
|
+
};
|
|
8121
|
+
var Enums_default = Enums;
|
|
8122
|
+
|
|
8123
|
+
// src/components/accounts/schema.tsx
|
|
8124
|
+
import { z as z2 } from "zod";
|
|
8125
|
+
var createAccountSchema = z2.object({
|
|
8126
|
+
name: z2.string().min(2, { message: "Name must be at least 2 characters" }),
|
|
8127
|
+
email: z2.string().optional().refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
|
|
8128
|
+
message: "Please enter a valid email address"
|
|
8129
|
+
}).transform((val) => val?.toLowerCase()),
|
|
8130
|
+
phoneNumber: z2.string().optional(),
|
|
8131
|
+
sex: z2.enum(Enums_default.sex),
|
|
8132
|
+
owner: z2.string().min(1, { message: "Owner is required" }),
|
|
8133
|
+
host: z2.string().min(1, { message: "Host is required" })
|
|
8134
|
+
});
|
|
8135
|
+
|
|
8136
|
+
// src/components/accounts/AccountForm.tsx
|
|
8137
|
+
import { useForm as useForm2 } from "react-hook-form";
|
|
8138
|
+
import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
|
|
8139
|
+
import { message as message5 } from "antd";
|
|
8140
|
+
import { useEffect as useEffect18 } from "react";
|
|
8141
|
+
import { jsx as jsx43, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
8142
|
+
function AccountForm() {
|
|
8143
|
+
const { getQuery, getParams, navigate } = useApp_default();
|
|
8144
|
+
const id = getQuery("id");
|
|
8145
|
+
const type = getParams("type");
|
|
8146
|
+
const isEdit = !!id;
|
|
8147
|
+
const { post, put, isLoading } = useApis_default();
|
|
8148
|
+
const { isLoading: isLoadingGet, get } = useApis_default();
|
|
8149
|
+
const methods = useForm2({
|
|
8150
|
+
resolver: zodResolver2(createAccountSchema),
|
|
8151
|
+
defaultValues: {
|
|
8152
|
+
name: "",
|
|
8153
|
+
email: "",
|
|
8154
|
+
phoneNumber: "",
|
|
8155
|
+
sex: "male",
|
|
8156
|
+
owner: "",
|
|
8157
|
+
host: ""
|
|
8158
|
+
},
|
|
8159
|
+
shouldUnregister: false
|
|
8160
|
+
});
|
|
8161
|
+
const { handleSubmit } = methods;
|
|
8162
|
+
const onSubmit = async (data) => {
|
|
8570
8163
|
try {
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8164
|
+
const payload = {
|
|
8165
|
+
...data,
|
|
8166
|
+
type
|
|
8167
|
+
};
|
|
8168
|
+
if (isEdit) {
|
|
8169
|
+
await put({
|
|
8170
|
+
url: `/accounts/update/${id}`,
|
|
8171
|
+
body: payload
|
|
8172
|
+
});
|
|
8576
8173
|
} else {
|
|
8577
|
-
|
|
8174
|
+
await post({
|
|
8175
|
+
url: "/accounts/create",
|
|
8176
|
+
body: payload
|
|
8177
|
+
});
|
|
8578
8178
|
}
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
);
|
|
8179
|
+
message5.success(`${type} ${isEdit ? "updated" : "created"} successfully`);
|
|
8180
|
+
navigate(-1);
|
|
8181
|
+
} catch (error) {
|
|
8182
|
+
message5.error(error?.message || "Something went wrong");
|
|
8584
8183
|
}
|
|
8585
|
-
}
|
|
8586
|
-
return {
|
|
8587
|
-
absoluteURL,
|
|
8588
|
-
isExternal,
|
|
8589
|
-
to
|
|
8590
8184
|
};
|
|
8591
|
-
|
|
8592
|
-
var objectProtoNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
8593
|
-
var validMutationMethodsArr = [
|
|
8594
|
-
"POST",
|
|
8595
|
-
"PUT",
|
|
8596
|
-
"PATCH",
|
|
8597
|
-
"DELETE"
|
|
8598
|
-
];
|
|
8599
|
-
var validMutationMethods = new Set(
|
|
8600
|
-
validMutationMethodsArr
|
|
8601
|
-
);
|
|
8602
|
-
var validRequestMethodsArr = [
|
|
8603
|
-
"GET",
|
|
8604
|
-
...validMutationMethodsArr
|
|
8605
|
-
];
|
|
8606
|
-
var validRequestMethods = new Set(validRequestMethodsArr);
|
|
8607
|
-
var DataRouterContext = React24.createContext(null);
|
|
8608
|
-
DataRouterContext.displayName = "DataRouter";
|
|
8609
|
-
var DataRouterStateContext = React24.createContext(null);
|
|
8610
|
-
DataRouterStateContext.displayName = "DataRouterState";
|
|
8611
|
-
var RSCRouterContext = React24.createContext(false);
|
|
8612
|
-
var ViewTransitionContext = React24.createContext({
|
|
8613
|
-
isTransitioning: false
|
|
8614
|
-
});
|
|
8615
|
-
ViewTransitionContext.displayName = "ViewTransition";
|
|
8616
|
-
var FetchersContext = React24.createContext(
|
|
8617
|
-
/* @__PURE__ */ new Map()
|
|
8618
|
-
);
|
|
8619
|
-
FetchersContext.displayName = "Fetchers";
|
|
8620
|
-
var AwaitContext = React24.createContext(null);
|
|
8621
|
-
AwaitContext.displayName = "Await";
|
|
8622
|
-
var NavigationContext = React24.createContext(
|
|
8623
|
-
null
|
|
8624
|
-
);
|
|
8625
|
-
NavigationContext.displayName = "Navigation";
|
|
8626
|
-
var LocationContext = React24.createContext(
|
|
8627
|
-
null
|
|
8628
|
-
);
|
|
8629
|
-
LocationContext.displayName = "Location";
|
|
8630
|
-
var RouteContext = React24.createContext({
|
|
8631
|
-
outlet: null,
|
|
8632
|
-
matches: [],
|
|
8633
|
-
isDataRoute: false
|
|
8634
|
-
});
|
|
8635
|
-
RouteContext.displayName = "Route";
|
|
8636
|
-
var RouteErrorContext = React24.createContext(null);
|
|
8637
|
-
RouteErrorContext.displayName = "RouteError";
|
|
8638
|
-
var ENABLE_DEV_WARNINGS = true;
|
|
8639
|
-
var ERROR_DIGEST_BASE = "REACT_ROUTER_ERROR";
|
|
8640
|
-
var ERROR_DIGEST_REDIRECT = "REDIRECT";
|
|
8641
|
-
var ERROR_DIGEST_ROUTE_ERROR_RESPONSE = "ROUTE_ERROR_RESPONSE";
|
|
8642
|
-
function decodeRedirectErrorDigest(digest) {
|
|
8643
|
-
if (digest.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:{`)) {
|
|
8185
|
+
const fetches = async () => {
|
|
8644
8186
|
try {
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8187
|
+
const res = await get({
|
|
8188
|
+
url: `/accounts/get/${type}?id=${id}`
|
|
8189
|
+
});
|
|
8190
|
+
const data = res.data;
|
|
8191
|
+
methods.reset(data);
|
|
8192
|
+
} catch (error) {
|
|
8193
|
+
message5.error(error?.message || "Something went wrong");
|
|
8650
8194
|
}
|
|
8651
|
-
}
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:{`
|
|
8656
|
-
)) {
|
|
8657
|
-
try {
|
|
8658
|
-
let parsed = JSON.parse(digest.slice(40));
|
|
8659
|
-
if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string") {
|
|
8660
|
-
return new ErrorResponseImpl(
|
|
8661
|
-
parsed.status,
|
|
8662
|
-
parsed.statusText,
|
|
8663
|
-
parsed.data
|
|
8664
|
-
);
|
|
8665
|
-
}
|
|
8666
|
-
} catch {
|
|
8667
|
-
}
|
|
8668
|
-
}
|
|
8669
|
-
}
|
|
8670
|
-
function useHref(to, { relative } = {}) {
|
|
8671
|
-
invariant(
|
|
8672
|
-
useInRouterContext(),
|
|
8673
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
|
8674
|
-
// router loaded. We can help them understand how to avoid that.
|
|
8675
|
-
`useHref() may be used only in the context of a <Router> component.`
|
|
8676
|
-
);
|
|
8677
|
-
let { basename, navigator: navigator2 } = React25.useContext(NavigationContext);
|
|
8678
|
-
let { hash, pathname, search } = useResolvedPath(to, { relative });
|
|
8679
|
-
let joinedPathname = pathname;
|
|
8680
|
-
if (basename !== "/") {
|
|
8681
|
-
joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
|
|
8682
|
-
}
|
|
8683
|
-
return navigator2.createHref({ pathname: joinedPathname, search, hash });
|
|
8684
|
-
}
|
|
8685
|
-
function useInRouterContext() {
|
|
8686
|
-
return React25.useContext(LocationContext) != null;
|
|
8687
|
-
}
|
|
8688
|
-
function useLocation3() {
|
|
8689
|
-
invariant(
|
|
8690
|
-
useInRouterContext(),
|
|
8691
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
|
8692
|
-
// router loaded. We can help them understand how to avoid that.
|
|
8693
|
-
`useLocation() may be used only in the context of a <Router> component.`
|
|
8694
|
-
);
|
|
8695
|
-
return React25.useContext(LocationContext).location;
|
|
8696
|
-
}
|
|
8697
|
-
var navigateEffectWarning = `You should call navigate() in a React.useEffect(), not when your component is first rendered.`;
|
|
8698
|
-
function useIsomorphicLayoutEffect(cb) {
|
|
8699
|
-
let isStatic = React25.useContext(NavigationContext).static;
|
|
8700
|
-
if (!isStatic) {
|
|
8701
|
-
React25.useLayoutEffect(cb);
|
|
8702
|
-
}
|
|
8703
|
-
}
|
|
8704
|
-
function useNavigate5() {
|
|
8705
|
-
let { isDataRoute } = React25.useContext(RouteContext);
|
|
8706
|
-
return isDataRoute ? useNavigateStable() : useNavigateUnstable();
|
|
8707
|
-
}
|
|
8708
|
-
function useNavigateUnstable() {
|
|
8709
|
-
invariant(
|
|
8710
|
-
useInRouterContext(),
|
|
8711
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
|
8712
|
-
// router loaded. We can help them understand how to avoid that.
|
|
8713
|
-
`useNavigate() may be used only in the context of a <Router> component.`
|
|
8714
|
-
);
|
|
8715
|
-
let dataRouterContext = React25.useContext(DataRouterContext);
|
|
8716
|
-
let { basename, navigator: navigator2 } = React25.useContext(NavigationContext);
|
|
8717
|
-
let { matches } = React25.useContext(RouteContext);
|
|
8718
|
-
let { pathname: locationPathname } = useLocation3();
|
|
8719
|
-
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
|
8720
|
-
let activeRef = React25.useRef(false);
|
|
8721
|
-
useIsomorphicLayoutEffect(() => {
|
|
8722
|
-
activeRef.current = true;
|
|
8723
|
-
});
|
|
8724
|
-
let navigate = React25.useCallback(
|
|
8725
|
-
(to, options = {}) => {
|
|
8726
|
-
warning3(activeRef.current, navigateEffectWarning);
|
|
8727
|
-
if (!activeRef.current) return;
|
|
8728
|
-
if (typeof to === "number") {
|
|
8729
|
-
navigator2.go(to);
|
|
8730
|
-
return;
|
|
8731
|
-
}
|
|
8732
|
-
let path = resolveTo(
|
|
8733
|
-
to,
|
|
8734
|
-
JSON.parse(routePathnamesJson),
|
|
8735
|
-
locationPathname,
|
|
8736
|
-
options.relative === "path"
|
|
8737
|
-
);
|
|
8738
|
-
if (dataRouterContext == null && basename !== "/") {
|
|
8739
|
-
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
|
8740
|
-
}
|
|
8741
|
-
(!!options.replace ? navigator2.replace : navigator2.push)(
|
|
8742
|
-
path,
|
|
8743
|
-
options.state,
|
|
8744
|
-
options
|
|
8745
|
-
);
|
|
8746
|
-
},
|
|
8747
|
-
[
|
|
8748
|
-
basename,
|
|
8749
|
-
navigator2,
|
|
8750
|
-
routePathnamesJson,
|
|
8751
|
-
locationPathname,
|
|
8752
|
-
dataRouterContext
|
|
8753
|
-
]
|
|
8754
|
-
);
|
|
8755
|
-
return navigate;
|
|
8756
|
-
}
|
|
8757
|
-
var OutletContext = React25.createContext(null);
|
|
8758
|
-
function useParams2() {
|
|
8759
|
-
let { matches } = React25.useContext(RouteContext);
|
|
8760
|
-
let routeMatch = matches[matches.length - 1];
|
|
8761
|
-
return routeMatch ? routeMatch.params : {};
|
|
8762
|
-
}
|
|
8763
|
-
function useResolvedPath(to, { relative } = {}) {
|
|
8764
|
-
let { matches } = React25.useContext(RouteContext);
|
|
8765
|
-
let { pathname: locationPathname } = useLocation3();
|
|
8766
|
-
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
|
|
8767
|
-
return React25.useMemo(
|
|
8768
|
-
() => resolveTo(
|
|
8769
|
-
to,
|
|
8770
|
-
JSON.parse(routePathnamesJson),
|
|
8771
|
-
locationPathname,
|
|
8772
|
-
relative === "path"
|
|
8773
|
-
),
|
|
8774
|
-
[to, routePathnamesJson, locationPathname, relative]
|
|
8775
|
-
);
|
|
8776
|
-
}
|
|
8777
|
-
function useRoutesImpl(routes, locationArg, dataRouterOpts) {
|
|
8778
|
-
invariant(
|
|
8779
|
-
useInRouterContext(),
|
|
8780
|
-
// TODO: This error is probably because they somehow have 2 versions of the
|
|
8781
|
-
// router loaded. We can help them understand how to avoid that.
|
|
8782
|
-
`useRoutes() may be used only in the context of a <Router> component.`
|
|
8783
|
-
);
|
|
8784
|
-
let { navigator: navigator2 } = React25.useContext(NavigationContext);
|
|
8785
|
-
let { matches: parentMatches } = React25.useContext(RouteContext);
|
|
8786
|
-
let routeMatch = parentMatches[parentMatches.length - 1];
|
|
8787
|
-
let parentParams = routeMatch ? routeMatch.params : {};
|
|
8788
|
-
let parentPathname = routeMatch ? routeMatch.pathname : "/";
|
|
8789
|
-
let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
|
|
8790
|
-
let parentRoute = routeMatch && routeMatch.route;
|
|
8791
|
-
if (ENABLE_DEV_WARNINGS) {
|
|
8792
|
-
let parentPath = parentRoute && parentRoute.path || "";
|
|
8793
|
-
warningOnce2(
|
|
8794
|
-
parentPathname,
|
|
8795
|
-
!parentRoute || parentPath.endsWith("*") || parentPath.endsWith("*?"),
|
|
8796
|
-
`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${parentPathname}" (under <Route path="${parentPath}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
8797
|
-
|
|
8798
|
-
Please change the parent <Route path="${parentPath}"> to <Route path="${parentPath === "/" ? "*" : `${parentPath}/*`}">.`
|
|
8799
|
-
);
|
|
8800
|
-
}
|
|
8801
|
-
let locationFromContext = useLocation3();
|
|
8802
|
-
let location;
|
|
8803
|
-
if (locationArg) {
|
|
8804
|
-
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
8805
|
-
invariant(
|
|
8806
|
-
parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase),
|
|
8807
|
-
`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${parentPathnameBase}" but pathname "${parsedLocationArg.pathname}" was given in the \`location\` prop.`
|
|
8808
|
-
);
|
|
8809
|
-
location = parsedLocationArg;
|
|
8810
|
-
} else {
|
|
8811
|
-
location = locationFromContext;
|
|
8812
|
-
}
|
|
8813
|
-
let pathname = location.pathname || "/";
|
|
8814
|
-
let remainingPathname = pathname;
|
|
8815
|
-
if (parentPathnameBase !== "/") {
|
|
8816
|
-
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
|
|
8817
|
-
let segments = pathname.replace(/^\//, "").split("/");
|
|
8818
|
-
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
|
|
8819
|
-
}
|
|
8820
|
-
let matches = matchRoutes(routes, { pathname: remainingPathname });
|
|
8821
|
-
if (ENABLE_DEV_WARNINGS) {
|
|
8822
|
-
warning3(
|
|
8823
|
-
parentRoute || matches != null,
|
|
8824
|
-
`No routes matched location "${location.pathname}${location.search}${location.hash}" `
|
|
8825
|
-
);
|
|
8826
|
-
warning3(
|
|
8827
|
-
matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0,
|
|
8828
|
-
`Matched leaf route at location "${location.pathname}${location.search}${location.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`
|
|
8829
|
-
);
|
|
8830
|
-
}
|
|
8831
|
-
let renderedMatches = _renderMatches(
|
|
8832
|
-
matches && matches.map(
|
|
8833
|
-
(match) => Object.assign({}, match, {
|
|
8834
|
-
params: Object.assign({}, parentParams, match.params),
|
|
8835
|
-
pathname: joinPaths([
|
|
8836
|
-
parentPathnameBase,
|
|
8837
|
-
// Re-encode pathnames that were decoded inside matchRoutes.
|
|
8838
|
-
// Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
|
|
8839
|
-
// `new URL()` internally and we need to prevent it from treating
|
|
8840
|
-
// them as separators
|
|
8841
|
-
navigator2.encodeLocation ? navigator2.encodeLocation(
|
|
8842
|
-
match.pathname.replace(/\?/g, "%3F").replace(/#/g, "%23")
|
|
8843
|
-
).pathname : match.pathname
|
|
8844
|
-
]),
|
|
8845
|
-
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
|
|
8846
|
-
parentPathnameBase,
|
|
8847
|
-
// Re-encode pathnames that were decoded inside matchRoutes
|
|
8848
|
-
// Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
|
|
8849
|
-
// `new URL()` internally and we need to prevent it from treating
|
|
8850
|
-
// them as separators
|
|
8851
|
-
navigator2.encodeLocation ? navigator2.encodeLocation(
|
|
8852
|
-
match.pathnameBase.replace(/\?/g, "%3F").replace(/#/g, "%23")
|
|
8853
|
-
).pathname : match.pathnameBase
|
|
8854
|
-
])
|
|
8855
|
-
})
|
|
8856
|
-
),
|
|
8857
|
-
parentMatches,
|
|
8858
|
-
dataRouterOpts
|
|
8859
|
-
);
|
|
8860
|
-
if (locationArg && renderedMatches) {
|
|
8861
|
-
return /* @__PURE__ */ React25.createElement(
|
|
8862
|
-
LocationContext.Provider,
|
|
8863
|
-
{
|
|
8864
|
-
value: {
|
|
8865
|
-
location: {
|
|
8866
|
-
pathname: "/",
|
|
8867
|
-
search: "",
|
|
8868
|
-
hash: "",
|
|
8869
|
-
state: null,
|
|
8870
|
-
key: "default",
|
|
8871
|
-
unstable_mask: void 0,
|
|
8872
|
-
...location
|
|
8873
|
-
},
|
|
8874
|
-
navigationType: "POP"
|
|
8875
|
-
/* Pop */
|
|
8876
|
-
}
|
|
8877
|
-
},
|
|
8878
|
-
renderedMatches
|
|
8879
|
-
);
|
|
8880
|
-
}
|
|
8881
|
-
return renderedMatches;
|
|
8882
|
-
}
|
|
8883
|
-
function DefaultErrorComponent() {
|
|
8884
|
-
let error = useRouteError();
|
|
8885
|
-
let message13 = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
|
|
8886
|
-
let stack = error instanceof Error ? error.stack : null;
|
|
8887
|
-
let lightgrey = "rgba(200,200,200, 0.5)";
|
|
8888
|
-
let preStyles = { padding: "0.5rem", backgroundColor: lightgrey };
|
|
8889
|
-
let codeStyles = { padding: "2px 4px", backgroundColor: lightgrey };
|
|
8890
|
-
let devInfo = null;
|
|
8891
|
-
if (ENABLE_DEV_WARNINGS) {
|
|
8892
|
-
console.error(
|
|
8893
|
-
"Error handled by React Router default ErrorBoundary:",
|
|
8894
|
-
error
|
|
8895
|
-
);
|
|
8896
|
-
devInfo = /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement("p", null, "\u{1F4BF} Hey developer \u{1F44B}"), /* @__PURE__ */ React25.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React25.createElement("code", { style: codeStyles }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React25.createElement("code", { style: codeStyles }, "errorElement"), " prop on your route."));
|
|
8897
|
-
}
|
|
8898
|
-
return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React25.createElement("h3", { style: { fontStyle: "italic" } }, message13), stack ? /* @__PURE__ */ React25.createElement("pre", { style: preStyles }, stack) : null, devInfo);
|
|
8899
|
-
}
|
|
8900
|
-
var defaultErrorElement = /* @__PURE__ */ React25.createElement(DefaultErrorComponent, null);
|
|
8901
|
-
var RenderErrorBoundary = class extends React25.Component {
|
|
8902
|
-
constructor(props) {
|
|
8903
|
-
super(props);
|
|
8904
|
-
this.state = {
|
|
8905
|
-
location: props.location,
|
|
8906
|
-
revalidation: props.revalidation,
|
|
8907
|
-
error: props.error
|
|
8908
|
-
};
|
|
8909
|
-
}
|
|
8910
|
-
static getDerivedStateFromError(error) {
|
|
8911
|
-
return { error };
|
|
8912
|
-
}
|
|
8913
|
-
static getDerivedStateFromProps(props, state) {
|
|
8914
|
-
if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
|
|
8915
|
-
return {
|
|
8916
|
-
error: props.error,
|
|
8917
|
-
location: props.location,
|
|
8918
|
-
revalidation: props.revalidation
|
|
8919
|
-
};
|
|
8920
|
-
}
|
|
8921
|
-
return {
|
|
8922
|
-
error: props.error !== void 0 ? props.error : state.error,
|
|
8923
|
-
location: state.location,
|
|
8924
|
-
revalidation: props.revalidation || state.revalidation
|
|
8925
|
-
};
|
|
8926
|
-
}
|
|
8927
|
-
componentDidCatch(error, errorInfo) {
|
|
8928
|
-
if (this.props.onError) {
|
|
8929
|
-
this.props.onError(error, errorInfo);
|
|
8930
|
-
} else {
|
|
8931
|
-
console.error(
|
|
8932
|
-
"React Router caught the following error during render",
|
|
8933
|
-
error
|
|
8934
|
-
);
|
|
8935
|
-
}
|
|
8936
|
-
}
|
|
8937
|
-
render() {
|
|
8938
|
-
let error = this.state.error;
|
|
8939
|
-
if (this.context && typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
|
|
8940
|
-
const decoded = decodeRouteErrorResponseDigest(error.digest);
|
|
8941
|
-
if (decoded) error = decoded;
|
|
8942
|
-
}
|
|
8943
|
-
let result = error !== void 0 ? /* @__PURE__ */ React25.createElement(RouteContext.Provider, { value: this.props.routeContext }, /* @__PURE__ */ React25.createElement(
|
|
8944
|
-
RouteErrorContext.Provider,
|
|
8945
|
-
{
|
|
8946
|
-
value: error,
|
|
8947
|
-
children: this.props.component
|
|
8948
|
-
}
|
|
8949
|
-
)) : this.props.children;
|
|
8950
|
-
if (this.context) {
|
|
8951
|
-
return /* @__PURE__ */ React25.createElement(RSCErrorHandler, { error }, result);
|
|
8952
|
-
}
|
|
8953
|
-
return result;
|
|
8954
|
-
}
|
|
8955
|
-
};
|
|
8956
|
-
RenderErrorBoundary.contextType = RSCRouterContext;
|
|
8957
|
-
var errorRedirectHandledMap = /* @__PURE__ */ new WeakMap();
|
|
8958
|
-
function RSCErrorHandler({
|
|
8959
|
-
children,
|
|
8960
|
-
error
|
|
8961
|
-
}) {
|
|
8962
|
-
let { basename } = React25.useContext(NavigationContext);
|
|
8963
|
-
if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
|
|
8964
|
-
let redirect2 = decodeRedirectErrorDigest(error.digest);
|
|
8965
|
-
if (redirect2) {
|
|
8966
|
-
let existingRedirect = errorRedirectHandledMap.get(error);
|
|
8967
|
-
if (existingRedirect) throw existingRedirect;
|
|
8968
|
-
let parsed = parseToInfo(redirect2.location, basename);
|
|
8969
|
-
if (isBrowser2 && !errorRedirectHandledMap.get(error)) {
|
|
8970
|
-
if (parsed.isExternal || redirect2.reloadDocument) {
|
|
8971
|
-
window.location.href = parsed.absoluteURL || parsed.to;
|
|
8972
|
-
} else {
|
|
8973
|
-
const redirectPromise = Promise.resolve().then(
|
|
8974
|
-
() => window.__reactRouterDataRouter.navigate(parsed.to, {
|
|
8975
|
-
replace: redirect2.replace
|
|
8976
|
-
})
|
|
8977
|
-
);
|
|
8978
|
-
errorRedirectHandledMap.set(error, redirectPromise);
|
|
8979
|
-
throw redirectPromise;
|
|
8980
|
-
}
|
|
8981
|
-
}
|
|
8982
|
-
return /* @__PURE__ */ React25.createElement(
|
|
8983
|
-
"meta",
|
|
8984
|
-
{
|
|
8985
|
-
httpEquiv: "refresh",
|
|
8986
|
-
content: `0;url=${parsed.absoluteURL || parsed.to}`
|
|
8987
|
-
}
|
|
8988
|
-
);
|
|
8989
|
-
}
|
|
8990
|
-
}
|
|
8991
|
-
return children;
|
|
8992
|
-
}
|
|
8993
|
-
function RenderedRoute({ routeContext, match, children }) {
|
|
8994
|
-
let dataRouterContext = React25.useContext(DataRouterContext);
|
|
8995
|
-
if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
|
|
8996
|
-
dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
|
|
8997
|
-
}
|
|
8998
|
-
return /* @__PURE__ */ React25.createElement(RouteContext.Provider, { value: routeContext }, children);
|
|
8999
|
-
}
|
|
9000
|
-
function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
|
|
9001
|
-
let dataRouterState = dataRouterOpts?.state;
|
|
9002
|
-
if (matches == null) {
|
|
9003
|
-
if (!dataRouterState) {
|
|
9004
|
-
return null;
|
|
9005
|
-
}
|
|
9006
|
-
if (dataRouterState.errors) {
|
|
9007
|
-
matches = dataRouterState.matches;
|
|
9008
|
-
} else if (parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
|
|
9009
|
-
matches = dataRouterState.matches;
|
|
9010
|
-
} else {
|
|
9011
|
-
return null;
|
|
9012
|
-
}
|
|
9013
|
-
}
|
|
9014
|
-
let renderedMatches = matches;
|
|
9015
|
-
let errors = dataRouterState?.errors;
|
|
9016
|
-
if (errors != null) {
|
|
9017
|
-
let errorIndex = renderedMatches.findIndex(
|
|
9018
|
-
(m) => m.route.id && errors?.[m.route.id] !== void 0
|
|
9019
|
-
);
|
|
9020
|
-
invariant(
|
|
9021
|
-
errorIndex >= 0,
|
|
9022
|
-
`Could not find a matching route for errors on route IDs: ${Object.keys(
|
|
9023
|
-
errors
|
|
9024
|
-
).join(",")}`
|
|
9025
|
-
);
|
|
9026
|
-
renderedMatches = renderedMatches.slice(
|
|
9027
|
-
0,
|
|
9028
|
-
Math.min(renderedMatches.length, errorIndex + 1)
|
|
9029
|
-
);
|
|
9030
|
-
}
|
|
9031
|
-
let renderFallback = false;
|
|
9032
|
-
let fallbackIndex = -1;
|
|
9033
|
-
if (dataRouterOpts && dataRouterState) {
|
|
9034
|
-
renderFallback = dataRouterState.renderFallback;
|
|
9035
|
-
for (let i = 0; i < renderedMatches.length; i++) {
|
|
9036
|
-
let match = renderedMatches[i];
|
|
9037
|
-
if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
|
|
9038
|
-
fallbackIndex = i;
|
|
9039
|
-
}
|
|
9040
|
-
if (match.route.id) {
|
|
9041
|
-
let { loaderData, errors: errors2 } = dataRouterState;
|
|
9042
|
-
let needsToRunLoader = match.route.loader && !loaderData.hasOwnProperty(match.route.id) && (!errors2 || errors2[match.route.id] === void 0);
|
|
9043
|
-
if (match.route.lazy || needsToRunLoader) {
|
|
9044
|
-
if (dataRouterOpts.isStatic) {
|
|
9045
|
-
renderFallback = true;
|
|
9046
|
-
}
|
|
9047
|
-
if (fallbackIndex >= 0) {
|
|
9048
|
-
renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
|
|
9049
|
-
} else {
|
|
9050
|
-
renderedMatches = [renderedMatches[0]];
|
|
9051
|
-
}
|
|
9052
|
-
break;
|
|
9053
|
-
}
|
|
9054
|
-
}
|
|
9055
|
-
}
|
|
9056
|
-
}
|
|
9057
|
-
let onErrorHandler = dataRouterOpts?.onError;
|
|
9058
|
-
let onError = dataRouterState && onErrorHandler ? (error, errorInfo) => {
|
|
9059
|
-
onErrorHandler(error, {
|
|
9060
|
-
location: dataRouterState.location,
|
|
9061
|
-
params: dataRouterState.matches?.[0]?.params ?? {},
|
|
9062
|
-
unstable_pattern: getRoutePattern(dataRouterState.matches),
|
|
9063
|
-
errorInfo
|
|
9064
|
-
});
|
|
9065
|
-
} : void 0;
|
|
9066
|
-
return renderedMatches.reduceRight(
|
|
9067
|
-
(outlet, match, index) => {
|
|
9068
|
-
let error;
|
|
9069
|
-
let shouldRenderHydrateFallback = false;
|
|
9070
|
-
let errorElement = null;
|
|
9071
|
-
let hydrateFallbackElement = null;
|
|
9072
|
-
if (dataRouterState) {
|
|
9073
|
-
error = errors && match.route.id ? errors[match.route.id] : void 0;
|
|
9074
|
-
errorElement = match.route.errorElement || defaultErrorElement;
|
|
9075
|
-
if (renderFallback) {
|
|
9076
|
-
if (fallbackIndex < 0 && index === 0) {
|
|
9077
|
-
warningOnce2(
|
|
9078
|
-
"route-fallback",
|
|
9079
|
-
false,
|
|
9080
|
-
"No `HydrateFallback` element provided to render during initial hydration"
|
|
9081
|
-
);
|
|
9082
|
-
shouldRenderHydrateFallback = true;
|
|
9083
|
-
hydrateFallbackElement = null;
|
|
9084
|
-
} else if (fallbackIndex === index) {
|
|
9085
|
-
shouldRenderHydrateFallback = true;
|
|
9086
|
-
hydrateFallbackElement = match.route.hydrateFallbackElement || null;
|
|
9087
|
-
}
|
|
9088
|
-
}
|
|
9089
|
-
}
|
|
9090
|
-
let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
|
|
9091
|
-
let getChildren = () => {
|
|
9092
|
-
let children;
|
|
9093
|
-
if (error) {
|
|
9094
|
-
children = errorElement;
|
|
9095
|
-
} else if (shouldRenderHydrateFallback) {
|
|
9096
|
-
children = hydrateFallbackElement;
|
|
9097
|
-
} else if (match.route.Component) {
|
|
9098
|
-
children = /* @__PURE__ */ React25.createElement(match.route.Component, null);
|
|
9099
|
-
} else if (match.route.element) {
|
|
9100
|
-
children = match.route.element;
|
|
9101
|
-
} else {
|
|
9102
|
-
children = outlet;
|
|
9103
|
-
}
|
|
9104
|
-
return /* @__PURE__ */ React25.createElement(
|
|
9105
|
-
RenderedRoute,
|
|
9106
|
-
{
|
|
9107
|
-
match,
|
|
9108
|
-
routeContext: {
|
|
9109
|
-
outlet,
|
|
9110
|
-
matches: matches2,
|
|
9111
|
-
isDataRoute: dataRouterState != null
|
|
9112
|
-
},
|
|
9113
|
-
children
|
|
9114
|
-
}
|
|
9115
|
-
);
|
|
9116
|
-
};
|
|
9117
|
-
return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React25.createElement(
|
|
9118
|
-
RenderErrorBoundary,
|
|
9119
|
-
{
|
|
9120
|
-
location: dataRouterState.location,
|
|
9121
|
-
revalidation: dataRouterState.revalidation,
|
|
9122
|
-
component: errorElement,
|
|
9123
|
-
error,
|
|
9124
|
-
children: getChildren(),
|
|
9125
|
-
routeContext: { outlet: null, matches: matches2, isDataRoute: true },
|
|
9126
|
-
onError
|
|
9127
|
-
}
|
|
9128
|
-
) : getChildren();
|
|
9129
|
-
},
|
|
9130
|
-
null
|
|
9131
|
-
);
|
|
9132
|
-
}
|
|
9133
|
-
function getDataRouterConsoleError(hookName) {
|
|
9134
|
-
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
|
9135
|
-
}
|
|
9136
|
-
function useDataRouterContext(hookName) {
|
|
9137
|
-
let ctx = React25.useContext(DataRouterContext);
|
|
9138
|
-
invariant(ctx, getDataRouterConsoleError(hookName));
|
|
9139
|
-
return ctx;
|
|
9140
|
-
}
|
|
9141
|
-
function useDataRouterState(hookName) {
|
|
9142
|
-
let state = React25.useContext(DataRouterStateContext);
|
|
9143
|
-
invariant(state, getDataRouterConsoleError(hookName));
|
|
9144
|
-
return state;
|
|
9145
|
-
}
|
|
9146
|
-
function useRouteContext(hookName) {
|
|
9147
|
-
let route = React25.useContext(RouteContext);
|
|
9148
|
-
invariant(route, getDataRouterConsoleError(hookName));
|
|
9149
|
-
return route;
|
|
9150
|
-
}
|
|
9151
|
-
function useCurrentRouteId(hookName) {
|
|
9152
|
-
let route = useRouteContext(hookName);
|
|
9153
|
-
let thisRoute = route.matches[route.matches.length - 1];
|
|
9154
|
-
invariant(
|
|
9155
|
-
thisRoute.route.id,
|
|
9156
|
-
`${hookName} can only be used on routes that contain a unique "id"`
|
|
9157
|
-
);
|
|
9158
|
-
return thisRoute.route.id;
|
|
9159
|
-
}
|
|
9160
|
-
function useRouteId() {
|
|
9161
|
-
return useCurrentRouteId(
|
|
9162
|
-
"useRouteId"
|
|
9163
|
-
/* UseRouteId */
|
|
9164
|
-
);
|
|
9165
|
-
}
|
|
9166
|
-
function useNavigation() {
|
|
9167
|
-
let state = useDataRouterState(
|
|
9168
|
-
"useNavigation"
|
|
9169
|
-
/* UseNavigation */
|
|
9170
|
-
);
|
|
9171
|
-
return state.navigation;
|
|
9172
|
-
}
|
|
9173
|
-
function useMatches() {
|
|
9174
|
-
let { matches, loaderData } = useDataRouterState(
|
|
9175
|
-
"useMatches"
|
|
9176
|
-
/* UseMatches */
|
|
9177
|
-
);
|
|
9178
|
-
return React25.useMemo(
|
|
9179
|
-
() => matches.map((m) => convertRouteMatchToUiMatch(m, loaderData)),
|
|
9180
|
-
[matches, loaderData]
|
|
9181
|
-
);
|
|
9182
|
-
}
|
|
9183
|
-
function useRouteError() {
|
|
9184
|
-
let error = React25.useContext(RouteErrorContext);
|
|
9185
|
-
let state = useDataRouterState(
|
|
9186
|
-
"useRouteError"
|
|
9187
|
-
/* UseRouteError */
|
|
9188
|
-
);
|
|
9189
|
-
let routeId = useCurrentRouteId(
|
|
9190
|
-
"useRouteError"
|
|
9191
|
-
/* UseRouteError */
|
|
9192
|
-
);
|
|
9193
|
-
if (error !== void 0) {
|
|
9194
|
-
return error;
|
|
9195
|
-
}
|
|
9196
|
-
return state.errors?.[routeId];
|
|
9197
|
-
}
|
|
9198
|
-
function useNavigateStable() {
|
|
9199
|
-
let { router } = useDataRouterContext(
|
|
9200
|
-
"useNavigate"
|
|
9201
|
-
/* UseNavigateStable */
|
|
9202
|
-
);
|
|
9203
|
-
let id = useCurrentRouteId(
|
|
9204
|
-
"useNavigate"
|
|
9205
|
-
/* UseNavigateStable */
|
|
9206
|
-
);
|
|
9207
|
-
let activeRef = React25.useRef(false);
|
|
9208
|
-
useIsomorphicLayoutEffect(() => {
|
|
9209
|
-
activeRef.current = true;
|
|
9210
|
-
});
|
|
9211
|
-
let navigate = React25.useCallback(
|
|
9212
|
-
async (to, options = {}) => {
|
|
9213
|
-
warning3(activeRef.current, navigateEffectWarning);
|
|
9214
|
-
if (!activeRef.current) return;
|
|
9215
|
-
if (typeof to === "number") {
|
|
9216
|
-
await router.navigate(to);
|
|
9217
|
-
} else {
|
|
9218
|
-
await router.navigate(to, { fromRouteId: id, ...options });
|
|
9219
|
-
}
|
|
9220
|
-
},
|
|
9221
|
-
[router, id]
|
|
9222
|
-
);
|
|
9223
|
-
return navigate;
|
|
9224
|
-
}
|
|
9225
|
-
var alreadyWarned = {};
|
|
9226
|
-
function warningOnce2(key, cond, message13) {
|
|
9227
|
-
if (!cond && !alreadyWarned[key]) {
|
|
9228
|
-
alreadyWarned[key] = true;
|
|
9229
|
-
warning3(false, message13);
|
|
9230
|
-
}
|
|
9231
|
-
}
|
|
9232
|
-
var USE_OPTIMISTIC = "useOptimistic";
|
|
9233
|
-
var useOptimisticImpl = React32[USE_OPTIMISTIC];
|
|
9234
|
-
var MemoizedDataRoutes = React32.memo(DataRoutes);
|
|
9235
|
-
function DataRoutes({
|
|
9236
|
-
routes,
|
|
9237
|
-
future,
|
|
9238
|
-
state,
|
|
9239
|
-
isStatic,
|
|
9240
|
-
onError
|
|
9241
|
-
}) {
|
|
9242
|
-
return useRoutesImpl(routes, void 0, { state, isStatic, onError, future });
|
|
9243
|
-
}
|
|
9244
|
-
function Router({
|
|
9245
|
-
basename: basenameProp = "/",
|
|
9246
|
-
children = null,
|
|
9247
|
-
location: locationProp,
|
|
9248
|
-
navigationType = "POP",
|
|
9249
|
-
navigator: navigator2,
|
|
9250
|
-
static: staticProp = false,
|
|
9251
|
-
unstable_useTransitions
|
|
9252
|
-
}) {
|
|
9253
|
-
invariant(
|
|
9254
|
-
!useInRouterContext(),
|
|
9255
|
-
`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`
|
|
9256
|
-
);
|
|
9257
|
-
let basename = basenameProp.replace(/^\/*/, "/");
|
|
9258
|
-
let navigationContext = React32.useMemo(
|
|
9259
|
-
() => ({
|
|
9260
|
-
basename,
|
|
9261
|
-
navigator: navigator2,
|
|
9262
|
-
static: staticProp,
|
|
9263
|
-
unstable_useTransitions,
|
|
9264
|
-
future: {}
|
|
9265
|
-
}),
|
|
9266
|
-
[basename, navigator2, staticProp, unstable_useTransitions]
|
|
9267
|
-
);
|
|
9268
|
-
if (typeof locationProp === "string") {
|
|
9269
|
-
locationProp = parsePath(locationProp);
|
|
9270
|
-
}
|
|
9271
|
-
let {
|
|
9272
|
-
pathname = "/",
|
|
9273
|
-
search = "",
|
|
9274
|
-
hash = "",
|
|
9275
|
-
state = null,
|
|
9276
|
-
key = "default",
|
|
9277
|
-
unstable_mask
|
|
9278
|
-
} = locationProp;
|
|
9279
|
-
let locationContext = React32.useMemo(() => {
|
|
9280
|
-
let trailingPathname = stripBasename(pathname, basename);
|
|
9281
|
-
if (trailingPathname == null) {
|
|
9282
|
-
return null;
|
|
9283
|
-
}
|
|
9284
|
-
return {
|
|
9285
|
-
location: {
|
|
9286
|
-
pathname: trailingPathname,
|
|
9287
|
-
search,
|
|
9288
|
-
hash,
|
|
9289
|
-
state,
|
|
9290
|
-
key,
|
|
9291
|
-
unstable_mask
|
|
9292
|
-
},
|
|
9293
|
-
navigationType
|
|
9294
|
-
};
|
|
9295
|
-
}, [
|
|
9296
|
-
basename,
|
|
9297
|
-
pathname,
|
|
9298
|
-
search,
|
|
9299
|
-
hash,
|
|
9300
|
-
state,
|
|
9301
|
-
key,
|
|
9302
|
-
navigationType,
|
|
9303
|
-
unstable_mask
|
|
9304
|
-
]);
|
|
9305
|
-
warning3(
|
|
9306
|
-
locationContext != null,
|
|
9307
|
-
`<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.`
|
|
9308
|
-
);
|
|
9309
|
-
if (locationContext == null) {
|
|
9310
|
-
return null;
|
|
9311
|
-
}
|
|
9312
|
-
return /* @__PURE__ */ React32.createElement(NavigationContext.Provider, { value: navigationContext }, /* @__PURE__ */ React32.createElement(LocationContext.Provider, { children, value: locationContext }));
|
|
9313
|
-
}
|
|
9314
|
-
var defaultMethod = "get";
|
|
9315
|
-
var defaultEncType = "application/x-www-form-urlencoded";
|
|
9316
|
-
function isHtmlElement(object3) {
|
|
9317
|
-
return typeof HTMLElement !== "undefined" && object3 instanceof HTMLElement;
|
|
9318
|
-
}
|
|
9319
|
-
function isButtonElement(object3) {
|
|
9320
|
-
return isHtmlElement(object3) && object3.tagName.toLowerCase() === "button";
|
|
9321
|
-
}
|
|
9322
|
-
function isFormElement(object3) {
|
|
9323
|
-
return isHtmlElement(object3) && object3.tagName.toLowerCase() === "form";
|
|
9324
|
-
}
|
|
9325
|
-
function isInputElement(object3) {
|
|
9326
|
-
return isHtmlElement(object3) && object3.tagName.toLowerCase() === "input";
|
|
9327
|
-
}
|
|
9328
|
-
function isModifiedEvent(event) {
|
|
9329
|
-
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
|
9330
|
-
}
|
|
9331
|
-
function shouldProcessLinkClick(event, target) {
|
|
9332
|
-
return event.button === 0 && // Ignore everything but left clicks
|
|
9333
|
-
(!target || target === "_self") && // Let browser handle "target=_blank" etc.
|
|
9334
|
-
!isModifiedEvent(event);
|
|
9335
|
-
}
|
|
9336
|
-
function createSearchParams(init = "") {
|
|
9337
|
-
return new URLSearchParams(
|
|
9338
|
-
typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo2, key) => {
|
|
9339
|
-
let value = init[key];
|
|
9340
|
-
return memo2.concat(
|
|
9341
|
-
Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]
|
|
9342
|
-
);
|
|
9343
|
-
}, [])
|
|
9344
|
-
);
|
|
9345
|
-
}
|
|
9346
|
-
function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
|
|
9347
|
-
let searchParams = createSearchParams(locationSearch);
|
|
9348
|
-
if (defaultSearchParams) {
|
|
9349
|
-
defaultSearchParams.forEach((_, key) => {
|
|
9350
|
-
if (!searchParams.has(key)) {
|
|
9351
|
-
defaultSearchParams.getAll(key).forEach((value) => {
|
|
9352
|
-
searchParams.append(key, value);
|
|
9353
|
-
});
|
|
9354
|
-
}
|
|
9355
|
-
});
|
|
9356
|
-
}
|
|
9357
|
-
return searchParams;
|
|
9358
|
-
}
|
|
9359
|
-
var _formDataSupportsSubmitter = null;
|
|
9360
|
-
function isFormDataSubmitterSupported() {
|
|
9361
|
-
if (_formDataSupportsSubmitter === null) {
|
|
9362
|
-
try {
|
|
9363
|
-
new FormData(
|
|
9364
|
-
document.createElement("form"),
|
|
9365
|
-
// @ts-expect-error if FormData supports the submitter parameter, this will throw
|
|
9366
|
-
0
|
|
9367
|
-
);
|
|
9368
|
-
_formDataSupportsSubmitter = false;
|
|
9369
|
-
} catch (e) {
|
|
9370
|
-
_formDataSupportsSubmitter = true;
|
|
9371
|
-
}
|
|
9372
|
-
}
|
|
9373
|
-
return _formDataSupportsSubmitter;
|
|
9374
|
-
}
|
|
9375
|
-
var supportedFormEncTypes = /* @__PURE__ */ new Set([
|
|
9376
|
-
"application/x-www-form-urlencoded",
|
|
9377
|
-
"multipart/form-data",
|
|
9378
|
-
"text/plain"
|
|
9379
|
-
]);
|
|
9380
|
-
function getFormEncType(encType) {
|
|
9381
|
-
if (encType != null && !supportedFormEncTypes.has(encType)) {
|
|
9382
|
-
warning3(
|
|
9383
|
-
false,
|
|
9384
|
-
`"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
|
|
9385
|
-
);
|
|
9386
|
-
return null;
|
|
9387
|
-
}
|
|
9388
|
-
return encType;
|
|
9389
|
-
}
|
|
9390
|
-
function getFormSubmissionInfo(target, basename) {
|
|
9391
|
-
let method;
|
|
9392
|
-
let action;
|
|
9393
|
-
let encType;
|
|
9394
|
-
let formData;
|
|
9395
|
-
let body;
|
|
9396
|
-
if (isFormElement(target)) {
|
|
9397
|
-
let attr = target.getAttribute("action");
|
|
9398
|
-
action = attr ? stripBasename(attr, basename) : null;
|
|
9399
|
-
method = target.getAttribute("method") || defaultMethod;
|
|
9400
|
-
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
|
|
9401
|
-
formData = new FormData(target);
|
|
9402
|
-
} else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
|
|
9403
|
-
let form = target.form;
|
|
9404
|
-
if (form == null) {
|
|
9405
|
-
throw new Error(
|
|
9406
|
-
`Cannot submit a <button> or <input type="submit"> without a <form>`
|
|
9407
|
-
);
|
|
9408
|
-
}
|
|
9409
|
-
let attr = target.getAttribute("formaction") || form.getAttribute("action");
|
|
9410
|
-
action = attr ? stripBasename(attr, basename) : null;
|
|
9411
|
-
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
|
|
9412
|
-
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
|
|
9413
|
-
formData = new FormData(form, target);
|
|
9414
|
-
if (!isFormDataSubmitterSupported()) {
|
|
9415
|
-
let { name, type, value } = target;
|
|
9416
|
-
if (type === "image") {
|
|
9417
|
-
let prefix = name ? `${name}.` : "";
|
|
9418
|
-
formData.append(`${prefix}x`, "0");
|
|
9419
|
-
formData.append(`${prefix}y`, "0");
|
|
9420
|
-
} else if (name) {
|
|
9421
|
-
formData.append(name, value);
|
|
9422
|
-
}
|
|
9423
|
-
}
|
|
9424
|
-
} else if (isHtmlElement(target)) {
|
|
9425
|
-
throw new Error(
|
|
9426
|
-
`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
|
|
9427
|
-
);
|
|
9428
|
-
} else {
|
|
9429
|
-
method = defaultMethod;
|
|
9430
|
-
action = null;
|
|
9431
|
-
encType = defaultEncType;
|
|
9432
|
-
body = target;
|
|
9433
|
-
}
|
|
9434
|
-
if (formData && encType === "text/plain") {
|
|
9435
|
-
body = formData;
|
|
9436
|
-
formData = void 0;
|
|
9437
|
-
}
|
|
9438
|
-
return { action, method: method.toLowerCase(), encType, formData, body };
|
|
9439
|
-
}
|
|
9440
|
-
var objectProtoNames2 = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
9441
|
-
var ESCAPE_LOOKUP = {
|
|
9442
|
-
"&": "\\u0026",
|
|
9443
|
-
">": "\\u003e",
|
|
9444
|
-
"<": "\\u003c",
|
|
9445
|
-
"\u2028": "\\u2028",
|
|
9446
|
-
"\u2029": "\\u2029"
|
|
9447
|
-
};
|
|
9448
|
-
var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
|
|
9449
|
-
function escapeHtml(html) {
|
|
9450
|
-
return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
|
|
9451
|
-
}
|
|
9452
|
-
function invariant2(value, message13) {
|
|
9453
|
-
if (value === false || value === null || typeof value === "undefined") {
|
|
9454
|
-
throw new Error(message13);
|
|
9455
|
-
}
|
|
9456
|
-
}
|
|
9457
|
-
function singleFetchUrl(reqUrl, basename, trailingSlashAware, extension) {
|
|
9458
|
-
let url = typeof reqUrl === "string" ? new URL(
|
|
9459
|
-
reqUrl,
|
|
9460
|
-
// This can be called during the SSR flow via PrefetchPageLinksImpl so
|
|
9461
|
-
// don't assume window is available
|
|
9462
|
-
typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
|
|
9463
|
-
) : reqUrl;
|
|
9464
|
-
if (trailingSlashAware) {
|
|
9465
|
-
if (url.pathname.endsWith("/")) {
|
|
9466
|
-
url.pathname = `${url.pathname}_.${extension}`;
|
|
9467
|
-
} else {
|
|
9468
|
-
url.pathname = `${url.pathname}.${extension}`;
|
|
9469
|
-
}
|
|
9470
|
-
} else {
|
|
9471
|
-
if (url.pathname === "/") {
|
|
9472
|
-
url.pathname = `_root.${extension}`;
|
|
9473
|
-
} else if (basename && stripBasename(url.pathname, basename) === "/") {
|
|
9474
|
-
url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
|
|
9475
|
-
} else {
|
|
9476
|
-
url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
|
|
9477
|
-
}
|
|
9478
|
-
}
|
|
9479
|
-
return url;
|
|
9480
|
-
}
|
|
9481
|
-
async function loadRouteModule(route, routeModulesCache) {
|
|
9482
|
-
if (route.id in routeModulesCache) {
|
|
9483
|
-
return routeModulesCache[route.id];
|
|
9484
|
-
}
|
|
9485
|
-
try {
|
|
9486
|
-
let routeModule = await import(
|
|
9487
|
-
/* @vite-ignore */
|
|
9488
|
-
/* webpackIgnore: true */
|
|
9489
|
-
route.module
|
|
9490
|
-
);
|
|
9491
|
-
routeModulesCache[route.id] = routeModule;
|
|
9492
|
-
return routeModule;
|
|
9493
|
-
} catch (error) {
|
|
9494
|
-
console.error(
|
|
9495
|
-
`Error loading route module \`${route.module}\`, reloading page...`
|
|
9496
|
-
);
|
|
9497
|
-
console.error(error);
|
|
9498
|
-
if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
|
|
9499
|
-
import.meta.hot) {
|
|
9500
|
-
throw error;
|
|
9501
|
-
}
|
|
9502
|
-
window.location.reload();
|
|
9503
|
-
return new Promise(() => {
|
|
9504
|
-
});
|
|
9505
|
-
}
|
|
9506
|
-
}
|
|
9507
|
-
function isPageLinkDescriptor(object3) {
|
|
9508
|
-
return object3 != null && typeof object3.page === "string";
|
|
9509
|
-
}
|
|
9510
|
-
function isHtmlLinkDescriptor(object3) {
|
|
9511
|
-
if (object3 == null) {
|
|
9512
|
-
return false;
|
|
9513
|
-
}
|
|
9514
|
-
if (object3.href == null) {
|
|
9515
|
-
return object3.rel === "preload" && typeof object3.imageSrcSet === "string" && typeof object3.imageSizes === "string";
|
|
9516
|
-
}
|
|
9517
|
-
return typeof object3.rel === "string" && typeof object3.href === "string";
|
|
9518
|
-
}
|
|
9519
|
-
async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
|
|
9520
|
-
let links = await Promise.all(
|
|
9521
|
-
matches.map(async (match) => {
|
|
9522
|
-
let route = manifest.routes[match.route.id];
|
|
9523
|
-
if (route) {
|
|
9524
|
-
let mod = await loadRouteModule(route, routeModules);
|
|
9525
|
-
return mod.links ? mod.links() : [];
|
|
9526
|
-
}
|
|
9527
|
-
return [];
|
|
9528
|
-
})
|
|
9529
|
-
);
|
|
9530
|
-
return dedupeLinkDescriptors(
|
|
9531
|
-
links.flat(1).filter(isHtmlLinkDescriptor).filter((link) => link.rel === "stylesheet" || link.rel === "preload").map(
|
|
9532
|
-
(link) => link.rel === "stylesheet" ? { ...link, rel: "prefetch", as: "style" } : { ...link, rel: "prefetch" }
|
|
9533
|
-
)
|
|
9534
|
-
);
|
|
9535
|
-
}
|
|
9536
|
-
function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
|
|
9537
|
-
let isNew = (match, index) => {
|
|
9538
|
-
if (!currentMatches[index]) return true;
|
|
9539
|
-
return match.route.id !== currentMatches[index].route.id;
|
|
9540
|
-
};
|
|
9541
|
-
let matchPathChanged = (match, index) => {
|
|
9542
|
-
return (
|
|
9543
|
-
// param change, /users/123 -> /users/456
|
|
9544
|
-
currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
|
|
9545
|
-
// e.g. /files/images/avatar.jpg -> files/finances.xls
|
|
9546
|
-
currentMatches[index].route.path?.endsWith("*") && currentMatches[index].params["*"] !== match.params["*"]
|
|
9547
|
-
);
|
|
9548
|
-
};
|
|
9549
|
-
if (mode === "assets") {
|
|
9550
|
-
return nextMatches.filter(
|
|
9551
|
-
(match, index) => isNew(match, index) || matchPathChanged(match, index)
|
|
9552
|
-
);
|
|
9553
|
-
}
|
|
9554
|
-
if (mode === "data") {
|
|
9555
|
-
return nextMatches.filter((match, index) => {
|
|
9556
|
-
let manifestRoute = manifest.routes[match.route.id];
|
|
9557
|
-
if (!manifestRoute || !manifestRoute.hasLoader) {
|
|
9558
|
-
return false;
|
|
9559
|
-
}
|
|
9560
|
-
if (isNew(match, index) || matchPathChanged(match, index)) {
|
|
9561
|
-
return true;
|
|
9562
|
-
}
|
|
9563
|
-
if (match.route.shouldRevalidate) {
|
|
9564
|
-
let routeChoice = match.route.shouldRevalidate({
|
|
9565
|
-
currentUrl: new URL(
|
|
9566
|
-
location.pathname + location.search + location.hash,
|
|
9567
|
-
window.origin
|
|
9568
|
-
),
|
|
9569
|
-
currentParams: currentMatches[0]?.params || {},
|
|
9570
|
-
nextUrl: new URL(page, window.origin),
|
|
9571
|
-
nextParams: match.params,
|
|
9572
|
-
defaultShouldRevalidate: true
|
|
9573
|
-
});
|
|
9574
|
-
if (typeof routeChoice === "boolean") {
|
|
9575
|
-
return routeChoice;
|
|
9576
|
-
}
|
|
9577
|
-
}
|
|
9578
|
-
return true;
|
|
9579
|
-
});
|
|
9580
|
-
}
|
|
9581
|
-
return [];
|
|
9582
|
-
}
|
|
9583
|
-
function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
|
|
9584
|
-
return dedupeHrefs(
|
|
9585
|
-
matches.map((match) => {
|
|
9586
|
-
let route = manifest.routes[match.route.id];
|
|
9587
|
-
if (!route) return [];
|
|
9588
|
-
let hrefs = [route.module];
|
|
9589
|
-
if (route.clientActionModule) {
|
|
9590
|
-
hrefs = hrefs.concat(route.clientActionModule);
|
|
9591
|
-
}
|
|
9592
|
-
if (route.clientLoaderModule) {
|
|
9593
|
-
hrefs = hrefs.concat(route.clientLoaderModule);
|
|
9594
|
-
}
|
|
9595
|
-
if (includeHydrateFallback && route.hydrateFallbackModule) {
|
|
9596
|
-
hrefs = hrefs.concat(route.hydrateFallbackModule);
|
|
9597
|
-
}
|
|
9598
|
-
if (route.imports) {
|
|
9599
|
-
hrefs = hrefs.concat(route.imports);
|
|
9600
|
-
}
|
|
9601
|
-
return hrefs;
|
|
9602
|
-
}).flat(1)
|
|
9603
|
-
);
|
|
9604
|
-
}
|
|
9605
|
-
function dedupeHrefs(hrefs) {
|
|
9606
|
-
return [...new Set(hrefs)];
|
|
9607
|
-
}
|
|
9608
|
-
function sortKeys(obj) {
|
|
9609
|
-
let sorted = {};
|
|
9610
|
-
let keys = Object.keys(obj).sort();
|
|
9611
|
-
for (let key of keys) {
|
|
9612
|
-
sorted[key] = obj[key];
|
|
9613
|
-
}
|
|
9614
|
-
return sorted;
|
|
9615
|
-
}
|
|
9616
|
-
function dedupeLinkDescriptors(descriptors, preloads) {
|
|
9617
|
-
let set = /* @__PURE__ */ new Set();
|
|
9618
|
-
let preloadsSet = new Set(preloads);
|
|
9619
|
-
return descriptors.reduce((deduped, descriptor) => {
|
|
9620
|
-
let alreadyModulePreload = preloads && !isPageLinkDescriptor(descriptor) && descriptor.as === "script" && descriptor.href && preloadsSet.has(descriptor.href);
|
|
9621
|
-
if (alreadyModulePreload) {
|
|
9622
|
-
return deduped;
|
|
9623
|
-
}
|
|
9624
|
-
let key = JSON.stringify(sortKeys(descriptor));
|
|
9625
|
-
if (!set.has(key)) {
|
|
9626
|
-
set.add(key);
|
|
9627
|
-
deduped.push({ key, link: descriptor });
|
|
9628
|
-
}
|
|
9629
|
-
return deduped;
|
|
9630
|
-
}, []);
|
|
9631
|
-
}
|
|
9632
|
-
function useDataRouterContext2() {
|
|
9633
|
-
let context = React82.useContext(DataRouterContext);
|
|
9634
|
-
invariant2(
|
|
9635
|
-
context,
|
|
9636
|
-
"You must render this element inside a <DataRouterContext.Provider> element"
|
|
9637
|
-
);
|
|
9638
|
-
return context;
|
|
9639
|
-
}
|
|
9640
|
-
function useDataRouterStateContext() {
|
|
9641
|
-
let context = React82.useContext(DataRouterStateContext);
|
|
9642
|
-
invariant2(
|
|
9643
|
-
context,
|
|
9644
|
-
"You must render this element inside a <DataRouterStateContext.Provider> element"
|
|
9645
|
-
);
|
|
9646
|
-
return context;
|
|
9647
|
-
}
|
|
9648
|
-
var FrameworkContext = React82.createContext(void 0);
|
|
9649
|
-
FrameworkContext.displayName = "FrameworkContext";
|
|
9650
|
-
function useFrameworkContext() {
|
|
9651
|
-
let context = React82.useContext(FrameworkContext);
|
|
9652
|
-
invariant2(
|
|
9653
|
-
context,
|
|
9654
|
-
"You must render this element inside a <HydratedRouter> element"
|
|
9655
|
-
);
|
|
9656
|
-
return context;
|
|
9657
|
-
}
|
|
9658
|
-
function usePrefetchBehavior(prefetch, theirElementProps) {
|
|
9659
|
-
let frameworkContext = React82.useContext(FrameworkContext);
|
|
9660
|
-
let [maybePrefetch, setMaybePrefetch] = React82.useState(false);
|
|
9661
|
-
let [shouldPrefetch, setShouldPrefetch] = React82.useState(false);
|
|
9662
|
-
let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
|
|
9663
|
-
let ref = React82.useRef(null);
|
|
9664
|
-
React82.useEffect(() => {
|
|
9665
|
-
if (prefetch === "render") {
|
|
9666
|
-
setShouldPrefetch(true);
|
|
9667
|
-
}
|
|
9668
|
-
if (prefetch === "viewport") {
|
|
9669
|
-
let callback = (entries) => {
|
|
9670
|
-
entries.forEach((entry) => {
|
|
9671
|
-
setShouldPrefetch(entry.isIntersecting);
|
|
9672
|
-
});
|
|
9673
|
-
};
|
|
9674
|
-
let observer = new IntersectionObserver(callback, { threshold: 0.5 });
|
|
9675
|
-
if (ref.current) observer.observe(ref.current);
|
|
9676
|
-
return () => {
|
|
9677
|
-
observer.disconnect();
|
|
9678
|
-
};
|
|
9679
|
-
}
|
|
9680
|
-
}, [prefetch]);
|
|
9681
|
-
React82.useEffect(() => {
|
|
9682
|
-
if (maybePrefetch) {
|
|
9683
|
-
let id = setTimeout(() => {
|
|
9684
|
-
setShouldPrefetch(true);
|
|
9685
|
-
}, 100);
|
|
9686
|
-
return () => {
|
|
9687
|
-
clearTimeout(id);
|
|
9688
|
-
};
|
|
9689
|
-
}
|
|
9690
|
-
}, [maybePrefetch]);
|
|
9691
|
-
let setIntent = () => {
|
|
9692
|
-
setMaybePrefetch(true);
|
|
9693
|
-
};
|
|
9694
|
-
let cancelIntent = () => {
|
|
9695
|
-
setMaybePrefetch(false);
|
|
9696
|
-
setShouldPrefetch(false);
|
|
9697
|
-
};
|
|
9698
|
-
if (!frameworkContext) {
|
|
9699
|
-
return [false, ref, {}];
|
|
9700
|
-
}
|
|
9701
|
-
if (prefetch !== "intent") {
|
|
9702
|
-
return [shouldPrefetch, ref, {}];
|
|
9703
|
-
}
|
|
9704
|
-
return [
|
|
9705
|
-
shouldPrefetch,
|
|
9706
|
-
ref,
|
|
9707
|
-
{
|
|
9708
|
-
onFocus: composeEventHandlers(onFocus, setIntent),
|
|
9709
|
-
onBlur: composeEventHandlers(onBlur, cancelIntent),
|
|
9710
|
-
onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
|
|
9711
|
-
onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
|
|
9712
|
-
onTouchStart: composeEventHandlers(onTouchStart, setIntent)
|
|
9713
|
-
}
|
|
9714
|
-
];
|
|
9715
|
-
}
|
|
9716
|
-
function composeEventHandlers(theirHandler, ourHandler) {
|
|
9717
|
-
return (event) => {
|
|
9718
|
-
theirHandler && theirHandler(event);
|
|
9719
|
-
if (!event.defaultPrevented) {
|
|
9720
|
-
ourHandler(event);
|
|
9721
|
-
}
|
|
9722
|
-
};
|
|
9723
|
-
}
|
|
9724
|
-
function PrefetchPageLinks({ page, ...linkProps }) {
|
|
9725
|
-
let { router } = useDataRouterContext2();
|
|
9726
|
-
let matches = React82.useMemo(
|
|
9727
|
-
() => matchRoutes(router.routes, page, router.basename),
|
|
9728
|
-
[router.routes, page, router.basename]
|
|
9729
|
-
);
|
|
9730
|
-
if (!matches) {
|
|
9731
|
-
return null;
|
|
9732
|
-
}
|
|
9733
|
-
return /* @__PURE__ */ React82.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
|
|
9734
|
-
}
|
|
9735
|
-
function useKeyedPrefetchLinks(matches) {
|
|
9736
|
-
let { manifest, routeModules } = useFrameworkContext();
|
|
9737
|
-
let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React82.useState([]);
|
|
9738
|
-
React82.useEffect(() => {
|
|
9739
|
-
let interrupted = false;
|
|
9740
|
-
void getKeyedPrefetchLinks(matches, manifest, routeModules).then(
|
|
9741
|
-
(links) => {
|
|
9742
|
-
if (!interrupted) {
|
|
9743
|
-
setKeyedPrefetchLinks(links);
|
|
9744
|
-
}
|
|
9745
|
-
}
|
|
9746
|
-
);
|
|
9747
|
-
return () => {
|
|
9748
|
-
interrupted = true;
|
|
9749
|
-
};
|
|
9750
|
-
}, [matches, manifest, routeModules]);
|
|
9751
|
-
return keyedPrefetchLinks;
|
|
9752
|
-
}
|
|
9753
|
-
function PrefetchPageLinksImpl({
|
|
9754
|
-
page,
|
|
9755
|
-
matches: nextMatches,
|
|
9756
|
-
...linkProps
|
|
9757
|
-
}) {
|
|
9758
|
-
let location = useLocation3();
|
|
9759
|
-
let { future, manifest, routeModules } = useFrameworkContext();
|
|
9760
|
-
let { basename } = useDataRouterContext2();
|
|
9761
|
-
let { loaderData, matches } = useDataRouterStateContext();
|
|
9762
|
-
let newMatchesForData = React82.useMemo(
|
|
9763
|
-
() => getNewMatchesForLinks(
|
|
9764
|
-
page,
|
|
9765
|
-
nextMatches,
|
|
9766
|
-
matches,
|
|
9767
|
-
manifest,
|
|
9768
|
-
location,
|
|
9769
|
-
"data"
|
|
9770
|
-
),
|
|
9771
|
-
[page, nextMatches, matches, manifest, location]
|
|
9772
|
-
);
|
|
9773
|
-
let newMatchesForAssets = React82.useMemo(
|
|
9774
|
-
() => getNewMatchesForLinks(
|
|
9775
|
-
page,
|
|
9776
|
-
nextMatches,
|
|
9777
|
-
matches,
|
|
9778
|
-
manifest,
|
|
9779
|
-
location,
|
|
9780
|
-
"assets"
|
|
9781
|
-
),
|
|
9782
|
-
[page, nextMatches, matches, manifest, location]
|
|
9783
|
-
);
|
|
9784
|
-
let dataHrefs = React82.useMemo(() => {
|
|
9785
|
-
if (page === location.pathname + location.search + location.hash) {
|
|
9786
|
-
return [];
|
|
9787
|
-
}
|
|
9788
|
-
let routesParams = /* @__PURE__ */ new Set();
|
|
9789
|
-
let foundOptOutRoute = false;
|
|
9790
|
-
nextMatches.forEach((m) => {
|
|
9791
|
-
let manifestRoute = manifest.routes[m.route.id];
|
|
9792
|
-
if (!manifestRoute || !manifestRoute.hasLoader) {
|
|
9793
|
-
return;
|
|
9794
|
-
}
|
|
9795
|
-
if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && routeModules[m.route.id]?.shouldRevalidate) {
|
|
9796
|
-
foundOptOutRoute = true;
|
|
9797
|
-
} else if (manifestRoute.hasClientLoader) {
|
|
9798
|
-
foundOptOutRoute = true;
|
|
9799
|
-
} else {
|
|
9800
|
-
routesParams.add(m.route.id);
|
|
9801
|
-
}
|
|
9802
|
-
});
|
|
9803
|
-
if (routesParams.size === 0) {
|
|
9804
|
-
return [];
|
|
9805
|
-
}
|
|
9806
|
-
let url = singleFetchUrl(
|
|
9807
|
-
page,
|
|
9808
|
-
basename,
|
|
9809
|
-
future.unstable_trailingSlashAwareDataRequests,
|
|
9810
|
-
"data"
|
|
9811
|
-
);
|
|
9812
|
-
if (foundOptOutRoute && routesParams.size > 0) {
|
|
9813
|
-
url.searchParams.set(
|
|
9814
|
-
"_routes",
|
|
9815
|
-
nextMatches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
|
|
9816
|
-
);
|
|
9817
|
-
}
|
|
9818
|
-
return [url.pathname + url.search];
|
|
9819
|
-
}, [
|
|
9820
|
-
basename,
|
|
9821
|
-
future.unstable_trailingSlashAwareDataRequests,
|
|
9822
|
-
loaderData,
|
|
9823
|
-
location,
|
|
9824
|
-
manifest,
|
|
9825
|
-
newMatchesForData,
|
|
9826
|
-
nextMatches,
|
|
9827
|
-
page,
|
|
9828
|
-
routeModules
|
|
9829
|
-
]);
|
|
9830
|
-
let moduleHrefs = React82.useMemo(
|
|
9831
|
-
() => getModuleLinkHrefs(newMatchesForAssets, manifest),
|
|
9832
|
-
[newMatchesForAssets, manifest]
|
|
9833
|
-
);
|
|
9834
|
-
let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
|
|
9835
|
-
return /* @__PURE__ */ React82.createElement(React82.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React82.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })), moduleHrefs.map((href) => /* @__PURE__ */ React82.createElement("link", { key: href, rel: "modulepreload", href, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
|
|
9836
|
-
// these don't spread `linkProps` because they are full link descriptors
|
|
9837
|
-
// already with their own props
|
|
9838
|
-
/* @__PURE__ */ React82.createElement(
|
|
9839
|
-
"link",
|
|
9840
|
-
{
|
|
9841
|
-
key,
|
|
9842
|
-
nonce: linkProps.nonce,
|
|
9843
|
-
...link,
|
|
9844
|
-
crossOrigin: link.crossOrigin ?? linkProps.crossOrigin
|
|
9845
|
-
}
|
|
9846
|
-
)
|
|
9847
|
-
)));
|
|
9848
|
-
}
|
|
9849
|
-
function mergeRefs(...refs) {
|
|
9850
|
-
return (value) => {
|
|
9851
|
-
refs.forEach((ref) => {
|
|
9852
|
-
if (typeof ref === "function") {
|
|
9853
|
-
ref(value);
|
|
9854
|
-
} else if (ref != null) {
|
|
9855
|
-
ref.current = value;
|
|
9856
|
-
}
|
|
9857
|
-
});
|
|
9858
|
-
};
|
|
9859
|
-
}
|
|
9860
|
-
var isBrowser22 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
9861
|
-
try {
|
|
9862
|
-
if (isBrowser22) {
|
|
9863
|
-
window.__reactRouterVersion = // @ts-expect-error
|
|
9864
|
-
"7.13.1";
|
|
9865
|
-
}
|
|
9866
|
-
} catch (e) {
|
|
9867
|
-
}
|
|
9868
|
-
function HistoryRouter({
|
|
9869
|
-
basename,
|
|
9870
|
-
children,
|
|
9871
|
-
history,
|
|
9872
|
-
unstable_useTransitions
|
|
9873
|
-
}) {
|
|
9874
|
-
let [state, setStateImpl] = React102.useState({
|
|
9875
|
-
action: history.action,
|
|
9876
|
-
location: history.location
|
|
9877
|
-
});
|
|
9878
|
-
let setState = React102.useCallback(
|
|
9879
|
-
(newState) => {
|
|
9880
|
-
if (unstable_useTransitions === false) {
|
|
9881
|
-
setStateImpl(newState);
|
|
9882
|
-
} else {
|
|
9883
|
-
React102.startTransition(() => setStateImpl(newState));
|
|
9884
|
-
}
|
|
9885
|
-
},
|
|
9886
|
-
[unstable_useTransitions]
|
|
9887
|
-
);
|
|
9888
|
-
React102.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
9889
|
-
return /* @__PURE__ */ React102.createElement(
|
|
9890
|
-
Router,
|
|
9891
|
-
{
|
|
9892
|
-
basename,
|
|
9893
|
-
children,
|
|
9894
|
-
location: state.location,
|
|
9895
|
-
navigationType: state.action,
|
|
9896
|
-
navigator: history,
|
|
9897
|
-
unstable_useTransitions
|
|
9898
|
-
}
|
|
9899
|
-
);
|
|
9900
|
-
}
|
|
9901
|
-
HistoryRouter.displayName = "unstable_HistoryRouter";
|
|
9902
|
-
var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
9903
|
-
var Link = React102.forwardRef(
|
|
9904
|
-
function LinkWithRef({
|
|
9905
|
-
onClick,
|
|
9906
|
-
discover = "render",
|
|
9907
|
-
prefetch = "none",
|
|
9908
|
-
relative,
|
|
9909
|
-
reloadDocument,
|
|
9910
|
-
replace: replace2,
|
|
9911
|
-
unstable_mask,
|
|
9912
|
-
state,
|
|
9913
|
-
target,
|
|
9914
|
-
to,
|
|
9915
|
-
preventScrollReset,
|
|
9916
|
-
viewTransition,
|
|
9917
|
-
unstable_defaultShouldRevalidate,
|
|
9918
|
-
...rest
|
|
9919
|
-
}, forwardedRef) {
|
|
9920
|
-
let { basename, navigator: navigator2, unstable_useTransitions } = React102.useContext(NavigationContext);
|
|
9921
|
-
let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
|
|
9922
|
-
let parsed = parseToInfo(to, basename);
|
|
9923
|
-
to = parsed.to;
|
|
9924
|
-
let href = useHref(to, { relative });
|
|
9925
|
-
let location = useLocation3();
|
|
9926
|
-
let maskedHref = null;
|
|
9927
|
-
if (unstable_mask) {
|
|
9928
|
-
let resolved = resolveTo(
|
|
9929
|
-
unstable_mask,
|
|
9930
|
-
[],
|
|
9931
|
-
location.unstable_mask ? location.unstable_mask.pathname : "/",
|
|
9932
|
-
true
|
|
9933
|
-
);
|
|
9934
|
-
if (basename !== "/") {
|
|
9935
|
-
resolved.pathname = resolved.pathname === "/" ? basename : joinPaths([basename, resolved.pathname]);
|
|
9936
|
-
}
|
|
9937
|
-
maskedHref = navigator2.createHref(resolved);
|
|
9938
|
-
}
|
|
9939
|
-
let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(
|
|
9940
|
-
prefetch,
|
|
9941
|
-
rest
|
|
9942
|
-
);
|
|
9943
|
-
let internalOnClick = useLinkClickHandler(to, {
|
|
9944
|
-
replace: replace2,
|
|
9945
|
-
unstable_mask,
|
|
9946
|
-
state,
|
|
9947
|
-
target,
|
|
9948
|
-
preventScrollReset,
|
|
9949
|
-
relative,
|
|
9950
|
-
viewTransition,
|
|
9951
|
-
unstable_defaultShouldRevalidate,
|
|
9952
|
-
unstable_useTransitions
|
|
9953
|
-
});
|
|
9954
|
-
function handleClick(event) {
|
|
9955
|
-
if (onClick) onClick(event);
|
|
9956
|
-
if (!event.defaultPrevented) {
|
|
9957
|
-
internalOnClick(event);
|
|
9958
|
-
}
|
|
9959
|
-
}
|
|
9960
|
-
let isSpaLink = !(parsed.isExternal || reloadDocument);
|
|
9961
|
-
let link = (
|
|
9962
|
-
// eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
9963
|
-
/* @__PURE__ */ React102.createElement(
|
|
9964
|
-
"a",
|
|
9965
|
-
{
|
|
9966
|
-
...rest,
|
|
9967
|
-
...prefetchHandlers,
|
|
9968
|
-
href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
|
|
9969
|
-
onClick: isSpaLink ? handleClick : onClick,
|
|
9970
|
-
ref: mergeRefs(forwardedRef, prefetchRef),
|
|
9971
|
-
target,
|
|
9972
|
-
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
|
9973
|
-
}
|
|
9974
|
-
)
|
|
9975
|
-
);
|
|
9976
|
-
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React102.createElement(React102.Fragment, null, link, /* @__PURE__ */ React102.createElement(PrefetchPageLinks, { page: href })) : link;
|
|
9977
|
-
}
|
|
9978
|
-
);
|
|
9979
|
-
Link.displayName = "Link";
|
|
9980
|
-
var NavLink = React102.forwardRef(
|
|
9981
|
-
function NavLinkWithRef({
|
|
9982
|
-
"aria-current": ariaCurrentProp = "page",
|
|
9983
|
-
caseSensitive = false,
|
|
9984
|
-
className: classNameProp = "",
|
|
9985
|
-
end = false,
|
|
9986
|
-
style: styleProp,
|
|
9987
|
-
to,
|
|
9988
|
-
viewTransition,
|
|
9989
|
-
children,
|
|
9990
|
-
...rest
|
|
9991
|
-
}, ref) {
|
|
9992
|
-
let path = useResolvedPath(to, { relative: rest.relative });
|
|
9993
|
-
let location = useLocation3();
|
|
9994
|
-
let routerState = React102.useContext(DataRouterStateContext);
|
|
9995
|
-
let { navigator: navigator2, basename } = React102.useContext(NavigationContext);
|
|
9996
|
-
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
|
|
9997
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
9998
|
-
useViewTransitionState(path) && viewTransition === true;
|
|
9999
|
-
let toPathname = navigator2.encodeLocation ? navigator2.encodeLocation(path).pathname : path.pathname;
|
|
10000
|
-
let locationPathname = location.pathname;
|
|
10001
|
-
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
|
|
10002
|
-
if (!caseSensitive) {
|
|
10003
|
-
locationPathname = locationPathname.toLowerCase();
|
|
10004
|
-
nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
|
|
10005
|
-
toPathname = toPathname.toLowerCase();
|
|
10006
|
-
}
|
|
10007
|
-
if (nextLocationPathname && basename) {
|
|
10008
|
-
nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
|
|
10009
|
-
}
|
|
10010
|
-
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
|
|
10011
|
-
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
|
|
10012
|
-
let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
|
|
10013
|
-
let renderProps = {
|
|
10014
|
-
isActive,
|
|
10015
|
-
isPending,
|
|
10016
|
-
isTransitioning
|
|
10017
|
-
};
|
|
10018
|
-
let ariaCurrent = isActive ? ariaCurrentProp : void 0;
|
|
10019
|
-
let className;
|
|
10020
|
-
if (typeof classNameProp === "function") {
|
|
10021
|
-
className = classNameProp(renderProps);
|
|
10022
|
-
} else {
|
|
10023
|
-
className = [
|
|
10024
|
-
classNameProp,
|
|
10025
|
-
isActive ? "active" : null,
|
|
10026
|
-
isPending ? "pending" : null,
|
|
10027
|
-
isTransitioning ? "transitioning" : null
|
|
10028
|
-
].filter(Boolean).join(" ");
|
|
10029
|
-
}
|
|
10030
|
-
let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
|
|
10031
|
-
return /* @__PURE__ */ React102.createElement(
|
|
10032
|
-
Link,
|
|
10033
|
-
{
|
|
10034
|
-
...rest,
|
|
10035
|
-
"aria-current": ariaCurrent,
|
|
10036
|
-
className,
|
|
10037
|
-
ref,
|
|
10038
|
-
style,
|
|
10039
|
-
to,
|
|
10040
|
-
viewTransition
|
|
10041
|
-
},
|
|
10042
|
-
typeof children === "function" ? children(renderProps) : children
|
|
10043
|
-
);
|
|
10044
|
-
}
|
|
10045
|
-
);
|
|
10046
|
-
NavLink.displayName = "NavLink";
|
|
10047
|
-
var Form = React102.forwardRef(
|
|
10048
|
-
({
|
|
10049
|
-
discover = "render",
|
|
10050
|
-
fetcherKey,
|
|
10051
|
-
navigate,
|
|
10052
|
-
reloadDocument,
|
|
10053
|
-
replace: replace2,
|
|
10054
|
-
state,
|
|
10055
|
-
method = defaultMethod,
|
|
10056
|
-
action,
|
|
10057
|
-
onSubmit,
|
|
10058
|
-
relative,
|
|
10059
|
-
preventScrollReset,
|
|
10060
|
-
viewTransition,
|
|
10061
|
-
unstable_defaultShouldRevalidate,
|
|
10062
|
-
...props
|
|
10063
|
-
}, forwardedRef) => {
|
|
10064
|
-
let { unstable_useTransitions } = React102.useContext(NavigationContext);
|
|
10065
|
-
let submit = useSubmit();
|
|
10066
|
-
let formAction = useFormAction(action, { relative });
|
|
10067
|
-
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
|
|
10068
|
-
let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
|
|
10069
|
-
let submitHandler = (event) => {
|
|
10070
|
-
onSubmit && onSubmit(event);
|
|
10071
|
-
if (event.defaultPrevented) return;
|
|
10072
|
-
event.preventDefault();
|
|
10073
|
-
let submitter = event.nativeEvent.submitter;
|
|
10074
|
-
let submitMethod = submitter?.getAttribute("formmethod") || method;
|
|
10075
|
-
let doSubmit = () => submit(submitter || event.currentTarget, {
|
|
10076
|
-
fetcherKey,
|
|
10077
|
-
method: submitMethod,
|
|
10078
|
-
navigate,
|
|
10079
|
-
replace: replace2,
|
|
10080
|
-
state,
|
|
10081
|
-
relative,
|
|
10082
|
-
preventScrollReset,
|
|
10083
|
-
viewTransition,
|
|
10084
|
-
unstable_defaultShouldRevalidate
|
|
10085
|
-
});
|
|
10086
|
-
if (unstable_useTransitions && navigate !== false) {
|
|
10087
|
-
React102.startTransition(() => doSubmit());
|
|
10088
|
-
} else {
|
|
10089
|
-
doSubmit();
|
|
10090
|
-
}
|
|
10091
|
-
};
|
|
10092
|
-
return /* @__PURE__ */ React102.createElement(
|
|
10093
|
-
"form",
|
|
10094
|
-
{
|
|
10095
|
-
ref: forwardedRef,
|
|
10096
|
-
method: formMethod,
|
|
10097
|
-
action: formAction,
|
|
10098
|
-
onSubmit: reloadDocument ? onSubmit : submitHandler,
|
|
10099
|
-
...props,
|
|
10100
|
-
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
|
10101
|
-
}
|
|
10102
|
-
);
|
|
10103
|
-
}
|
|
10104
|
-
);
|
|
10105
|
-
Form.displayName = "Form";
|
|
10106
|
-
function ScrollRestoration({
|
|
10107
|
-
getKey,
|
|
10108
|
-
storageKey,
|
|
10109
|
-
...props
|
|
10110
|
-
}) {
|
|
10111
|
-
let remixContext = React102.useContext(FrameworkContext);
|
|
10112
|
-
let { basename } = React102.useContext(NavigationContext);
|
|
10113
|
-
let location = useLocation3();
|
|
10114
|
-
let matches = useMatches();
|
|
10115
|
-
useScrollRestoration({ getKey, storageKey });
|
|
10116
|
-
let ssrKey = React102.useMemo(
|
|
10117
|
-
() => {
|
|
10118
|
-
if (!remixContext || !getKey) return null;
|
|
10119
|
-
let userKey = getScrollRestorationKey(
|
|
10120
|
-
location,
|
|
10121
|
-
matches,
|
|
10122
|
-
basename,
|
|
10123
|
-
getKey
|
|
10124
|
-
);
|
|
10125
|
-
return userKey !== location.key ? userKey : null;
|
|
10126
|
-
},
|
|
10127
|
-
// Nah, we only need this the first time for the SSR render
|
|
10128
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10129
|
-
[]
|
|
10130
|
-
);
|
|
10131
|
-
if (!remixContext || remixContext.isSpaMode) {
|
|
10132
|
-
return null;
|
|
10133
|
-
}
|
|
10134
|
-
let restoreScroll = ((storageKey2, restoreKey) => {
|
|
10135
|
-
if (!window.history.state || !window.history.state.key) {
|
|
10136
|
-
let key = Math.random().toString(32).slice(2);
|
|
10137
|
-
window.history.replaceState({ key }, "");
|
|
10138
|
-
}
|
|
10139
|
-
try {
|
|
10140
|
-
let positions = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
|
|
10141
|
-
let storedY = positions[restoreKey || window.history.state.key];
|
|
10142
|
-
if (typeof storedY === "number") {
|
|
10143
|
-
window.scrollTo(0, storedY);
|
|
10144
|
-
}
|
|
10145
|
-
} catch (error) {
|
|
10146
|
-
console.error(error);
|
|
10147
|
-
sessionStorage.removeItem(storageKey2);
|
|
10148
|
-
}
|
|
10149
|
-
}).toString();
|
|
10150
|
-
return /* @__PURE__ */ React102.createElement(
|
|
10151
|
-
"script",
|
|
10152
|
-
{
|
|
10153
|
-
...props,
|
|
10154
|
-
suppressHydrationWarning: true,
|
|
10155
|
-
dangerouslySetInnerHTML: {
|
|
10156
|
-
__html: `(${restoreScroll})(${escapeHtml(
|
|
10157
|
-
JSON.stringify(storageKey || SCROLL_RESTORATION_STORAGE_KEY)
|
|
10158
|
-
)}, ${escapeHtml(JSON.stringify(ssrKey))})`
|
|
10159
|
-
}
|
|
10160
|
-
}
|
|
10161
|
-
);
|
|
10162
|
-
}
|
|
10163
|
-
ScrollRestoration.displayName = "ScrollRestoration";
|
|
10164
|
-
function getDataRouterConsoleError2(hookName) {
|
|
10165
|
-
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
|
10166
|
-
}
|
|
10167
|
-
function useDataRouterContext3(hookName) {
|
|
10168
|
-
let ctx = React102.useContext(DataRouterContext);
|
|
10169
|
-
invariant(ctx, getDataRouterConsoleError2(hookName));
|
|
10170
|
-
return ctx;
|
|
10171
|
-
}
|
|
10172
|
-
function useDataRouterState2(hookName) {
|
|
10173
|
-
let state = React102.useContext(DataRouterStateContext);
|
|
10174
|
-
invariant(state, getDataRouterConsoleError2(hookName));
|
|
10175
|
-
return state;
|
|
10176
|
-
}
|
|
10177
|
-
function useLinkClickHandler(to, {
|
|
10178
|
-
target,
|
|
10179
|
-
replace: replaceProp,
|
|
10180
|
-
unstable_mask,
|
|
10181
|
-
state,
|
|
10182
|
-
preventScrollReset,
|
|
10183
|
-
relative,
|
|
10184
|
-
viewTransition,
|
|
10185
|
-
unstable_defaultShouldRevalidate,
|
|
10186
|
-
unstable_useTransitions
|
|
10187
|
-
} = {}) {
|
|
10188
|
-
let navigate = useNavigate5();
|
|
10189
|
-
let location = useLocation3();
|
|
10190
|
-
let path = useResolvedPath(to, { relative });
|
|
10191
|
-
return React102.useCallback(
|
|
10192
|
-
(event) => {
|
|
10193
|
-
if (shouldProcessLinkClick(event, target)) {
|
|
10194
|
-
event.preventDefault();
|
|
10195
|
-
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
|
|
10196
|
-
let doNavigate = () => navigate(to, {
|
|
10197
|
-
replace: replace2,
|
|
10198
|
-
unstable_mask,
|
|
10199
|
-
state,
|
|
10200
|
-
preventScrollReset,
|
|
10201
|
-
relative,
|
|
10202
|
-
viewTransition,
|
|
10203
|
-
unstable_defaultShouldRevalidate
|
|
10204
|
-
});
|
|
10205
|
-
if (unstable_useTransitions) {
|
|
10206
|
-
React102.startTransition(() => doNavigate());
|
|
10207
|
-
} else {
|
|
10208
|
-
doNavigate();
|
|
10209
|
-
}
|
|
10210
|
-
}
|
|
10211
|
-
},
|
|
10212
|
-
[
|
|
10213
|
-
location,
|
|
10214
|
-
navigate,
|
|
10215
|
-
path,
|
|
10216
|
-
replaceProp,
|
|
10217
|
-
unstable_mask,
|
|
10218
|
-
state,
|
|
10219
|
-
target,
|
|
10220
|
-
to,
|
|
10221
|
-
preventScrollReset,
|
|
10222
|
-
relative,
|
|
10223
|
-
viewTransition,
|
|
10224
|
-
unstable_defaultShouldRevalidate,
|
|
10225
|
-
unstable_useTransitions
|
|
10226
|
-
]
|
|
10227
|
-
);
|
|
10228
|
-
}
|
|
10229
|
-
function useSearchParams(defaultInit) {
|
|
10230
|
-
warning3(
|
|
10231
|
-
typeof URLSearchParams !== "undefined",
|
|
10232
|
-
`You cannot use the \`useSearchParams\` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.`
|
|
10233
|
-
);
|
|
10234
|
-
let defaultSearchParamsRef = React102.useRef(createSearchParams(defaultInit));
|
|
10235
|
-
let hasSetSearchParamsRef = React102.useRef(false);
|
|
10236
|
-
let location = useLocation3();
|
|
10237
|
-
let searchParams = React102.useMemo(
|
|
10238
|
-
() => (
|
|
10239
|
-
// Only merge in the defaults if we haven't yet called setSearchParams.
|
|
10240
|
-
// Once we call that we want those to take precedence, otherwise you can't
|
|
10241
|
-
// remove a param with setSearchParams({}) if it has an initial value
|
|
10242
|
-
getSearchParamsForLocation(
|
|
10243
|
-
location.search,
|
|
10244
|
-
hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
|
|
10245
|
-
)
|
|
10246
|
-
),
|
|
10247
|
-
[location.search]
|
|
10248
|
-
);
|
|
10249
|
-
let navigate = useNavigate5();
|
|
10250
|
-
let setSearchParams = React102.useCallback(
|
|
10251
|
-
(nextInit, navigateOptions) => {
|
|
10252
|
-
const newSearchParams = createSearchParams(
|
|
10253
|
-
typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit
|
|
10254
|
-
);
|
|
10255
|
-
hasSetSearchParamsRef.current = true;
|
|
10256
|
-
navigate("?" + newSearchParams, navigateOptions);
|
|
10257
|
-
},
|
|
10258
|
-
[navigate, searchParams]
|
|
10259
|
-
);
|
|
10260
|
-
return [searchParams, setSearchParams];
|
|
10261
|
-
}
|
|
10262
|
-
var fetcherId = 0;
|
|
10263
|
-
var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
|
|
10264
|
-
function useSubmit() {
|
|
10265
|
-
let { router } = useDataRouterContext3(
|
|
10266
|
-
"useSubmit"
|
|
10267
|
-
/* UseSubmit */
|
|
10268
|
-
);
|
|
10269
|
-
let { basename } = React102.useContext(NavigationContext);
|
|
10270
|
-
let currentRouteId = useRouteId();
|
|
10271
|
-
let routerFetch = router.fetch;
|
|
10272
|
-
let routerNavigate = router.navigate;
|
|
10273
|
-
return React102.useCallback(
|
|
10274
|
-
async (target, options = {}) => {
|
|
10275
|
-
let { action, method, encType, formData, body } = getFormSubmissionInfo(
|
|
10276
|
-
target,
|
|
10277
|
-
basename
|
|
10278
|
-
);
|
|
10279
|
-
if (options.navigate === false) {
|
|
10280
|
-
let key = options.fetcherKey || getUniqueFetcherId();
|
|
10281
|
-
await routerFetch(key, currentRouteId, options.action || action, {
|
|
10282
|
-
unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
|
|
10283
|
-
preventScrollReset: options.preventScrollReset,
|
|
10284
|
-
formData,
|
|
10285
|
-
body,
|
|
10286
|
-
formMethod: options.method || method,
|
|
10287
|
-
formEncType: options.encType || encType,
|
|
10288
|
-
flushSync: options.flushSync
|
|
10289
|
-
});
|
|
10290
|
-
} else {
|
|
10291
|
-
await routerNavigate(options.action || action, {
|
|
10292
|
-
unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
|
|
10293
|
-
preventScrollReset: options.preventScrollReset,
|
|
10294
|
-
formData,
|
|
10295
|
-
body,
|
|
10296
|
-
formMethod: options.method || method,
|
|
10297
|
-
formEncType: options.encType || encType,
|
|
10298
|
-
replace: options.replace,
|
|
10299
|
-
state: options.state,
|
|
10300
|
-
fromRouteId: currentRouteId,
|
|
10301
|
-
flushSync: options.flushSync,
|
|
10302
|
-
viewTransition: options.viewTransition
|
|
10303
|
-
});
|
|
10304
|
-
}
|
|
10305
|
-
},
|
|
10306
|
-
[routerFetch, routerNavigate, basename, currentRouteId]
|
|
10307
|
-
);
|
|
10308
|
-
}
|
|
10309
|
-
function useFormAction(action, { relative } = {}) {
|
|
10310
|
-
let { basename } = React102.useContext(NavigationContext);
|
|
10311
|
-
let routeContext = React102.useContext(RouteContext);
|
|
10312
|
-
invariant(routeContext, "useFormAction must be used inside a RouteContext");
|
|
10313
|
-
let [match] = routeContext.matches.slice(-1);
|
|
10314
|
-
let path = { ...useResolvedPath(action ? action : ".", { relative }) };
|
|
10315
|
-
let location = useLocation3();
|
|
10316
|
-
if (action == null) {
|
|
10317
|
-
path.search = location.search;
|
|
10318
|
-
let params = new URLSearchParams(path.search);
|
|
10319
|
-
let indexValues = params.getAll("index");
|
|
10320
|
-
let hasNakedIndexParam = indexValues.some((v) => v === "");
|
|
10321
|
-
if (hasNakedIndexParam) {
|
|
10322
|
-
params.delete("index");
|
|
10323
|
-
indexValues.filter((v) => v).forEach((v) => params.append("index", v));
|
|
10324
|
-
let qs = params.toString();
|
|
10325
|
-
path.search = qs ? `?${qs}` : "";
|
|
10326
|
-
}
|
|
10327
|
-
}
|
|
10328
|
-
if ((!action || action === ".") && match.route.index) {
|
|
10329
|
-
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
|
|
10330
|
-
}
|
|
10331
|
-
if (basename !== "/") {
|
|
10332
|
-
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
|
|
10333
|
-
}
|
|
10334
|
-
return createPath(path);
|
|
10335
|
-
}
|
|
10336
|
-
var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
|
|
10337
|
-
var savedScrollPositions = {};
|
|
10338
|
-
function getScrollRestorationKey(location, matches, basename, getKey) {
|
|
10339
|
-
let key = null;
|
|
10340
|
-
if (getKey) {
|
|
10341
|
-
if (basename !== "/") {
|
|
10342
|
-
key = getKey(
|
|
10343
|
-
{
|
|
10344
|
-
...location,
|
|
10345
|
-
pathname: stripBasename(location.pathname, basename) || location.pathname
|
|
10346
|
-
},
|
|
10347
|
-
matches
|
|
10348
|
-
);
|
|
10349
|
-
} else {
|
|
10350
|
-
key = getKey(location, matches);
|
|
10351
|
-
}
|
|
10352
|
-
}
|
|
10353
|
-
if (key == null) {
|
|
10354
|
-
key = location.key;
|
|
10355
|
-
}
|
|
10356
|
-
return key;
|
|
10357
|
-
}
|
|
10358
|
-
function useScrollRestoration({
|
|
10359
|
-
getKey,
|
|
10360
|
-
storageKey
|
|
10361
|
-
} = {}) {
|
|
10362
|
-
let { router } = useDataRouterContext3(
|
|
10363
|
-
"useScrollRestoration"
|
|
10364
|
-
/* UseScrollRestoration */
|
|
10365
|
-
);
|
|
10366
|
-
let { restoreScrollPosition, preventScrollReset } = useDataRouterState2(
|
|
10367
|
-
"useScrollRestoration"
|
|
10368
|
-
/* UseScrollRestoration */
|
|
10369
|
-
);
|
|
10370
|
-
let { basename } = React102.useContext(NavigationContext);
|
|
10371
|
-
let location = useLocation3();
|
|
10372
|
-
let matches = useMatches();
|
|
10373
|
-
let navigation = useNavigation();
|
|
10374
|
-
React102.useEffect(() => {
|
|
10375
|
-
window.history.scrollRestoration = "manual";
|
|
10376
|
-
return () => {
|
|
10377
|
-
window.history.scrollRestoration = "auto";
|
|
10378
|
-
};
|
|
10379
|
-
}, []);
|
|
10380
|
-
usePageHide(
|
|
10381
|
-
React102.useCallback(() => {
|
|
10382
|
-
if (navigation.state === "idle") {
|
|
10383
|
-
let key = getScrollRestorationKey(location, matches, basename, getKey);
|
|
10384
|
-
savedScrollPositions[key] = window.scrollY;
|
|
10385
|
-
}
|
|
10386
|
-
try {
|
|
10387
|
-
sessionStorage.setItem(
|
|
10388
|
-
storageKey || SCROLL_RESTORATION_STORAGE_KEY,
|
|
10389
|
-
JSON.stringify(savedScrollPositions)
|
|
10390
|
-
);
|
|
10391
|
-
} catch (error) {
|
|
10392
|
-
warning3(
|
|
10393
|
-
false,
|
|
10394
|
-
`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
|
|
10395
|
-
);
|
|
10396
|
-
}
|
|
10397
|
-
window.history.scrollRestoration = "auto";
|
|
10398
|
-
}, [navigation.state, getKey, basename, location, matches, storageKey])
|
|
10399
|
-
);
|
|
10400
|
-
if (typeof document !== "undefined") {
|
|
10401
|
-
React102.useLayoutEffect(() => {
|
|
10402
|
-
try {
|
|
10403
|
-
let sessionPositions = sessionStorage.getItem(
|
|
10404
|
-
storageKey || SCROLL_RESTORATION_STORAGE_KEY
|
|
10405
|
-
);
|
|
10406
|
-
if (sessionPositions) {
|
|
10407
|
-
savedScrollPositions = JSON.parse(sessionPositions);
|
|
10408
|
-
}
|
|
10409
|
-
} catch (e) {
|
|
10410
|
-
}
|
|
10411
|
-
}, [storageKey]);
|
|
10412
|
-
React102.useLayoutEffect(() => {
|
|
10413
|
-
let disableScrollRestoration = router?.enableScrollRestoration(
|
|
10414
|
-
savedScrollPositions,
|
|
10415
|
-
() => window.scrollY,
|
|
10416
|
-
getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
|
|
10417
|
-
);
|
|
10418
|
-
return () => disableScrollRestoration && disableScrollRestoration();
|
|
10419
|
-
}, [router, basename, getKey]);
|
|
10420
|
-
React102.useLayoutEffect(() => {
|
|
10421
|
-
if (restoreScrollPosition === false) {
|
|
10422
|
-
return;
|
|
10423
|
-
}
|
|
10424
|
-
if (typeof restoreScrollPosition === "number") {
|
|
10425
|
-
window.scrollTo(0, restoreScrollPosition);
|
|
10426
|
-
return;
|
|
10427
|
-
}
|
|
10428
|
-
try {
|
|
10429
|
-
if (location.hash) {
|
|
10430
|
-
let el = document.getElementById(
|
|
10431
|
-
decodeURIComponent(location.hash.slice(1))
|
|
10432
|
-
);
|
|
10433
|
-
if (el) {
|
|
10434
|
-
el.scrollIntoView();
|
|
10435
|
-
return;
|
|
10436
|
-
}
|
|
10437
|
-
}
|
|
10438
|
-
} catch {
|
|
10439
|
-
warning3(
|
|
10440
|
-
false,
|
|
10441
|
-
`"${location.hash.slice(
|
|
10442
|
-
1
|
|
10443
|
-
)}" is not a decodable element ID. The view will not scroll to it.`
|
|
10444
|
-
);
|
|
10445
|
-
}
|
|
10446
|
-
if (preventScrollReset === true) {
|
|
10447
|
-
return;
|
|
10448
|
-
}
|
|
10449
|
-
window.scrollTo(0, 0);
|
|
10450
|
-
}, [location, restoreScrollPosition, preventScrollReset]);
|
|
10451
|
-
}
|
|
10452
|
-
}
|
|
10453
|
-
function usePageHide(callback, options) {
|
|
10454
|
-
let { capture } = options || {};
|
|
10455
|
-
React102.useEffect(() => {
|
|
10456
|
-
let opts = capture != null ? { capture } : void 0;
|
|
10457
|
-
window.addEventListener("pagehide", callback, opts);
|
|
10458
|
-
return () => {
|
|
10459
|
-
window.removeEventListener("pagehide", callback, opts);
|
|
10460
|
-
};
|
|
10461
|
-
}, [callback, capture]);
|
|
10462
|
-
}
|
|
10463
|
-
function useViewTransitionState(to, { relative } = {}) {
|
|
10464
|
-
let vtContext = React102.useContext(ViewTransitionContext);
|
|
10465
|
-
invariant(
|
|
10466
|
-
vtContext != null,
|
|
10467
|
-
"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
|
|
10468
|
-
);
|
|
10469
|
-
let { basename } = useDataRouterContext3(
|
|
10470
|
-
"useViewTransitionState"
|
|
10471
|
-
/* useViewTransitionState */
|
|
10472
|
-
);
|
|
10473
|
-
let path = useResolvedPath(to, { relative });
|
|
10474
|
-
if (!vtContext.isTransitioning) {
|
|
10475
|
-
return false;
|
|
10476
|
-
}
|
|
10477
|
-
let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
|
|
10478
|
-
let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
|
|
10479
|
-
return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
|
|
10480
|
-
}
|
|
10481
|
-
|
|
10482
|
-
// src/hooks/useApp.tsx
|
|
10483
|
-
var useApp = () => {
|
|
10484
|
-
const [searchParams] = useSearchParams();
|
|
10485
|
-
const navigate = useNavigate5();
|
|
10486
|
-
const getParams = (key) => {
|
|
10487
|
-
const params = useParams2();
|
|
10488
|
-
if (key) return params[key];
|
|
10489
|
-
return params;
|
|
10490
|
-
};
|
|
10491
|
-
const getQuery = (key) => {
|
|
10492
|
-
if (key) return searchParams.get(key);
|
|
10493
|
-
return Object.fromEntries(searchParams.entries());
|
|
10494
|
-
};
|
|
10495
|
-
return {
|
|
10496
|
-
navigate,
|
|
10497
|
-
getQuery,
|
|
10498
|
-
getParams
|
|
10499
|
-
};
|
|
10500
|
-
};
|
|
10501
|
-
var useApp_default = useApp;
|
|
10502
|
-
|
|
10503
|
-
// src/utils/Enums.ts
|
|
10504
|
-
var Enums = {
|
|
10505
|
-
roles: ["admin", "staff"],
|
|
10506
|
-
sex: ["male", "female"],
|
|
10507
|
-
accountTypes: ["employee", "supplier", "customer", "investor"],
|
|
10508
|
-
verificationTypes: ["email_verification", "password_reset"],
|
|
10509
|
-
auditActions: ["create", "update", "delete", "login", "logout"]
|
|
10510
|
-
};
|
|
10511
|
-
var Enums_default = Enums;
|
|
10512
|
-
|
|
10513
|
-
// src/components/accounts/schema.tsx
|
|
10514
|
-
import { z as z2 } from "zod";
|
|
10515
|
-
var createAccountSchema = z2.object({
|
|
10516
|
-
name: z2.string().min(2, { message: "Name must be at least 2 characters" }),
|
|
10517
|
-
email: z2.string().optional().refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
|
|
10518
|
-
message: "Please enter a valid email address"
|
|
10519
|
-
}).transform((val) => val?.toLowerCase()),
|
|
10520
|
-
phoneNumber: z2.string().optional(),
|
|
10521
|
-
sex: z2.enum(Enums_default.sex),
|
|
10522
|
-
owner: z2.string().min(1, { message: "Owner is required" }),
|
|
10523
|
-
host: z2.string().min(1, { message: "Host is required" })
|
|
10524
|
-
});
|
|
10525
|
-
|
|
10526
|
-
// src/components/accounts/AccountForm.tsx
|
|
10527
|
-
import { useForm as useForm2 } from "react-hook-form";
|
|
10528
|
-
import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
|
|
10529
|
-
import { message as message5 } from "antd";
|
|
10530
|
-
import { useEffect as useEffect23 } from "react";
|
|
10531
|
-
import { jsx as jsx43, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
10532
|
-
function AccountForm() {
|
|
10533
|
-
const { getQuery, getParams, navigate } = useApp_default();
|
|
10534
|
-
const id = getQuery("id");
|
|
10535
|
-
const type = getParams("type");
|
|
10536
|
-
const isEdit = !!id;
|
|
10537
|
-
const { post, put, isLoading } = useApis_default();
|
|
10538
|
-
const { isLoading: isLoadingGet, get } = useApis_default();
|
|
10539
|
-
const methods = useForm2({
|
|
10540
|
-
resolver: zodResolver2(createAccountSchema),
|
|
10541
|
-
defaultValues: {
|
|
10542
|
-
name: "",
|
|
10543
|
-
email: "",
|
|
10544
|
-
phoneNumber: "",
|
|
10545
|
-
sex: "male",
|
|
10546
|
-
owner: "",
|
|
10547
|
-
host: ""
|
|
10548
|
-
},
|
|
10549
|
-
shouldUnregister: false
|
|
10550
|
-
});
|
|
10551
|
-
const { handleSubmit } = methods;
|
|
10552
|
-
const onSubmit = async (data2) => {
|
|
10553
|
-
try {
|
|
10554
|
-
const payload = {
|
|
10555
|
-
...data2,
|
|
10556
|
-
type
|
|
10557
|
-
};
|
|
10558
|
-
if (isEdit) {
|
|
10559
|
-
await put({
|
|
10560
|
-
url: `/accounts/update/${id}`,
|
|
10561
|
-
body: payload
|
|
10562
|
-
});
|
|
10563
|
-
} else {
|
|
10564
|
-
await post({
|
|
10565
|
-
url: "/accounts/create",
|
|
10566
|
-
body: payload
|
|
10567
|
-
});
|
|
10568
|
-
}
|
|
10569
|
-
message5.success(`${type} ${isEdit ? "updated" : "created"} successfully`);
|
|
10570
|
-
navigate(-1);
|
|
10571
|
-
} catch (error) {
|
|
10572
|
-
message5.error(error?.message || "Something went wrong");
|
|
10573
|
-
}
|
|
10574
|
-
};
|
|
10575
|
-
const fetches = async () => {
|
|
10576
|
-
try {
|
|
10577
|
-
const res = await get({
|
|
10578
|
-
url: `/accounts/get/${type}?id=${id}`
|
|
10579
|
-
});
|
|
10580
|
-
const data2 = res.data;
|
|
10581
|
-
methods.reset(data2);
|
|
10582
|
-
} catch (error) {
|
|
10583
|
-
message5.error(error?.message || "Something went wrong");
|
|
10584
|
-
}
|
|
10585
|
-
};
|
|
10586
|
-
useEffect23(() => {
|
|
10587
|
-
if (isEdit) {
|
|
10588
|
-
fetches();
|
|
8195
|
+
};
|
|
8196
|
+
useEffect18(() => {
|
|
8197
|
+
if (isEdit) {
|
|
8198
|
+
fetches();
|
|
10589
8199
|
}
|
|
10590
8200
|
}, [id]);
|
|
10591
8201
|
return /* @__PURE__ */ jsxs33(
|
|
@@ -10720,7 +8330,7 @@ var resetPasswordSchema = z3.object({
|
|
|
10720
8330
|
import { useForm as useForm3 } from "react-hook-form";
|
|
10721
8331
|
import { zodResolver as zodResolver3 } from "@hookform/resolvers/zod";
|
|
10722
8332
|
import { message as message6 } from "antd";
|
|
10723
|
-
import { useEffect as
|
|
8333
|
+
import { useEffect as useEffect19 } from "react";
|
|
10724
8334
|
import { jsx as jsx44, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
10725
8335
|
function LinkUser({ type: initialType = "employee" }) {
|
|
10726
8336
|
const { getQuery, navigate, getParams } = useApp_default();
|
|
@@ -10737,10 +8347,10 @@ function LinkUser({ type: initialType = "employee" }) {
|
|
|
10737
8347
|
shouldUnregister: false
|
|
10738
8348
|
});
|
|
10739
8349
|
const { handleSubmit } = methods;
|
|
10740
|
-
const onSubmit = async (
|
|
8350
|
+
const onSubmit = async (data) => {
|
|
10741
8351
|
try {
|
|
10742
8352
|
const payload = {
|
|
10743
|
-
...
|
|
8353
|
+
...data
|
|
10744
8354
|
};
|
|
10745
8355
|
await post({
|
|
10746
8356
|
url: `/accounts/link-user/${id}`,
|
|
@@ -10757,18 +8367,18 @@ function LinkUser({ type: initialType = "employee" }) {
|
|
|
10757
8367
|
const res = await get({
|
|
10758
8368
|
url: `/accounts/get/${type}?id=${id}`
|
|
10759
8369
|
});
|
|
10760
|
-
const
|
|
10761
|
-
if (
|
|
8370
|
+
const data = res.data;
|
|
8371
|
+
if (data?.user) {
|
|
10762
8372
|
message6.error("Account Already Has A Login User");
|
|
10763
8373
|
navigate(-1);
|
|
10764
8374
|
return;
|
|
10765
8375
|
}
|
|
10766
|
-
methods.reset(
|
|
8376
|
+
methods.reset(data);
|
|
10767
8377
|
} catch (error) {
|
|
10768
8378
|
message6.error(error?.message || "Something went wrong");
|
|
10769
8379
|
}
|
|
10770
8380
|
};
|
|
10771
|
-
|
|
8381
|
+
useEffect19(() => {
|
|
10772
8382
|
if (id) {
|
|
10773
8383
|
fetches();
|
|
10774
8384
|
} else {
|
|
@@ -10839,7 +8449,7 @@ function LinkUser({ type: initialType = "employee" }) {
|
|
|
10839
8449
|
var linkUser_default = LinkUser;
|
|
10840
8450
|
|
|
10841
8451
|
// src/components/users/users.tsx
|
|
10842
|
-
import { useMemo as
|
|
8452
|
+
import { useMemo as useMemo8 } from "react";
|
|
10843
8453
|
import {
|
|
10844
8454
|
EllipsisVertical as EllipsisVertical2,
|
|
10845
8455
|
Info,
|
|
@@ -10852,27 +8462,27 @@ import {
|
|
|
10852
8462
|
import { useForm as useForm4 } from "react-hook-form";
|
|
10853
8463
|
import { zodResolver as zodResolver4 } from "@hookform/resolvers/zod";
|
|
10854
8464
|
import { message as message7, Statistic } from "antd";
|
|
10855
|
-
import { useState as
|
|
8465
|
+
import { useState as useState26, useEffect as useEffect20 } from "react";
|
|
10856
8466
|
import { jsx as jsx45, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
10857
8467
|
var { Countdown } = Statistic;
|
|
10858
8468
|
function VerifyEmailForm({
|
|
10859
|
-
data
|
|
8469
|
+
data,
|
|
10860
8470
|
close,
|
|
10861
8471
|
reload
|
|
10862
8472
|
}) {
|
|
10863
8473
|
const { put, isLoading } = useApis_default();
|
|
10864
|
-
const [datas, setDatas] =
|
|
10865
|
-
const [hasPassed, setHasPassed] =
|
|
10866
|
-
|
|
8474
|
+
const [datas, setDatas] = useState26(data);
|
|
8475
|
+
const [hasPassed, setHasPassed] = useState26(
|
|
8476
|
+
data?.emailVerification?.passed || !data?.emailVerification?.createdAt
|
|
10867
8477
|
);
|
|
10868
|
-
|
|
10869
|
-
setDatas(
|
|
8478
|
+
useEffect20(() => {
|
|
8479
|
+
setDatas(data);
|
|
10870
8480
|
setHasPassed(
|
|
10871
|
-
|
|
8481
|
+
data?.emailVerification?.passed || !data?.emailVerification?.createdAt
|
|
10872
8482
|
);
|
|
10873
|
-
}, [
|
|
10874
|
-
const email =
|
|
10875
|
-
const oldEmail =
|
|
8483
|
+
}, [data]);
|
|
8484
|
+
const email = data?.emailVerification?.email;
|
|
8485
|
+
const oldEmail = data?.emailVerification?.email !== data?.email ? data?.emailVerification?.email : null;
|
|
10876
8486
|
const methods = useForm4({
|
|
10877
8487
|
resolver: zodResolver4(verifyUserEmailSchema),
|
|
10878
8488
|
defaultValues: {
|
|
@@ -10888,7 +8498,7 @@ function VerifyEmailForm({
|
|
|
10888
8498
|
...datas2
|
|
10889
8499
|
};
|
|
10890
8500
|
await put({
|
|
10891
|
-
url: `/users/verify_email/${
|
|
8501
|
+
url: `/users/verify_email/${data._id}`,
|
|
10892
8502
|
body: payload
|
|
10893
8503
|
});
|
|
10894
8504
|
message7.success(`Email Verified successfully`);
|
|
@@ -10905,9 +8515,9 @@ function VerifyEmailForm({
|
|
|
10905
8515
|
const resend = async () => {
|
|
10906
8516
|
try {
|
|
10907
8517
|
const res = await put({
|
|
10908
|
-
url: `/users/resend_email_verification/${
|
|
8518
|
+
url: `/users/resend_email_verification/${data._id}`,
|
|
10909
8519
|
body: {
|
|
10910
|
-
email:
|
|
8520
|
+
email: data?.emailVerification?.email || data?.email
|
|
10911
8521
|
}
|
|
10912
8522
|
});
|
|
10913
8523
|
setDatas((prev) => ({
|
|
@@ -10997,12 +8607,12 @@ import { zodResolver as zodResolver5 } from "@hookform/resolvers/zod";
|
|
|
10997
8607
|
import { message as message8 } from "antd";
|
|
10998
8608
|
import { jsx as jsx46, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
10999
8609
|
function UpdateEmailForm({
|
|
11000
|
-
data
|
|
8610
|
+
data,
|
|
11001
8611
|
close,
|
|
11002
8612
|
reload
|
|
11003
8613
|
}) {
|
|
11004
8614
|
const { put, isLoading } = useApis_default();
|
|
11005
|
-
const currentEmail =
|
|
8615
|
+
const currentEmail = data?.email;
|
|
11006
8616
|
const methods = useForm5({
|
|
11007
8617
|
resolver: zodResolver5(updateUserEmailSchema),
|
|
11008
8618
|
defaultValues: {
|
|
@@ -11014,7 +8624,7 @@ function UpdateEmailForm({
|
|
|
11014
8624
|
const onSubmit = async (formData) => {
|
|
11015
8625
|
try {
|
|
11016
8626
|
await put({
|
|
11017
|
-
url: `/users/change_email/${
|
|
8627
|
+
url: `/users/change_email/${data._id}`,
|
|
11018
8628
|
body: {
|
|
11019
8629
|
email: formData.newEmail
|
|
11020
8630
|
}
|
|
@@ -11081,24 +8691,24 @@ var UpdateEmailForm_default = UpdateEmailForm;
|
|
|
11081
8691
|
// src/components/users/ResetPasswordForm.tsx
|
|
11082
8692
|
import { useForm as useForm6 } from "react-hook-form";
|
|
11083
8693
|
import { message as message9, Statistic as Statistic2 } from "antd";
|
|
11084
|
-
import { useState as
|
|
8694
|
+
import { useState as useState27, useEffect as useEffect21 } from "react";
|
|
11085
8695
|
import { jsx as jsx47, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
11086
8696
|
var { Countdown: Countdown2 } = Statistic2;
|
|
11087
8697
|
function ResetPasswordForm({
|
|
11088
|
-
data
|
|
8698
|
+
data,
|
|
11089
8699
|
close,
|
|
11090
8700
|
reload
|
|
11091
8701
|
}) {
|
|
11092
8702
|
const { put, isLoading } = useApis_default();
|
|
11093
|
-
const [datas, setDatas] =
|
|
11094
|
-
const [hasPassed, setHasPassed] =
|
|
11095
|
-
|
|
8703
|
+
const [datas, setDatas] = useState27(data);
|
|
8704
|
+
const [hasPassed, setHasPassed] = useState27(
|
|
8705
|
+
data?.passwordReset?.passed || !data?.passwordReset?.createdAt
|
|
11096
8706
|
);
|
|
11097
|
-
|
|
11098
|
-
setDatas(
|
|
11099
|
-
setHasPassed(
|
|
11100
|
-
}, [
|
|
11101
|
-
const userEmail =
|
|
8707
|
+
useEffect21(() => {
|
|
8708
|
+
setDatas(data);
|
|
8709
|
+
setHasPassed(data?.passwordReset?.passed || !data?.passwordReset?.createdAt);
|
|
8710
|
+
}, [data]);
|
|
8711
|
+
const userEmail = data?.email;
|
|
11102
8712
|
const methods = useForm6({
|
|
11103
8713
|
defaultValues: {
|
|
11104
8714
|
email: userEmail
|
|
@@ -11119,7 +8729,7 @@ function ResetPasswordForm({
|
|
|
11119
8729
|
const resendToken = async () => {
|
|
11120
8730
|
try {
|
|
11121
8731
|
const res = await put({
|
|
11122
|
-
url: `/users/reset_password/${
|
|
8732
|
+
url: `/users/reset_password/${data._id}`,
|
|
11123
8733
|
body: {
|
|
11124
8734
|
email: userEmail
|
|
11125
8735
|
}
|
|
@@ -11188,17 +8798,17 @@ var ResetPasswordForm_default = ResetPasswordForm;
|
|
|
11188
8798
|
|
|
11189
8799
|
// src/components/users/Activate.tsx
|
|
11190
8800
|
import { message as message10, Switch } from "antd";
|
|
11191
|
-
import { useState as
|
|
11192
|
-
import { Fragment as
|
|
11193
|
-
var ActivateUser = ({ data
|
|
11194
|
-
const [checked, setChecked] =
|
|
8801
|
+
import { useState as useState28 } from "react";
|
|
8802
|
+
import { Fragment as Fragment10, jsx as jsx48 } from "react/jsx-runtime";
|
|
8803
|
+
var ActivateUser = ({ data }) => {
|
|
8804
|
+
const [checked, setChecked] = useState28(data?.isActive);
|
|
11195
8805
|
const { put, isLoading } = useApis_default();
|
|
11196
|
-
return /* @__PURE__ */ jsx48(
|
|
8806
|
+
return /* @__PURE__ */ jsx48(Fragment10, { children: /* @__PURE__ */ jsx48(
|
|
11197
8807
|
Switch,
|
|
11198
8808
|
{
|
|
11199
8809
|
onChange: async (e) => {
|
|
11200
8810
|
const res = await put({
|
|
11201
|
-
url: `/users/activate/${
|
|
8811
|
+
url: `/users/activate/${data?._id}`,
|
|
11202
8812
|
v: 1,
|
|
11203
8813
|
body: { isActive: e }
|
|
11204
8814
|
});
|
|
@@ -11216,16 +8826,16 @@ var ActivateUser = ({ data: data2 }) => {
|
|
|
11216
8826
|
var Activate_default = ActivateUser;
|
|
11217
8827
|
|
|
11218
8828
|
// src/components/users/users.tsx
|
|
11219
|
-
import { Fragment as
|
|
8829
|
+
import { Fragment as Fragment11, jsx as jsx49, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
11220
8830
|
function Users() {
|
|
11221
|
-
const { data
|
|
8831
|
+
const { data, TransactionViewComponent, reload } = useTransaction_default({
|
|
11222
8832
|
url: "/users/get",
|
|
11223
8833
|
v: 1,
|
|
11224
8834
|
dateFilter: false
|
|
11225
8835
|
});
|
|
11226
8836
|
const { Modal: Modal2, openState, close } = useModal();
|
|
11227
8837
|
const { put, isLoading } = useApis_default();
|
|
11228
|
-
const items = (
|
|
8838
|
+
const items = (data2) => [
|
|
11229
8839
|
{
|
|
11230
8840
|
label: `Reset Password`,
|
|
11231
8841
|
icon: /* @__PURE__ */ jsx49(Key, { size: 16 }),
|
|
@@ -11235,7 +8845,7 @@ function Users() {
|
|
|
11235
8845
|
content: /* @__PURE__ */ jsx49(
|
|
11236
8846
|
ResetPasswordForm_default,
|
|
11237
8847
|
{
|
|
11238
|
-
data:
|
|
8848
|
+
data: data2,
|
|
11239
8849
|
close: () => close(),
|
|
11240
8850
|
reload: () => reload()
|
|
11241
8851
|
}
|
|
@@ -11252,7 +8862,7 @@ function Users() {
|
|
|
11252
8862
|
content: /* @__PURE__ */ jsx49(
|
|
11253
8863
|
UpdateEmailForm_default,
|
|
11254
8864
|
{
|
|
11255
|
-
data:
|
|
8865
|
+
data: data2,
|
|
11256
8866
|
close: () => close(),
|
|
11257
8867
|
reload: () => reload()
|
|
11258
8868
|
}
|
|
@@ -11260,7 +8870,7 @@ function Users() {
|
|
|
11260
8870
|
width: 600
|
|
11261
8871
|
})
|
|
11262
8872
|
},
|
|
11263
|
-
|
|
8873
|
+
data2?.emailVerification && {
|
|
11264
8874
|
label: `Verify Email`,
|
|
11265
8875
|
icon: /* @__PURE__ */ jsx49(ShieldCheck, {}),
|
|
11266
8876
|
onClick: () => openState({
|
|
@@ -11269,7 +8879,7 @@ function Users() {
|
|
|
11269
8879
|
content: /* @__PURE__ */ jsx49(
|
|
11270
8880
|
VerifyEmailForm_default,
|
|
11271
8881
|
{
|
|
11272
|
-
data:
|
|
8882
|
+
data: data2,
|
|
11273
8883
|
close: () => close(),
|
|
11274
8884
|
reload: () => reload()
|
|
11275
8885
|
}
|
|
@@ -11278,21 +8888,21 @@ function Users() {
|
|
|
11278
8888
|
})
|
|
11279
8889
|
}
|
|
11280
8890
|
].filter(Boolean);
|
|
11281
|
-
const columns =
|
|
8891
|
+
const columns = useMemo8(
|
|
11282
8892
|
() => [
|
|
11283
8893
|
{
|
|
11284
8894
|
accessorKey: "email",
|
|
11285
8895
|
header: "Email",
|
|
11286
8896
|
cell: ({ row }) => {
|
|
11287
|
-
const
|
|
11288
|
-
const emailVerification =
|
|
11289
|
-
const newEmail = emailVerification?.email !==
|
|
8897
|
+
const data2 = row.original;
|
|
8898
|
+
const emailVerification = data2?.emailVerification;
|
|
8899
|
+
const newEmail = emailVerification?.email !== data2?.email ? emailVerification?.email : null;
|
|
11290
8900
|
return /* @__PURE__ */ jsxs38("div", { className: "space-y-1", children: [
|
|
11291
8901
|
/* @__PURE__ */ jsxs38("section", { className: "flex items-center gap-2", children: [
|
|
11292
8902
|
" ",
|
|
11293
|
-
/* @__PURE__ */ jsx49("p", { children:
|
|
11294
|
-
|
|
11295
|
-
!
|
|
8903
|
+
/* @__PURE__ */ jsx49("p", { children: data2?.email }),
|
|
8904
|
+
data2?.isEmailVerified && /* @__PURE__ */ jsx49(Badge, { variant: "success", size: "sm", children: "Verified" }),
|
|
8905
|
+
!data2?.isEmailVerified && /* @__PURE__ */ jsx49(Badge, { variant: "warning", size: "sm", children: "Not Verified" })
|
|
11296
8906
|
] }),
|
|
11297
8907
|
newEmail && /* @__PURE__ */ jsxs38("section", { className: "flex items-center gap-2", children: [
|
|
11298
8908
|
/* @__PURE__ */ jsx49(Info, { size: 16, className: "text-orange-600" }),
|
|
@@ -11313,20 +8923,20 @@ function Users() {
|
|
|
11313
8923
|
accessorKey: "status",
|
|
11314
8924
|
header: "Status",
|
|
11315
8925
|
cell: ({ row }) => {
|
|
11316
|
-
const
|
|
11317
|
-
return /* @__PURE__ */ jsx49(Activate_default, { data:
|
|
8926
|
+
const data2 = row.original;
|
|
8927
|
+
return /* @__PURE__ */ jsx49(Activate_default, { data: data2 });
|
|
11318
8928
|
}
|
|
11319
8929
|
},
|
|
11320
8930
|
{
|
|
11321
8931
|
accessorKey: "actions",
|
|
11322
8932
|
header: "Actions",
|
|
11323
8933
|
cell: ({ row }) => {
|
|
11324
|
-
const
|
|
8934
|
+
const data2 = row.original;
|
|
11325
8935
|
return /* @__PURE__ */ jsx49(
|
|
11326
8936
|
Dropdown,
|
|
11327
8937
|
{
|
|
11328
8938
|
className: "w-fit! cursor-pointer",
|
|
11329
|
-
items: items(
|
|
8939
|
+
items: items(data2),
|
|
11330
8940
|
triggerMode: "hover",
|
|
11331
8941
|
children: /* @__PURE__ */ jsx49(EllipsisVertical2, {})
|
|
11332
8942
|
}
|
|
@@ -11336,8 +8946,8 @@ function Users() {
|
|
|
11336
8946
|
],
|
|
11337
8947
|
[items]
|
|
11338
8948
|
);
|
|
11339
|
-
const users =
|
|
11340
|
-
return /* @__PURE__ */ jsxs38(
|
|
8949
|
+
const users = data?.data || [];
|
|
8950
|
+
return /* @__PURE__ */ jsxs38(Fragment11, { children: [
|
|
11341
8951
|
/* @__PURE__ */ jsx49(Modal2, {}),
|
|
11342
8952
|
/* @__PURE__ */ jsx49(
|
|
11343
8953
|
TransactionViewComponent,
|
|
@@ -11355,18 +8965,18 @@ function Users() {
|
|
|
11355
8965
|
var users_default = Users;
|
|
11356
8966
|
|
|
11357
8967
|
// src/components/users/ResetPasswordPage.tsx
|
|
11358
|
-
import { useEffect as
|
|
8968
|
+
import { useEffect as useEffect22, useState as useState29 } from "react";
|
|
11359
8969
|
import { useSearchParams as useSearchParams2, useNavigate as useNavigate6 } from "react-router-dom";
|
|
11360
8970
|
import { Lock as Lock2, ShieldCheck as ShieldCheck2, ArrowRight as ArrowRight2, Terminal as Terminal2 } from "lucide-react";
|
|
11361
8971
|
import { useForm as useForm7 } from "react-hook-form";
|
|
11362
8972
|
import { zodResolver as zodResolver6 } from "@hookform/resolvers/zod";
|
|
11363
8973
|
import * as z4 from "zod";
|
|
11364
8974
|
import { message as message11, Spin } from "antd";
|
|
11365
|
-
import { Fragment as
|
|
8975
|
+
import { Fragment as Fragment12, jsx as jsx50, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
11366
8976
|
var resetPageSchema = z4.object({
|
|
11367
8977
|
password: z4.string().min(6, "Password must be at least 6 characters"),
|
|
11368
8978
|
confirmPassword: z4.string().min(6, "Password must be at least 6 characters")
|
|
11369
|
-
}).refine((
|
|
8979
|
+
}).refine((data) => data.password === data.confirmPassword, {
|
|
11370
8980
|
message: "Passwords don't match",
|
|
11371
8981
|
path: ["confirmPassword"]
|
|
11372
8982
|
});
|
|
@@ -11374,9 +8984,9 @@ function ResetPasswordPage() {
|
|
|
11374
8984
|
const [searchParams] = useSearchParams2();
|
|
11375
8985
|
const navigate = useNavigate6();
|
|
11376
8986
|
const { put, isLoading } = useApis_default();
|
|
11377
|
-
const [isVerified, setIsVerified] =
|
|
11378
|
-
const [verifying, setVerifying] =
|
|
11379
|
-
const [error, setError] =
|
|
8987
|
+
const [isVerified, setIsVerified] = useState29(false);
|
|
8988
|
+
const [verifying, setVerifying] = useState29(true);
|
|
8989
|
+
const [error, setError] = useState29(null);
|
|
11380
8990
|
const token = searchParams.get("token");
|
|
11381
8991
|
const email = searchParams.get("email");
|
|
11382
8992
|
const id = searchParams.get("id");
|
|
@@ -11387,7 +8997,7 @@ function ResetPasswordPage() {
|
|
|
11387
8997
|
confirmPassword: ""
|
|
11388
8998
|
}
|
|
11389
8999
|
});
|
|
11390
|
-
|
|
9000
|
+
useEffect22(() => {
|
|
11391
9001
|
const verifyToken = async () => {
|
|
11392
9002
|
if (!token || !email) {
|
|
11393
9003
|
setError("Invalid or missing reset link parameters.");
|
|
@@ -11409,14 +9019,14 @@ function ResetPasswordPage() {
|
|
|
11409
9019
|
};
|
|
11410
9020
|
verifyToken();
|
|
11411
9021
|
}, [token, email]);
|
|
11412
|
-
const onSubmit = async (
|
|
9022
|
+
const onSubmit = async (data) => {
|
|
11413
9023
|
try {
|
|
11414
9024
|
await put({
|
|
11415
9025
|
url: `/users/set_password/${id}`,
|
|
11416
9026
|
body: {
|
|
11417
9027
|
token,
|
|
11418
9028
|
email,
|
|
11419
|
-
password:
|
|
9029
|
+
password: data.password
|
|
11420
9030
|
}
|
|
11421
9031
|
});
|
|
11422
9032
|
message11.success(
|
|
@@ -11480,7 +9090,7 @@ function ResetPasswordPage() {
|
|
|
11480
9090
|
children: "Back to Login"
|
|
11481
9091
|
}
|
|
11482
9092
|
)
|
|
11483
|
-
] }) : /* @__PURE__ */ jsxs39(
|
|
9093
|
+
] }) : /* @__PURE__ */ jsxs39(Fragment12, { children: [
|
|
11484
9094
|
/* @__PURE__ */ jsxs39("div", { className: "mb-10", children: [
|
|
11485
9095
|
/* @__PURE__ */ jsx50("h2", { className: "text-3xl font-bold text-slate-900 dark:text-white mb-3 tracking-tight", children: "Reset Password" }),
|
|
11486
9096
|
/* @__PURE__ */ jsxs39("p", { className: "text-slate-500 dark:text-slate-400", children: [
|
|
@@ -11742,18 +9352,3 @@ export {
|
|
|
11742
9352
|
useWarqadConfig,
|
|
11743
9353
|
verifyUserEmailSchema
|
|
11744
9354
|
};
|
|
11745
|
-
/*! Bundled license information:
|
|
11746
|
-
|
|
11747
|
-
react-router/dist/development/chunk-LFPYN7LY.mjs:
|
|
11748
|
-
react-router/dist/development/index.mjs:
|
|
11749
|
-
(**
|
|
11750
|
-
* react-router v7.13.1
|
|
11751
|
-
*
|
|
11752
|
-
* Copyright (c) Remix Software Inc.
|
|
11753
|
-
*
|
|
11754
|
-
* This source code is licensed under the MIT license found in the
|
|
11755
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
11756
|
-
*
|
|
11757
|
-
* @license MIT
|
|
11758
|
-
*)
|
|
11759
|
-
*/
|