gomtm 0.0.344 → 0.0.346
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 +2 -2
- package/dist/esm/components/SSR.js +9 -9
- package/dist/esm/curd/CurdView.d.ts +17 -0
- package/dist/esm/curd/CurdView.js +98 -0
- package/dist/esm/curd/CurdViewSS.d.ts +4 -0
- package/dist/esm/curd/CurdViewSS.js +66 -0
- package/dist/esm/curd/listview/CommonListView.js +1 -37
- package/dist/esm/curd/listview/CommonListViewV2.d.ts +5 -0
- package/dist/esm/curd/listview/CommonListViewV2.js +66 -0
- package/dist/esm/curd/listview/ListViewRender.js +1 -1
- package/dist/esm/curd/listview/list-store.d.ts +5 -2
- package/dist/esm/curd/remove/RemovePanel.js +12 -5
- package/dist/esm/gomtmQuery.d.ts +4 -3
- package/dist/esm/gomtmQuery.js +30 -9
- package/dist/esm/ly/LayoutBase.js +16 -26
- package/dist/esm/mtmFetcher.d.ts +3 -2
- package/dist/esm/mtmFetcher.js +4 -3
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PropsWithChildren } from "react";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function PrefetchConnectQuery(props: {
|
|
3
3
|
svc: string;
|
|
4
4
|
method: string;
|
|
5
5
|
input?: any;
|
|
6
6
|
} & PropsWithChildren): Promise<import("react").JSX.Element>;
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function PrefetchConnectInfiniteQuery(props: {
|
|
8
8
|
svc: string;
|
|
9
9
|
method: string;
|
|
10
10
|
input?: any;
|
|
@@ -37,34 +37,34 @@ var __async = (__this, __arguments, generator) => {
|
|
|
37
37
|
import { jsx } from "react/jsx-runtime";
|
|
38
38
|
import { HydrationBoundary, QueryClient, dehydrate } from "@tanstack/react-query";
|
|
39
39
|
import { createInfiniteQueryKey, createQueryKey, goMtmQueryFn } from "../mtmFetcher";
|
|
40
|
-
function
|
|
40
|
+
function PrefetchConnectQuery(props) {
|
|
41
41
|
return __async(this, null, function* () {
|
|
42
42
|
const { svc, method, input, children } = props;
|
|
43
43
|
const queryClient = new QueryClient();
|
|
44
|
-
const queryKey =
|
|
44
|
+
const queryKey = createQueryKey(svc, method, input);
|
|
45
45
|
const data = yield goMtmQueryFn({ svc, method, input });
|
|
46
|
-
yield queryClient.
|
|
46
|
+
yield queryClient.prefetchQuery({
|
|
47
47
|
queryKey,
|
|
48
48
|
queryFn: (k) => __async(this, null, function* () {
|
|
49
49
|
return data;
|
|
50
|
-
})
|
|
51
|
-
initialPageParam: __spreadValues({}, input)
|
|
50
|
+
})
|
|
52
51
|
});
|
|
53
52
|
const dehydratedState = dehydrate(queryClient);
|
|
54
53
|
return /* @__PURE__ */ jsx(HydrationBoundary, { state: dehydratedState, children });
|
|
55
54
|
});
|
|
56
55
|
}
|
|
57
|
-
function
|
|
56
|
+
function PrefetchConnectInfiniteQuery(props) {
|
|
58
57
|
return __async(this, null, function* () {
|
|
59
58
|
const { svc, method, input, children } = props;
|
|
60
59
|
const queryClient = new QueryClient();
|
|
61
|
-
const queryKey =
|
|
60
|
+
const queryKey = createInfiniteQueryKey(svc, method, input);
|
|
62
61
|
const data = yield goMtmQueryFn({ svc, method, input });
|
|
63
|
-
yield queryClient.
|
|
62
|
+
yield queryClient.prefetchInfiniteQuery({
|
|
64
63
|
queryKey,
|
|
65
64
|
queryFn: (k) => __async(this, null, function* () {
|
|
66
65
|
return data;
|
|
67
|
-
})
|
|
66
|
+
}),
|
|
67
|
+
initialPageParam: __spreadValues({}, input)
|
|
68
68
|
});
|
|
69
69
|
const dehydratedState = dehydrate(queryClient);
|
|
70
70
|
return /* @__PURE__ */ jsx(HydrationBoundary, { state: dehydratedState, children });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PlainMessage } from "@bufbuild/protobuf";
|
|
3
|
+
import { CurdView } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
4
|
+
interface CurdViewProps {
|
|
5
|
+
backendUrl?: string;
|
|
6
|
+
curdView: PlainMessage<CurdView>;
|
|
7
|
+
}
|
|
8
|
+
export interface ListViewState extends CurdViewProps {
|
|
9
|
+
}
|
|
10
|
+
export declare const curdViewContext: import("react").Context<import("zustand").StoreApi<ListViewState> | null>;
|
|
11
|
+
type CurdViewProviderProps = React.PropsWithChildren<CurdViewProps>;
|
|
12
|
+
export declare const CurdViewProvider: (props: CurdViewProviderProps) => import("react").JSX.Element;
|
|
13
|
+
export declare function useCurdView<T>(selector: (state: ListViewState) => T): T;
|
|
14
|
+
export declare const CurdViewView: (props: {
|
|
15
|
+
name: string;
|
|
16
|
+
}) => import("react").JSX.Element | null;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
import { jsx } from "react/jsx-runtime";
|
|
34
|
+
import { toPlainMessage } from "@bufbuild/protobuf";
|
|
35
|
+
import { Suspense, createContext, useContext, useRef } from "react";
|
|
36
|
+
import { createStore, useStore } from "zustand";
|
|
37
|
+
import { useSuspenseQuery } from "../connectquery";
|
|
38
|
+
import { curdViewGet } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
|
|
39
|
+
import { CurdView } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
40
|
+
import { CommonListViewV2 } from "./listview/CommonListViewV2";
|
|
41
|
+
import { ListViewStoreProvider } from "./listview/list-store";
|
|
42
|
+
const createListviewStore = (initProps) => {
|
|
43
|
+
const DEFAULT_PROPS = {
|
|
44
|
+
backendUrl: "",
|
|
45
|
+
curdView: toPlainMessage(new CurdView())
|
|
46
|
+
};
|
|
47
|
+
return createStore()((set, get) => __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_PROPS), initProps), {
|
|
48
|
+
openRemove: false,
|
|
49
|
+
nextPage: () => {
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
const curdViewContext = createContext(null);
|
|
54
|
+
const CurdViewProvider = (props) => {
|
|
55
|
+
const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
|
|
56
|
+
const storeRef = useRef();
|
|
57
|
+
if (!storeRef.current) {
|
|
58
|
+
storeRef.current = createListviewStore(props);
|
|
59
|
+
}
|
|
60
|
+
return /* @__PURE__ */ jsx(curdViewContext.Provider, { value: storeRef.current, children });
|
|
61
|
+
};
|
|
62
|
+
function useCurdView(selector) {
|
|
63
|
+
const store = useContext(curdViewContext);
|
|
64
|
+
if (!store)
|
|
65
|
+
throw new Error("useCurd Missing CurdViewProvider in the tree");
|
|
66
|
+
return useStore(store, selector);
|
|
67
|
+
}
|
|
68
|
+
const CurdViewView = (props) => {
|
|
69
|
+
const { name } = props;
|
|
70
|
+
const query = useSuspenseQuery(curdViewGet, { name });
|
|
71
|
+
if (!query.data) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
switch (query.data.item.case) {
|
|
75
|
+
case "error":
|
|
76
|
+
return /* @__PURE__ */ jsx("div", { children: "error222" });
|
|
77
|
+
default:
|
|
78
|
+
if (!query.data.item.value) {
|
|
79
|
+
return /* @__PURE__ */ jsx("div", { children: "missing curd data222" });
|
|
80
|
+
}
|
|
81
|
+
const curdViewData = query.data.item.value;
|
|
82
|
+
return /* @__PURE__ */ jsx("div", { className: "bg-red-100 p-2", children: /* @__PURE__ */ jsx(CurdViewProvider, { curdView: curdViewData, children: /* @__PURE__ */ jsx(
|
|
83
|
+
ListViewStoreProvider,
|
|
84
|
+
{
|
|
85
|
+
slugPath: "/post",
|
|
86
|
+
svc: curdViewData.svcName,
|
|
87
|
+
methodList: curdViewData.methodList,
|
|
88
|
+
children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading CommonListViewV2" }), children: /* @__PURE__ */ jsx(CommonListViewV2, {}) })
|
|
89
|
+
}
|
|
90
|
+
) }) });
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
export {
|
|
94
|
+
CurdViewProvider,
|
|
95
|
+
CurdViewView,
|
|
96
|
+
curdViewContext,
|
|
97
|
+
useCurdView
|
|
98
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { Suspense } from "react";
|
|
23
|
+
import { MtmService } from "../../src/gomtmpb/mtm/sppb/mtm_connect";
|
|
24
|
+
import { PrefetchConnectInfiniteQuery, PrefetchConnectQuery } from "../components/SSR";
|
|
25
|
+
import { curdViewGet } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
|
|
26
|
+
import { CurdViewGetReq } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
27
|
+
import { createMtmServiceClient } from "../mtmFetcher";
|
|
28
|
+
import { CurdViewView } from "./CurdView";
|
|
29
|
+
const CurdViewSS = (props) => __async(void 0, null, function* () {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const { name } = props;
|
|
32
|
+
const client = createMtmServiceClient(MtmService);
|
|
33
|
+
const curdViewRes = yield client.curdViewGet(new CurdViewGetReq({
|
|
34
|
+
name
|
|
35
|
+
}));
|
|
36
|
+
if (curdViewRes.item.case == "error") {
|
|
37
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
38
|
+
"error ",
|
|
39
|
+
curdViewRes.item.value.message
|
|
40
|
+
] });
|
|
41
|
+
}
|
|
42
|
+
const svc = ((_a = curdViewRes.item.value) == null ? void 0 : _a.svcName) || "";
|
|
43
|
+
const methodList = ((_b = curdViewRes.item.value) == null ? void 0 : _b.methodList) || "";
|
|
44
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
45
|
+
PrefetchConnectQuery,
|
|
46
|
+
{
|
|
47
|
+
svc: curdViewGet.service.typeName,
|
|
48
|
+
method: curdViewGet.name,
|
|
49
|
+
input: {
|
|
50
|
+
name
|
|
51
|
+
},
|
|
52
|
+
children: /* @__PURE__ */ jsx(
|
|
53
|
+
PrefetchConnectInfiniteQuery,
|
|
54
|
+
{
|
|
55
|
+
svc,
|
|
56
|
+
method: methodList,
|
|
57
|
+
input: {},
|
|
58
|
+
children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading CurdViewView" }), children: /* @__PURE__ */ jsx(CurdViewView, { name }) })
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
) });
|
|
63
|
+
});
|
|
64
|
+
export {
|
|
65
|
+
CurdViewSS
|
|
66
|
+
};
|
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Icons } from "mtxuilib/icons/icons";
|
|
4
4
|
import { cn } from "mtxuilib/lib/utils";
|
|
5
|
-
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
6
5
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
7
6
|
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
|
|
8
7
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
9
|
-
import { Suspense, lazy
|
|
10
|
-
import { useHotkeys } from "react-hotkeys-hook";
|
|
8
|
+
import { Suspense, lazy } from "react";
|
|
11
9
|
import { MtmErrorView } from "../../components/MtmErrorView";
|
|
12
|
-
import { HOTKEY_Listview_Switchlayout } from "../../consts";
|
|
13
10
|
import { useGomtmSuspenseInfiniteQuery } from "../../gomtmQuery";
|
|
14
11
|
import { CurdCreatePanelTriggerButton } from "../create/CurdCreatePanel";
|
|
15
12
|
import { CommontListResView } from "../list-item/ListViewLayoutRender";
|
|
@@ -68,39 +65,6 @@ const ListViewActions = () => {
|
|
|
68
65
|
] })
|
|
69
66
|
] });
|
|
70
67
|
};
|
|
71
|
-
const ListViewLayout = (props) => {
|
|
72
|
-
const layout = useListview((x) => x.layout);
|
|
73
|
-
const { children } = props;
|
|
74
|
-
const Layout = useMemo(() => {
|
|
75
|
-
switch (layout) {
|
|
76
|
-
case "demo":
|
|
77
|
-
return LzListViewLayoutDemo;
|
|
78
|
-
default:
|
|
79
|
-
return LzListViewLayoutDefault;
|
|
80
|
-
}
|
|
81
|
-
}, [layout]);
|
|
82
|
-
return /* @__PURE__ */ jsx(Layout, { children });
|
|
83
|
-
};
|
|
84
|
-
const ListViewLayoutSwitch = () => {
|
|
85
|
-
const layout = useListview((x) => x.layout);
|
|
86
|
-
const setLayout = useListview((x) => x.setLayout);
|
|
87
|
-
const [open, setOpen] = useState(false);
|
|
88
|
-
useHotkeys(HOTKEY_Listview_Switchlayout, () => {
|
|
89
|
-
setOpen((pre) => !pre);
|
|
90
|
-
}, [open, setOpen]);
|
|
91
|
-
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
92
|
-
/* @__PURE__ */ jsxs(DialogTitle, { children: [
|
|
93
|
-
"LayoutSwitch,",
|
|
94
|
-
layout
|
|
95
|
-
] }),
|
|
96
|
-
/* @__PURE__ */ jsx("div", { className: "flex gap-2 bg-red-100 p-2", children: ALL_Layouts.map((layout2) => {
|
|
97
|
-
return /* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
98
|
-
setLayout(layout2);
|
|
99
|
-
setOpen(false);
|
|
100
|
-
}, children: layout2 }, layout2);
|
|
101
|
-
}) })
|
|
102
|
-
] }) });
|
|
103
|
-
};
|
|
104
68
|
export {
|
|
105
69
|
CommonListView,
|
|
106
70
|
ListViewActions,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const LzListViewLayoutDemo: import("react").LazyExoticComponent<typeof import("./listview-layouts/listviewlayout-demo").default>;
|
|
3
|
+
export declare const LzListViewLayoutDefault: import("react").LazyExoticComponent<typeof import("./listview-layouts/default").default>;
|
|
4
|
+
export declare function CommonListViewV2(): import("react").JSX.Element | null;
|
|
5
|
+
export declare const ListViewActions: () => import("react").JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Icons } from "mtxuilib/icons/icons";
|
|
4
|
+
import { cn } from "mtxuilib/lib/utils";
|
|
5
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
6
|
+
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
|
|
7
|
+
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
8
|
+
import { Suspense, lazy } from "react";
|
|
9
|
+
import { MtmErrorView } from "../../components/MtmErrorView";
|
|
10
|
+
import { useGomtmSuspenseInfiniteQuery } from "../../gomtmQuery";
|
|
11
|
+
import { useCurdView } from "../CurdView";
|
|
12
|
+
import { CommontListResView } from "../list-item/ListViewLayoutRender";
|
|
13
|
+
const LzListViewLayoutDemo = lazy(() => import("./listview-layouts/listviewlayout-demo"));
|
|
14
|
+
const LzListViewLayoutDefault = lazy(() => import("./listview-layouts/default"));
|
|
15
|
+
function CommonListViewV2() {
|
|
16
|
+
const curdView = useCurdView((x) => x.curdView);
|
|
17
|
+
const listQuery = useGomtmSuspenseInfiniteQuery(curdView.svcName, curdView == null ? void 0 : curdView.methodList, {});
|
|
18
|
+
if (!(listQuery == null ? void 0 : listQuery.data)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
22
|
+
/* @__PURE__ */ jsx(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
className: cn(
|
|
26
|
+
"w-full"
|
|
27
|
+
// 滚动设置
|
|
28
|
+
// " max-h-[700px] overflow-y-auto"
|
|
29
|
+
),
|
|
30
|
+
children: listQuery.data.pages.map((page, i) => {
|
|
31
|
+
if (page.errCode) {
|
|
32
|
+
return /* @__PURE__ */ jsx(MtmErrorView, { unaryError: page }, i);
|
|
33
|
+
} else {
|
|
34
|
+
return /* @__PURE__ */ jsx(CommontListResView, { data: page }, i);
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
listQuery.data.pages && !!listQuery.data.pages.length && /* @__PURE__ */ jsx(Pagination, { children: /* @__PURE__ */ jsxs(PaginationContent, { children: [
|
|
40
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationPrevious, { href: "#" }) }),
|
|
41
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { href: "#", children: "1" }) }),
|
|
42
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { href: "#", isActive: true, children: "2" }) }),
|
|
43
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { href: "#", children: "3" }) }),
|
|
44
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationEllipsis, {}) }),
|
|
45
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationNext, { href: "#" }) })
|
|
46
|
+
] }) }),
|
|
47
|
+
/* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1" })
|
|
48
|
+
] });
|
|
49
|
+
}
|
|
50
|
+
const ListViewActions = () => {
|
|
51
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
52
|
+
/* @__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, {}) }) }),
|
|
53
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56", children: [
|
|
54
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: "List \u64CD\u4F5C" }),
|
|
55
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
56
|
+
/* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ jsx("div", { className: "bg-yellow-100 p-2" }) }) }) }),
|
|
57
|
+
/* @__PURE__ */ jsx(DropdownMenuSeparator, {})
|
|
58
|
+
] })
|
|
59
|
+
] });
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
CommonListViewV2,
|
|
63
|
+
ListViewActions,
|
|
64
|
+
LzListViewLayoutDefault,
|
|
65
|
+
LzListViewLayoutDemo
|
|
66
|
+
};
|
|
@@ -10,7 +10,7 @@ const ListViewRender = (props) => {
|
|
|
10
10
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11
11
|
/* @__PURE__ */ jsx(CommonListView, {}),
|
|
12
12
|
/* @__PURE__ */ jsxs(Suspense, { children: [
|
|
13
|
-
/* @__PURE__ */ jsx(CurdCreatePanel, {}),
|
|
13
|
+
/* @__PURE__ */ jsx(CurdCreatePanel, { fullScreen: true }),
|
|
14
14
|
/* @__PURE__ */ jsx(CurdEditPanel, { fullScreen: true }),
|
|
15
15
|
/* @__PURE__ */ jsx(PanelRemove, {})
|
|
16
16
|
] }),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Renderable } from 'mtxuilib/lib/render';
|
|
2
2
|
import { ComponentProps, PropsWithChildren } from 'react';
|
|
3
|
+
import { PlainMessage } from '@bufbuild/protobuf';
|
|
4
|
+
import { CurdView } from '../../gomtmpb/mtm/sppb/mtm_pb';
|
|
3
5
|
interface ListViewStateProps {
|
|
4
6
|
backendUrl?: string;
|
|
5
7
|
svc: string;
|
|
@@ -20,6 +22,7 @@ interface ListViewStateProps {
|
|
|
20
22
|
editorComponentName?: string;
|
|
21
23
|
createRender?: Renderable<any>;
|
|
22
24
|
createComponentName?: string;
|
|
25
|
+
curdView?: PlainMessage<CurdView>;
|
|
23
26
|
}
|
|
24
27
|
export interface ListViewState extends ListViewStateProps {
|
|
25
28
|
openRemove: boolean;
|
|
@@ -41,6 +44,6 @@ type BearProviderProps = React.PropsWithChildren<ListViewStateProps>;
|
|
|
41
44
|
export declare const ListViewStoreProvider: (props: BearProviderProps) => import("react").JSX.Element;
|
|
42
45
|
export declare const ListView: (props: Omit<ComponentProps<typeof ListViewStoreProvider>, 'backendUrl'> & PropsWithChildren) => import("react").JSX.Element;
|
|
43
46
|
export declare function useListview<T>(selector: (state: ListViewState) => T): T;
|
|
44
|
-
export declare const useCurdUpdateMutation: () => import("@tanstack/react-query").UseMutationResult<
|
|
45
|
-
export declare const useCurdCreateMutation: () => import("@tanstack/react-query").UseMutationResult<
|
|
47
|
+
export declare const useCurdUpdateMutation: () => import("@tanstack/react-query").UseMutationResult<unknown, any, any, any>;
|
|
48
|
+
export declare const useCurdCreateMutation: () => import("@tanstack/react-query").UseMutationResult<unknown, any, any, any>;
|
|
46
49
|
export {};
|
|
@@ -26,13 +26,23 @@ import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
|
26
26
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
27
27
|
import { useCallback } from "react";
|
|
28
28
|
import { useGomtmMutation } from "../../gomtmQuery";
|
|
29
|
+
import { createQueryKey } from "../../mtmFetcher";
|
|
29
30
|
import { useListview } from "../listview/list-store";
|
|
30
31
|
function useCurdRemove() {
|
|
31
32
|
const svc = useListview((x) => x.svc);
|
|
32
33
|
const openRemove = useListview((x) => x.openRemove);
|
|
33
34
|
const setOpenRemove = useListview((x) => x.setOpenRemove);
|
|
34
35
|
const methodDelete = useListview((x) => x.methodDelete);
|
|
35
|
-
const
|
|
36
|
+
const methodList = useListview((x) => x.methodList);
|
|
37
|
+
const mutation = useGomtmMutation(svc, methodDelete, {
|
|
38
|
+
onSuccess(data, variables, context) {
|
|
39
|
+
console.log("remove sucess", data);
|
|
40
|
+
queryClient.invalidateQueries({
|
|
41
|
+
queryKey: createQueryKey(svc, methodList)
|
|
42
|
+
});
|
|
43
|
+
setOpenRemove(false);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
36
46
|
const activateItem = useListview((x) => x.activateItem);
|
|
37
47
|
const router = useMtRouter();
|
|
38
48
|
const queryClient = useQueryClient();
|
|
@@ -40,10 +50,7 @@ function useCurdRemove() {
|
|
|
40
50
|
yield mutation.mutateAsync({
|
|
41
51
|
id: activateItem == null ? void 0 : activateItem.id
|
|
42
52
|
});
|
|
43
|
-
|
|
44
|
-
router.refresh();
|
|
45
|
-
queryClient.invalidateQueries();
|
|
46
|
-
}), [activateItem == null ? void 0 : activateItem.id, mutation, queryClient, router, setOpenRemove]);
|
|
53
|
+
}), [activateItem == null ? void 0 : activateItem.id, mutation]);
|
|
47
54
|
return {
|
|
48
55
|
handlerSubmit,
|
|
49
56
|
open: openRemove,
|
package/dist/esm/gomtmQuery.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PlainMessage } from "@bufbuild/protobuf";
|
|
2
|
+
import { DefaultError, UseMutationOptions } from "@tanstack/react-query";
|
|
2
3
|
import { MtmError } from "./gomtmpb/mtm/sppb/mtm_pb";
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
4
|
+
export declare function useGomtmQuery<T = any>(svc: string, method: string, input?: any): import("@tanstack/react-query").UseQueryResult<T, Error>;
|
|
5
|
+
export declare function useGomtmSuspenseQuery<T = any>(svc: string, method: string, input?: any): import("@tanstack/react-query").UseSuspenseQueryResult<T, Error>;
|
|
5
6
|
export declare function useGomtmSuspenseInfiniteQuery<T = any>(svc: string, method: string, input?: any): import("@tanstack/react-query").UseSuspenseInfiniteQueryResult<import("@tanstack/react-query").InfiniteData<T & PlainMessage<MtmError>, unknown>, Error>;
|
|
6
|
-
export declare
|
|
7
|
+
export declare function useGomtmMutation<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(svc: string, method: string, options?: UseMutationOptions): import("@tanstack/react-query").UseMutationResult<TData, any, any, any>;
|
package/dist/esm/gomtmQuery.js
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
2
21
|
import { useMutation, useQuery, useSuspenseInfiniteQuery, useSuspenseQuery } from "@tanstack/react-query";
|
|
3
22
|
import { MTM_API_PREFIX } from "./consts";
|
|
4
23
|
import { createInfiniteQueryKey, createQueryKey, goMtmQueryFn } from "./mtmFetcher";
|
|
@@ -8,6 +27,7 @@ const useGmtmQjeryFn = () => {
|
|
|
8
27
|
const cookieStr = useGomtm((x) => x.cookieStr);
|
|
9
28
|
const token = useGomtm((x) => x.token);
|
|
10
29
|
const gomtmHost = useGomtm((x) => x.gomtmHost);
|
|
30
|
+
const cacheEnabled = useGomtm((x) => x.cacheEnabled);
|
|
11
31
|
return (svc, method, input) => {
|
|
12
32
|
return goMtmQueryFn({
|
|
13
33
|
svc,
|
|
@@ -17,25 +37,26 @@ const useGmtmQjeryFn = () => {
|
|
|
17
37
|
url: new URL(MTM_API_PREFIX, backendUrl).toString(),
|
|
18
38
|
token,
|
|
19
39
|
cookieStr,
|
|
20
|
-
gomtmHost
|
|
40
|
+
gomtmHost,
|
|
41
|
+
cacheEnabled: !!cacheEnabled
|
|
21
42
|
}
|
|
22
43
|
});
|
|
23
44
|
};
|
|
24
45
|
};
|
|
25
|
-
|
|
46
|
+
function useGomtmQuery(svc, method, input) {
|
|
26
47
|
const fn = useGmtmQjeryFn();
|
|
27
48
|
return useQuery({
|
|
28
49
|
queryKey: createQueryKey(svc, method, input),
|
|
29
50
|
queryFn: (k) => fn(svc, method, input)
|
|
30
51
|
});
|
|
31
|
-
}
|
|
32
|
-
|
|
52
|
+
}
|
|
53
|
+
function useGomtmSuspenseQuery(svc, method, input) {
|
|
33
54
|
const fn = useGmtmQjeryFn();
|
|
34
55
|
return useSuspenseQuery({
|
|
35
56
|
queryKey: createQueryKey(svc, method, input),
|
|
36
57
|
queryFn: (k) => fn(svc, method, input)
|
|
37
58
|
});
|
|
38
|
-
}
|
|
59
|
+
}
|
|
39
60
|
function useGomtmSuspenseInfiniteQuery(svc, method, input) {
|
|
40
61
|
const fn = useGmtmQjeryFn();
|
|
41
62
|
return useSuspenseInfiniteQuery({
|
|
@@ -47,12 +68,12 @@ function useGomtmSuspenseInfiniteQuery(svc, method, input) {
|
|
|
47
68
|
}
|
|
48
69
|
});
|
|
49
70
|
}
|
|
50
|
-
|
|
71
|
+
function useGomtmMutation(svc, method, options) {
|
|
51
72
|
const fn = useGmtmQjeryFn();
|
|
52
|
-
return useMutation({
|
|
73
|
+
return useMutation(__spreadProps(__spreadValues({}, options), {
|
|
53
74
|
mutationFn: (input) => fn(svc, method, input)
|
|
54
|
-
});
|
|
55
|
-
}
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
56
77
|
export {
|
|
57
78
|
useGomtmMutation,
|
|
58
79
|
useGomtmQuery,
|
|
@@ -6,7 +6,6 @@ import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
|
6
6
|
import { TooltipProvider } from "mtxuilib/ui/tooltip";
|
|
7
7
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
8
8
|
import { AppProgressBar as ProgressBar } from "next-nprogress-bar";
|
|
9
|
-
import { ThemeProvider } from "next-themes";
|
|
10
9
|
import { Suspense, lazy, useMemo, useState } from "react";
|
|
11
10
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
12
11
|
import { Toaster } from "sonner";
|
|
@@ -38,31 +37,22 @@ const LayoutBase = (props) => {
|
|
|
38
37
|
return LzFrontLayout;
|
|
39
38
|
}
|
|
40
39
|
}, [layout]);
|
|
41
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
),
|
|
59
|
-
/* @__PURE__ */ jsx(ReactQueryDevtools, {}),
|
|
60
|
-
/* @__PURE__ */ jsx(Toaster, {}),
|
|
61
|
-
/* @__PURE__ */ jsx(TailwindIndicator, {}),
|
|
62
|
-
/* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(LayoutSwitchDlg, {}) })
|
|
63
|
-
] })
|
|
64
|
-
}
|
|
65
|
-
) });
|
|
40
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(TooltipProvider, { delayDuration: 0, children: [
|
|
41
|
+
/* @__PURE__ */ jsx(LayoutComponent, { children }),
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
ProgressBar,
|
|
44
|
+
{
|
|
45
|
+
height: "4px",
|
|
46
|
+
color: "#4934eb",
|
|
47
|
+
options: { showSpinner: false },
|
|
48
|
+
shallowRouting: true
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ jsx(ReactQueryDevtools, {}),
|
|
52
|
+
/* @__PURE__ */ jsx(Toaster, {}),
|
|
53
|
+
/* @__PURE__ */ jsx(TailwindIndicator, {}),
|
|
54
|
+
/* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(LayoutSwitchDlg, {}) })
|
|
55
|
+
] }) });
|
|
66
56
|
};
|
|
67
57
|
const LayoutSwitchDlg = () => {
|
|
68
58
|
const layout = useGomtm((x) => x.layout);
|
package/dist/esm/mtmFetcher.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServiceType } from "@bufbuild/protobuf";
|
|
2
|
-
export declare const createQueryKey: (svc: string, method: string, input
|
|
2
|
+
export declare const createQueryKey: (svc: string, method: string, input?: any) => any[];
|
|
3
3
|
export declare const createInfiniteQueryKey: (svc: string, method: string, input: any) => any[];
|
|
4
4
|
interface goMtmQueryFnProps {
|
|
5
5
|
svc: string;
|
|
@@ -10,6 +10,7 @@ interface goMtmQueryFnProps {
|
|
|
10
10
|
token?: string;
|
|
11
11
|
cookieStr?: string;
|
|
12
12
|
gomtmHost: string;
|
|
13
|
+
cacheEnabled?: boolean;
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
export declare const goMtmQueryFn: (props: goMtmQueryFnProps) => Promise<any>;
|
|
@@ -17,7 +18,7 @@ export declare const ssrGetBackendUrl: () => string;
|
|
|
17
18
|
export declare const gomtmApiUrl: () => string;
|
|
18
19
|
export declare function createMtmServiceClient<T extends ServiceType>(service: T, url?: string): import("@connectrpc/connect").PromiseClient<T>;
|
|
19
20
|
export declare function createTransport(): import("@connectrpc/connect").Transport;
|
|
20
|
-
export declare function createMtmServiceClientByName<T extends ServiceType>(svcName: string, url?: string, token?: string, gomtmHost?: string): import("@connectrpc/connect").PromiseClient<ServiceType>;
|
|
21
|
+
export declare function createMtmServiceClientByName<T extends ServiceType>(svcName: string, url?: string, token?: string, gomtmHost?: string, cacheEnabled?: boolean): import("@connectrpc/connect").PromiseClient<ServiceType>;
|
|
21
22
|
type CustomRequestInit = RequestInit & {
|
|
22
23
|
cookieStr?: string;
|
|
23
24
|
token?: string;
|
package/dist/esm/mtmFetcher.js
CHANGED
|
@@ -107,7 +107,7 @@ function createTransport() {
|
|
|
107
107
|
useHttpGet: true
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
function createMtmServiceClientByName(svcName, url, token, gomtmHost) {
|
|
110
|
+
function createMtmServiceClientByName(svcName, url, token, gomtmHost, cacheEnabled) {
|
|
111
111
|
let svcType = void 0;
|
|
112
112
|
for (const a of allServices) {
|
|
113
113
|
if (a.typeName == svcName) {
|
|
@@ -125,7 +125,8 @@ function createMtmServiceClientByName(svcName, url, token, gomtmHost) {
|
|
|
125
125
|
fetch: gomtmFetcher({
|
|
126
126
|
cookieStr: token,
|
|
127
127
|
token,
|
|
128
|
-
gomtmHost
|
|
128
|
+
gomtmHost,
|
|
129
|
+
enableCache: cacheEnabled
|
|
129
130
|
})
|
|
130
131
|
})
|
|
131
132
|
);
|
|
@@ -162,7 +163,7 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
162
163
|
}, cookieStr1 && { "Cookie": cookieStr1 }), token && { "Authorization": "Bearer " + token }), gomtmHost && { [CONST_HeaderMtmHost]: gomtmHost })
|
|
163
164
|
});
|
|
164
165
|
let fetcher = fetch;
|
|
165
|
-
req.enableCache =
|
|
166
|
+
req.enableCache = initGlobal == null ? void 0 : initGlobal.enableCache;
|
|
166
167
|
if (req.enableCache) {
|
|
167
168
|
fetcher = fetchMiddleWithCache(fetch);
|
|
168
169
|
}
|