gomtm 0.0.281 → 0.0.282
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/esm/components/SSR.d.ts +4 -5
- package/dist/esm/components/SSR.js +5 -8
- package/dist/esm/curd/CurdDetailProvider.d.ts +0 -4
- package/dist/esm/curd/CurdDetailProvider.js +0 -33
- package/dist/esm/curd/ListPageCommands.js +1 -1
- package/dist/esm/curd/ListViewProvider.d.ts +17 -15
- package/dist/esm/curd/ListViewProvider.js +6 -21
- package/dist/esm/curd/MtListView.d.ts +1 -2
- package/dist/esm/curd/MtListView.js +2 -2
- package/dist/esm/curd/create/CurdCreatePanel.js +1 -1
- package/dist/esm/curd/edit/CurdEditPanel.js +2 -2
- package/dist/esm/curd/list-item/CommonListItemView.js +1 -1
- package/dist/esm/curd/list-item/PostCardListItem.js +1 -1
- package/dist/esm/curd/listview/ListViewProvider.d.ts +64 -0
- package/dist/esm/curd/listview/ListViewProvider.js +195 -0
- package/dist/esm/curd/listview/MtListView.d.ts +3 -0
- package/dist/esm/curd/listview/MtListView.js +50 -0
- package/dist/esm/curd/listview/listview-layouts/listview-demolayout/index.d.ts +2 -0
- package/dist/esm/curd/listview/listview-layouts/listview-demolayout/index.js +9 -0
- package/dist/esm/gomtmQuery.d.ts +14 -0
- package/dist/esm/gomtmQuery.js +102 -0
- package/dist/esm/mtmFetcher.d.ts +2 -0
- package/dist/esm/mtmFetcher.js +11 -2
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Message, PartialMessage } from "@bufbuild/protobuf";
|
|
2
1
|
import { PropsWithChildren } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
input?:
|
|
2
|
+
export declare function PrefetchConnectInfiniteQuery(props: {
|
|
3
|
+
svc: string;
|
|
4
|
+
method: string;
|
|
5
|
+
input?: any;
|
|
7
6
|
} & PropsWithChildren): Promise<import("react").JSX.Element>;
|
|
@@ -36,18 +36,15 @@ var __async = (__this, __arguments, generator) => {
|
|
|
36
36
|
};
|
|
37
37
|
import { jsx } from "react/jsx-runtime";
|
|
38
38
|
import { HydrationBoundary, QueryClient, dehydrate } from "@tanstack/react-query";
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
39
|
+
import { goMtmQueryFn } from "../gomtmQuery";
|
|
40
|
+
import { createInfiniteQueryKey } from "../mtmFetcher";
|
|
41
41
|
function PrefetchConnectInfiniteQuery(props) {
|
|
42
42
|
return __async(this, null, function* () {
|
|
43
|
-
const {
|
|
43
|
+
const { svc, method, input, children } = props;
|
|
44
44
|
const queryClient = new QueryClient();
|
|
45
|
-
const ts = createTransport();
|
|
46
45
|
yield queryClient.prefetchInfiniteQuery({
|
|
47
|
-
queryKey:
|
|
48
|
-
queryFn: (k) => {
|
|
49
|
-
return callUnaryMethod(methodSig, input, { transport: ts });
|
|
50
|
-
},
|
|
46
|
+
queryKey: createInfiniteQueryKey(svc, method, input),
|
|
47
|
+
queryFn: (k) => goMtmQueryFn({ svc, method, input }),
|
|
51
48
|
initialPageParam: __spreadValues({}, input)
|
|
52
49
|
});
|
|
53
50
|
const dehydratedState = dehydrate(queryClient);
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const DetailViewDataDlg: () => import("react").JSX.Element;
|
|
3
|
-
export declare function DlgCurdDebugInfo(): import("react").JSX.Element;
|
|
4
|
-
export declare const DlgCurdDebugInfoTriggerButton: () => import("react").JSX.Element | null;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Dialog, DialogContent, DialogTitle, DialogTrigger } from "mtxuilib/ui/dialog";
|
|
3
|
-
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
4
|
-
import { useSuspenseQuery } from "../connectquery";
|
|
5
|
-
import { useMtmApp } from "../providers/GomtmProvider";
|
|
6
|
-
import { useListView } from "./ListViewProvider";
|
|
7
|
-
const DetailViewDataDlg = () => {
|
|
8
|
-
const listView = useListView();
|
|
9
|
-
const query = useSuspenseQuery(listView.methodGet, listView.getParams);
|
|
10
|
-
return /* @__PURE__ */ jsxs(Dialog, { children: [
|
|
11
|
-
/* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx(MtButton, { children: "DetailData" }) }),
|
|
12
|
-
/* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx("pre", { children: JSON.stringify(query.data, null, 2) }) })
|
|
13
|
-
] });
|
|
14
|
-
};
|
|
15
|
-
function DlgCurdDebugInfo() {
|
|
16
|
-
const listView = useListView();
|
|
17
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Dialog, { open: listView.openDebug, onOpenChange: listView.setOpenDebug, children: /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "list view info" }) }) }) });
|
|
18
|
-
}
|
|
19
|
-
const DlgCurdDebugInfoTriggerButton = () => {
|
|
20
|
-
const listView = useListView();
|
|
21
|
-
const mtApp = useMtmApp();
|
|
22
|
-
if (!mtApp.isDebug) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
26
|
-
listView.setOpenDebug(true);
|
|
27
|
-
}, children: "DlgCurdDebug" }) });
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
DetailViewDataDlg,
|
|
31
|
-
DlgCurdDebugInfo,
|
|
32
|
-
DlgCurdDebugInfoTriggerButton
|
|
33
|
-
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { HOTKEY_ListViewCMDK } from "../consts";
|
|
4
3
|
import { debounce } from "lodash";
|
|
5
4
|
import { CommandDialog, CommandEmpty, CommandInput, CommandList, CommandSeparator } from "mtxuilib/ui/command";
|
|
6
5
|
import { useState } from "react";
|
|
7
6
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
7
|
+
import { HOTKEY_ListViewCMDK } from "../consts";
|
|
8
8
|
function ListPageCommands() {
|
|
9
9
|
const [open, setOpen] = useState(false);
|
|
10
10
|
useHotkeys(HOTKEY_ListViewCMDK, () => {
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { Message } from "@bufbuild/protobuf";
|
|
2
2
|
import { Dispatch, PropsWithChildren, SetStateAction } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
methodList:
|
|
6
|
-
methodDelete:
|
|
7
|
-
methodCreate?:
|
|
8
|
-
methodGet?:
|
|
3
|
+
interface ListViewProps {
|
|
4
|
+
svc: string;
|
|
5
|
+
methodList: string;
|
|
6
|
+
methodDelete: string;
|
|
7
|
+
methodCreate?: string;
|
|
8
|
+
methodGet?: string;
|
|
9
9
|
slugPath?: string;
|
|
10
10
|
activateItem?: any;
|
|
11
11
|
params?: any;
|
|
12
12
|
getParams?: any;
|
|
13
13
|
detailData?: any;
|
|
14
14
|
}
|
|
15
|
-
export declare function ListViewProvider
|
|
15
|
+
export declare function ListViewProvider(props: ListViewProps & PropsWithChildren): import("react").JSX.Element;
|
|
16
16
|
export declare function useListView<I extends Message<I>, O extends Message<O>>(): {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
svc?: string | undefined;
|
|
18
|
+
methodList?: string | undefined;
|
|
19
|
+
methodDelete?: string | undefined;
|
|
20
|
+
methodCreate?: string | undefined;
|
|
21
|
+
methodGet?: string | undefined;
|
|
21
22
|
slugPath?: string | undefined;
|
|
22
23
|
activateItem?: any;
|
|
23
24
|
params?: any;
|
|
@@ -36,10 +37,11 @@ export declare function useListView<I extends Message<I>, O extends Message<O>>(
|
|
|
36
37
|
setDetailData?: Dispatch<any> | undefined;
|
|
37
38
|
};
|
|
38
39
|
export declare function useDetail(): {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
svc: string;
|
|
41
|
+
methodList: string;
|
|
42
|
+
methodDelete: string;
|
|
43
|
+
methodCreate?: string | undefined;
|
|
44
|
+
methodGet?: string | undefined;
|
|
43
45
|
slugPath?: string | undefined;
|
|
44
46
|
activateItem?: any;
|
|
45
47
|
params?: any;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
3
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -17,7 +15,6 @@ var __spreadValues = (a, b) => {
|
|
|
17
15
|
}
|
|
18
16
|
return a;
|
|
19
17
|
};
|
|
20
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
18
|
var __async = (__this, __arguments, generator) => {
|
|
22
19
|
return new Promise((resolve, reject) => {
|
|
23
20
|
var fulfilled = (value) => {
|
|
@@ -48,8 +45,8 @@ import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, Pagi
|
|
|
48
45
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
49
46
|
import { Suspense, createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
50
47
|
import { MtmErrorView } from "../components/MtmErrorView";
|
|
51
|
-
import { useMutation, useSuspenseInfiniteQuery } from "../connectquery";
|
|
52
48
|
import { CONST_debounce_INPUT } from "../consts";
|
|
49
|
+
import { useGomtmMutation, useGomtmSuspenseInfiniteQuery } from "../gomtmQuery";
|
|
53
50
|
import { useMtmApp } from "../providers/GomtmProvider";
|
|
54
51
|
import { DlgCurdDebugInfo, DlgCurdDebugInfoTriggerButton } from "./CurdDetailProvider";
|
|
55
52
|
import CurdCreatePanel, { CurdCreatePanelTriggerButton } from "./create/CurdCreatePanel";
|
|
@@ -58,8 +55,9 @@ import { ListItemView } from "./list-item/ListItem";
|
|
|
58
55
|
import { ListLayout } from "./list-item/ListLayout";
|
|
59
56
|
const commonListViewContext = createContext(void 0);
|
|
60
57
|
function ListViewProvider(props) {
|
|
61
|
-
const { children, methodList, methodDelete, slugPath, methodCreate, methodGet } = props;
|
|
58
|
+
const { children, svc, methodList, methodDelete, slugPath, methodCreate, methodGet } = props;
|
|
62
59
|
const mtapp = useMtmApp();
|
|
60
|
+
const [_svc, setSvc] = useState(svc);
|
|
63
61
|
const [openRemove, setOpenRemove] = useState(false);
|
|
64
62
|
const [openCreate, setOpenCreate] = useState(false);
|
|
65
63
|
const [activateItem, setActivateItem] = useState(void 0);
|
|
@@ -77,6 +75,7 @@ function ListViewProvider(props) {
|
|
|
77
75
|
_setParams(values);
|
|
78
76
|
}, CONST_debounce_INPUT), [_setParams]);
|
|
79
77
|
return /* @__PURE__ */ jsx(commonListViewContext.Provider, { value: {
|
|
78
|
+
svc: _svc,
|
|
80
79
|
methodList,
|
|
81
80
|
methodGet,
|
|
82
81
|
methodDelete,
|
|
@@ -111,21 +110,7 @@ function useDetail() {
|
|
|
111
110
|
}
|
|
112
111
|
function CommonListView() {
|
|
113
112
|
const listView = useListView();
|
|
114
|
-
const listQuery =
|
|
115
|
-
params: {
|
|
116
|
-
params: {
|
|
117
|
-
q: listView.params.q || ""
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
pagination: void 0
|
|
121
|
-
}, {
|
|
122
|
-
pageParamKey: "pagination",
|
|
123
|
-
getNextPageParam: (lastPage, allPages, lastPageParam, allPageParams) => {
|
|
124
|
-
var _a;
|
|
125
|
-
const a = __spreadProps(__spreadValues({}, lastPageParam), { page: (((_a = lastPage.Pagination) == null ? void 0 : _a.page) || 1) + 1 });
|
|
126
|
-
return a;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
113
|
+
const listQuery = useGomtmSuspenseInfiniteQuery(listView.svc, listView.methodList, listView.params);
|
|
129
114
|
if (!(listQuery == null ? void 0 : listQuery.data)) {
|
|
130
115
|
return null;
|
|
131
116
|
}
|
|
@@ -161,7 +146,7 @@ function CommonListView() {
|
|
|
161
146
|
}
|
|
162
147
|
const PanelRemove = () => {
|
|
163
148
|
const listView = useListView();
|
|
164
|
-
const mutation =
|
|
149
|
+
const mutation = useGomtmMutation(listView.svc, listView.methodDelete);
|
|
165
150
|
return /* @__PURE__ */ jsx(Dialog, { open: listView.openRemove, onOpenChange: listView.setOpenRemove, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
166
151
|
/* @__PURE__ */ jsx(DialogTitle, { children: "remove item" }),
|
|
167
152
|
/* @__PURE__ */ jsx(MtButton, { onClick: () => __async(void 0, null, function* () {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { ComponentProps, PropsWithChildren } from "react";
|
|
2
|
-
import { Message } from "..";
|
|
3
2
|
import { ListViewProvider } from "./ListViewProvider";
|
|
4
|
-
export default function MtListView
|
|
3
|
+
export default function MtListView(props: {} & ComponentProps<typeof ListViewProvider> & PropsWithChildren): import("react").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -39,7 +38,8 @@ function MtListView(props) {
|
|
|
39
38
|
return /* @__PURE__ */ jsx(ListViewProvider, __spreadProps(__spreadValues({}, etc), { children: /* @__PURE__ */ jsx(
|
|
40
39
|
PrefetchConnectInfiniteQuery,
|
|
41
40
|
{
|
|
42
|
-
|
|
41
|
+
svc: siteList.service.typeName,
|
|
42
|
+
method: siteList.name,
|
|
43
43
|
input: etc.params,
|
|
44
44
|
children
|
|
45
45
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
3
|
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
4
4
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
5
|
-
import { useListView } from "../ListViewProvider";
|
|
5
|
+
import { useListView } from "../listview/ListViewProvider";
|
|
6
6
|
function CurdCreatePanel() {
|
|
7
7
|
const listView = useListView();
|
|
8
8
|
return /* @__PURE__ */ jsx(Dialog, { open: listView.openCreate, onOpenChange: listView.setOpenCreate, children: /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogTitle, { children: " Create " }) }) });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
4
3
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
5
|
-
import { useListView } from "../ListViewProvider";
|
|
4
|
+
import { useListView } from "../listview/ListViewProvider";
|
|
5
|
+
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
6
6
|
function CurdEditPanel() {
|
|
7
7
|
const listView = useListView();
|
|
8
8
|
return /* @__PURE__ */ jsx(Dialog, { open: listView.openEdit, onOpenChange: listView.setOpenEdit, children: /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogTitle, { children: " Edit " }) }) });
|
|
@@ -7,7 +7,7 @@ import { buttonVariants } from "mtxuilib/ui/button";
|
|
|
7
7
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
8
8
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
9
9
|
import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
|
|
10
|
-
import { useListView } from "../ListViewProvider";
|
|
10
|
+
import { useListView } from "../listview/ListViewProvider";
|
|
11
11
|
const CommonListItemView = (props) => {
|
|
12
12
|
const { item } = props;
|
|
13
13
|
const handleSelect = () => {
|
|
@@ -6,7 +6,7 @@ import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle }
|
|
|
6
6
|
import { Icons } from "mtxuilib/icons/icons";
|
|
7
7
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
8
8
|
import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
|
|
9
|
-
import { useListView } from "../ListViewProvider";
|
|
9
|
+
import { useListView } from "../listview/ListViewProvider";
|
|
10
10
|
const PostCardListItem = (props) => {
|
|
11
11
|
var _a;
|
|
12
12
|
const { item } = props;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Message } from "@bufbuild/protobuf";
|
|
2
|
+
import { Dispatch, PropsWithChildren, SetStateAction } from "react";
|
|
3
|
+
interface ListViewProps {
|
|
4
|
+
svc: string;
|
|
5
|
+
methodList: string;
|
|
6
|
+
methodDelete: string;
|
|
7
|
+
methodCreate?: string;
|
|
8
|
+
methodGet?: string;
|
|
9
|
+
slugPath?: string;
|
|
10
|
+
activateItem?: any;
|
|
11
|
+
params?: any;
|
|
12
|
+
getParams?: any;
|
|
13
|
+
detailData?: any;
|
|
14
|
+
}
|
|
15
|
+
export declare function ListViewProvider(props: ListViewProps & PropsWithChildren): import("react").JSX.Element;
|
|
16
|
+
export declare function useListView<I extends Message<I>, O extends Message<O>>(): {
|
|
17
|
+
svc?: string | undefined;
|
|
18
|
+
methodList?: string | undefined;
|
|
19
|
+
methodDelete?: string | undefined;
|
|
20
|
+
methodCreate?: string | undefined;
|
|
21
|
+
methodGet?: string | undefined;
|
|
22
|
+
slugPath?: string | undefined;
|
|
23
|
+
activateItem?: any;
|
|
24
|
+
params?: any;
|
|
25
|
+
getParams?: any;
|
|
26
|
+
detailData?: any;
|
|
27
|
+
openRemove?: boolean | undefined;
|
|
28
|
+
setOpenRemove?: Dispatch<SetStateAction<boolean>> | undefined;
|
|
29
|
+
openCreate?: boolean | undefined;
|
|
30
|
+
setOpenCreate?: Dispatch<SetStateAction<boolean>> | undefined;
|
|
31
|
+
setActivateItem?: Dispatch<any> | undefined;
|
|
32
|
+
openEdit?: boolean | undefined;
|
|
33
|
+
setOpenEdit?: Dispatch<SetStateAction<boolean>> | undefined;
|
|
34
|
+
openDebug?: boolean | undefined;
|
|
35
|
+
setOpenDebug?: Dispatch<SetStateAction<boolean>> | undefined;
|
|
36
|
+
setParams?: Dispatch<any> | undefined;
|
|
37
|
+
setDetailData?: Dispatch<any> | undefined;
|
|
38
|
+
};
|
|
39
|
+
export declare function useDetail(): {
|
|
40
|
+
svc: string;
|
|
41
|
+
methodList: string;
|
|
42
|
+
methodDelete: string;
|
|
43
|
+
methodCreate?: string | undefined;
|
|
44
|
+
methodGet?: string | undefined;
|
|
45
|
+
slugPath?: string | undefined;
|
|
46
|
+
activateItem?: any;
|
|
47
|
+
params?: any;
|
|
48
|
+
getParams?: any;
|
|
49
|
+
detailData?: any;
|
|
50
|
+
openRemove: boolean;
|
|
51
|
+
setOpenRemove: Dispatch<SetStateAction<boolean>>;
|
|
52
|
+
openCreate: boolean;
|
|
53
|
+
setOpenCreate: Dispatch<SetStateAction<boolean>>;
|
|
54
|
+
setActivateItem: Dispatch<any>;
|
|
55
|
+
openEdit?: boolean | undefined;
|
|
56
|
+
setOpenEdit: Dispatch<SetStateAction<boolean>>;
|
|
57
|
+
openDebug?: boolean | undefined;
|
|
58
|
+
setOpenDebug: Dispatch<SetStateAction<boolean>>;
|
|
59
|
+
setParams: Dispatch<any>;
|
|
60
|
+
setDetailData: Dispatch<any>;
|
|
61
|
+
};
|
|
62
|
+
export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
|
|
63
|
+
export declare const ListViewActions: () => import("react").JSX.Element;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __spreadValues = (a, b) => {
|
|
8
|
+
for (var prop in b || (b = {}))
|
|
9
|
+
if (__hasOwnProp.call(b, prop))
|
|
10
|
+
__defNormalProp(a, prop, b[prop]);
|
|
11
|
+
if (__getOwnPropSymbols)
|
|
12
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
13
|
+
if (__propIsEnum.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
}
|
|
16
|
+
return a;
|
|
17
|
+
};
|
|
18
|
+
var __async = (__this, __arguments, generator) => {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
var fulfilled = (value) => {
|
|
21
|
+
try {
|
|
22
|
+
step(generator.next(value));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var rejected = (value) => {
|
|
28
|
+
try {
|
|
29
|
+
step(generator.throw(value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
35
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
39
|
+
import { debounce } from "lodash";
|
|
40
|
+
import { Icons } from "mtxuilib/icons/icons";
|
|
41
|
+
import { cn } from "mtxuilib/lib/utils";
|
|
42
|
+
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
43
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
44
|
+
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
|
|
45
|
+
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
46
|
+
import { Suspense, createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
47
|
+
import { MtmErrorView } from "../../components/MtmErrorView";
|
|
48
|
+
import { CONST_debounce_INPUT } from "../../consts";
|
|
49
|
+
import { useGomtmMutation, useGomtmSuspenseInfiniteQuery } from "../../gomtmQuery";
|
|
50
|
+
import { useMtmApp } from "../../providers/GomtmProvider";
|
|
51
|
+
import CurdCreatePanel, { CurdCreatePanelTriggerButton } from "../create/CurdCreatePanel";
|
|
52
|
+
import CurdEditPanel, { CurdEditPanelTriggerButton } from "../edit/CurdEditPanel";
|
|
53
|
+
import { ListItemView } from "../list-item/ListItem";
|
|
54
|
+
import { ListLayout } from "../list-item/ListLayout";
|
|
55
|
+
const commonListViewContext = createContext(void 0);
|
|
56
|
+
function ListViewProvider(props) {
|
|
57
|
+
const { children, svc, methodList, methodDelete, slugPath, methodCreate, methodGet } = props;
|
|
58
|
+
const mtapp = useMtmApp();
|
|
59
|
+
const [_svc, setSvc] = useState(svc);
|
|
60
|
+
const [openRemove, setOpenRemove] = useState(false);
|
|
61
|
+
const [openCreate, setOpenCreate] = useState(false);
|
|
62
|
+
const [activateItem, setActivateItem] = useState(void 0);
|
|
63
|
+
const [openEdit, setOpenEdit] = useState(false);
|
|
64
|
+
const [openDebug, setOpenDebug] = useState(false);
|
|
65
|
+
const [_params, _setParams] = useState(mtapp.globalSearchParams);
|
|
66
|
+
const [detailData, setDetailData] = useState(void 0);
|
|
67
|
+
const params = useMemo(() => {
|
|
68
|
+
var _a;
|
|
69
|
+
return {
|
|
70
|
+
q: (_a = mtapp.globalSearchParams) == null ? void 0 : _a.q
|
|
71
|
+
};
|
|
72
|
+
}, [mtapp.globalSearchParams]);
|
|
73
|
+
const setParams = useCallback(debounce((values) => {
|
|
74
|
+
_setParams(values);
|
|
75
|
+
}, CONST_debounce_INPUT), [_setParams]);
|
|
76
|
+
return /* @__PURE__ */ jsx(commonListViewContext.Provider, { value: {
|
|
77
|
+
svc: _svc,
|
|
78
|
+
methodList,
|
|
79
|
+
methodGet,
|
|
80
|
+
methodDelete,
|
|
81
|
+
methodCreate,
|
|
82
|
+
slugPath,
|
|
83
|
+
openRemove,
|
|
84
|
+
setOpenRemove,
|
|
85
|
+
openCreate,
|
|
86
|
+
setOpenCreate,
|
|
87
|
+
activateItem,
|
|
88
|
+
setActivateItem,
|
|
89
|
+
openEdit,
|
|
90
|
+
setOpenEdit,
|
|
91
|
+
openDebug,
|
|
92
|
+
setOpenDebug,
|
|
93
|
+
params,
|
|
94
|
+
setParams,
|
|
95
|
+
detailData,
|
|
96
|
+
setDetailData
|
|
97
|
+
}, children });
|
|
98
|
+
}
|
|
99
|
+
function useListView() {
|
|
100
|
+
const ctx = useContext(commonListViewContext);
|
|
101
|
+
return __spreadValues({}, ctx);
|
|
102
|
+
}
|
|
103
|
+
function useDetail() {
|
|
104
|
+
const mtappContext = useContext(commonListViewContext);
|
|
105
|
+
if (mtappContext === void 0) {
|
|
106
|
+
throw new Error("useDetail must be used within a MtAppProvider");
|
|
107
|
+
}
|
|
108
|
+
return __spreadValues({}, mtappContext);
|
|
109
|
+
}
|
|
110
|
+
function CommonListView() {
|
|
111
|
+
const listView = useListView();
|
|
112
|
+
const listQuery = useGomtmSuspenseInfiniteQuery(listView.svc, listView.methodList, listView.params);
|
|
113
|
+
if (!(listQuery == null ? void 0 : listQuery.data)) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
117
|
+
/* @__PURE__ */ jsx(
|
|
118
|
+
"div",
|
|
119
|
+
{
|
|
120
|
+
className: cn(
|
|
121
|
+
"w-full"
|
|
122
|
+
// 滚动设置
|
|
123
|
+
// " max-h-[700px] overflow-y-auto"
|
|
124
|
+
),
|
|
125
|
+
children: listQuery.data.pages.map((page, i) => {
|
|
126
|
+
var _a;
|
|
127
|
+
if (page.errCode) {
|
|
128
|
+
return /* @__PURE__ */ jsx(MtmErrorView, { unaryError: page }, i);
|
|
129
|
+
} else {
|
|
130
|
+
return /* @__PURE__ */ jsx(ListLayout, { layout: page.listLayout, children: (_a = page == null ? void 0 : page.items) == null ? void 0 : _a.map((item, j) => /* @__PURE__ */ jsx(ListItemView, { item }, `${i}-${j}`)) }, i);
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
),
|
|
135
|
+
/* @__PURE__ */ jsx(Pagination, { children: /* @__PURE__ */ jsxs(PaginationContent, { children: [
|
|
136
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationPrevious, { href: "#" }) }),
|
|
137
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { href: "#", children: "1" }) }),
|
|
138
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { href: "#", isActive: true, children: "2" }) }),
|
|
139
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { href: "#", children: "3" }) }),
|
|
140
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationEllipsis, {}) }),
|
|
141
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationNext, { href: "#" }) })
|
|
142
|
+
] }) }),
|
|
143
|
+
/* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1", children: /* @__PURE__ */ jsx(ListViewActions, {}) })
|
|
144
|
+
] });
|
|
145
|
+
}
|
|
146
|
+
const PanelRemove = () => {
|
|
147
|
+
const listView = useListView();
|
|
148
|
+
const mutation = useGomtmMutation(listView.svc, listView.methodDelete);
|
|
149
|
+
return /* @__PURE__ */ jsx(Dialog, { open: listView.openRemove, onOpenChange: listView.setOpenRemove, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
150
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: "remove item" }),
|
|
151
|
+
/* @__PURE__ */ jsx(MtButton, { onClick: () => __async(void 0, null, function* () {
|
|
152
|
+
var _a;
|
|
153
|
+
yield mutation.mutateAsync({
|
|
154
|
+
id: (_a = listView.activateItem) == null ? void 0 : _a.id
|
|
155
|
+
});
|
|
156
|
+
listView.setOpenRemove(false);
|
|
157
|
+
}), children: "ok" })
|
|
158
|
+
] }) });
|
|
159
|
+
};
|
|
160
|
+
const PanelCreate = () => {
|
|
161
|
+
const listView = useListView();
|
|
162
|
+
return /* @__PURE__ */ jsx(Dialog, { open: listView.openCreate, onOpenChange: listView.setOpenCreate, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
163
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: "TODO create item Dlg" }),
|
|
164
|
+
/* @__PURE__ */ jsx(MtButton, { onClick: () => __async(void 0, null, function* () {
|
|
165
|
+
listView.setOpenCreate(false);
|
|
166
|
+
}), children: "ok" })
|
|
167
|
+
] }) });
|
|
168
|
+
};
|
|
169
|
+
const ListViewActions = () => {
|
|
170
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
171
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(MtButton, { variant: "ghost", className: "m-0 flex h-10 w-10 items-center justify-center border p-0 shadow-sm backdrop-blur", children: /* @__PURE__ */ jsx(Icons.ellipsis, {}) }) }),
|
|
172
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56", children: [
|
|
173
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Edit" }),
|
|
174
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
175
|
+
/* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
176
|
+
/* @__PURE__ */ jsx(PanelRemove, {}),
|
|
177
|
+
/* @__PURE__ */ jsx(PanelCreate, {}),
|
|
178
|
+
/* @__PURE__ */ jsx(CurdCreatePanel, {}),
|
|
179
|
+
/* @__PURE__ */ jsx(CurdEditPanel, {}),
|
|
180
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-yellow-100 p-2", children: [
|
|
181
|
+
/* @__PURE__ */ jsx(CurdEditPanelTriggerButton, {}),
|
|
182
|
+
/* @__PURE__ */ jsx(CurdCreatePanelTriggerButton, {})
|
|
183
|
+
] })
|
|
184
|
+
] }) }) }),
|
|
185
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {})
|
|
186
|
+
] })
|
|
187
|
+
] });
|
|
188
|
+
};
|
|
189
|
+
export {
|
|
190
|
+
CommonListView,
|
|
191
|
+
ListViewActions,
|
|
192
|
+
ListViewProvider,
|
|
193
|
+
useDetail,
|
|
194
|
+
useListView
|
|
195
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { jsx } from "react/jsx-runtime";
|
|
33
|
+
import { PrefetchConnectInfiniteQuery } from "../../components/SSR";
|
|
34
|
+
import { siteList } from "../../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
|
|
35
|
+
import { ListViewProvider } from "./ListViewProvider";
|
|
36
|
+
function MtListView(props) {
|
|
37
|
+
const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
|
|
38
|
+
return /* @__PURE__ */ jsx(ListViewProvider, __spreadProps(__spreadValues({}, etc), { children: /* @__PURE__ */ jsx(
|
|
39
|
+
PrefetchConnectInfiniteQuery,
|
|
40
|
+
{
|
|
41
|
+
svc: siteList.service.typeName,
|
|
42
|
+
method: siteList.name,
|
|
43
|
+
input: etc.params,
|
|
44
|
+
children
|
|
45
|
+
}
|
|
46
|
+
) }));
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
MtListView as default
|
|
50
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface goMtmQueryFnProps {
|
|
2
|
+
svc: string;
|
|
3
|
+
method: string;
|
|
4
|
+
input?: any;
|
|
5
|
+
options?: {
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare const goMtmQueryFn: (props: goMtmQueryFnProps) => Promise<any>;
|
|
10
|
+
export declare const useGomtmQuery: (svc: string, method: string, input?: any) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
11
|
+
export declare const useGomtmSuspenseQuery: (svc: string, method: string, input?: any) => import("@tanstack/react-query").UseSuspenseQueryResult<any, Error>;
|
|
12
|
+
export declare const useGomtmSuspenseInfiniteQuery: (svc: string, method: string, input?: any) => import("@tanstack/react-query").UseSuspenseInfiniteQueryResult<import("@tanstack/react-query").InfiniteData<any, unknown>, Error>;
|
|
13
|
+
export declare const useGomtmMutation: (svc: string, method: string) => import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
|
|
14
|
+
export {};
|