gomtm 0.0.267 → 0.0.268
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/devtools/GoMtmDebug.d.ts +2 -0
- package/dist/esm/components/devtools/GoMtmDebug.js +28 -0
- package/dist/esm/consts.d.ts +1 -0
- package/dist/esm/consts.js +2 -0
- package/dist/esm/curd/ListViewProvider.d.ts +7 -3
- package/dist/esm/curd/ListViewProvider.js +20 -9
- package/dist/esm/ly/LayoutBase.js +1 -4
- package/dist/esm/ly/front-layout/PageSearchCmd.js +8 -0
- package/dist/esm/providers/GomtmProvider.d.ts +6 -0
- package/dist/esm/providers/GomtmProvider.js +38 -5
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CommandDialog, CommandEmpty, CommandInput, CommandList, CommandSeparator } from "mtxuilib/ui/command";
|
|
4
|
+
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import { useMtmApp } from "../../providers/GomtmProvider";
|
|
7
|
+
const GoMtmDebug = () => {
|
|
8
|
+
const [open, setOpen] = useState(false);
|
|
9
|
+
const mtapp = useMtmApp();
|
|
10
|
+
if (!mtapp.isDebug) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return /* @__PURE__ */ jsxs("div", { className: "fixed bottom-12 right-4 bg-red-300 p-2", children: [
|
|
14
|
+
/* @__PURE__ */ jsx(MtButton, { children: "appDebug" }),
|
|
15
|
+
/* @__PURE__ */ jsxs(CommandDialog, { open, onOpenChange: setOpen, children: [
|
|
16
|
+
/* @__PURE__ */ jsx(CommandInput, { placeholder: "Type a command or search...", onValueChange: (s) => {
|
|
17
|
+
setOpen(false);
|
|
18
|
+
} }),
|
|
19
|
+
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
20
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: "No results found." }),
|
|
21
|
+
/* @__PURE__ */ jsx(CommandSeparator, {})
|
|
22
|
+
] })
|
|
23
|
+
] })
|
|
24
|
+
] });
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
GoMtmDebug
|
|
28
|
+
};
|
package/dist/esm/consts.d.ts
CHANGED
package/dist/esm/consts.js
CHANGED
|
@@ -26,6 +26,7 @@ const ImageNoExist = "/images/404.jpg";
|
|
|
26
26
|
const ADMIN_ROLE = "admin";
|
|
27
27
|
const MEMBER_ROLE = "member";
|
|
28
28
|
const TRPC_API_PREFIX = "/api.v1/trpc";
|
|
29
|
+
const HOTKEY_Debug = "'alt+j'";
|
|
29
30
|
export {
|
|
30
31
|
ADMIN_ROLE,
|
|
31
32
|
ActionCreate,
|
|
@@ -38,6 +39,7 @@ export {
|
|
|
38
39
|
Cookie_Site_Host,
|
|
39
40
|
DEFAULT_revalidate_SECONDS,
|
|
40
41
|
ExtKey_Hostname,
|
|
42
|
+
HOTKEY_Debug,
|
|
41
43
|
HeaderMtmApi,
|
|
42
44
|
HeaderMtmHost,
|
|
43
45
|
ImageNoExist,
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Message } from "@bufbuild/protobuf";
|
|
2
2
|
import { Dispatch, PropsWithChildren, SetStateAction } from "react";
|
|
3
3
|
import { MethodUnaryDescriptor } from "../connectquery";
|
|
4
|
-
|
|
4
|
+
interface ListViewProps<I extends Message<I>, O extends Message<O>> {
|
|
5
5
|
methodList: MethodUnaryDescriptor<I, any>;
|
|
6
6
|
methodDelete: MethodUnaryDescriptor<any, any>;
|
|
7
7
|
methodCreate?: MethodUnaryDescriptor<any, any>;
|
|
8
8
|
slugPath?: string;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
activateItem?: any;
|
|
10
|
+
params?: any;
|
|
11
|
+
}
|
|
12
|
+
export declare function ListViewProvider<I extends Message<I>, O extends Message<O>>(props: ListViewProps<I, O> & PropsWithChildren): import("react").JSX.Element;
|
|
13
|
+
export declare function useListView<I extends Message<I>, O extends Message<O>>(): {
|
|
11
14
|
methodList?: MethodUnaryDescriptor<any, any> | undefined;
|
|
12
15
|
methodDelete?: MethodUnaryDescriptor<any, any> | undefined;
|
|
13
16
|
methodCreate?: MethodUnaryDescriptor<any, any> | undefined;
|
|
@@ -27,3 +30,4 @@ export declare const useListView: () => {
|
|
|
27
30
|
};
|
|
28
31
|
export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
|
|
29
32
|
export declare const ListViewActions: () => import("react").JSX.Element;
|
|
33
|
+
export {};
|
|
@@ -45,9 +45,10 @@ import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
|
45
45
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
46
46
|
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
|
|
47
47
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
48
|
-
import { Suspense, createContext, useContext, useState } from "react";
|
|
48
|
+
import { Suspense, createContext, useContext, useMemo, useState } from "react";
|
|
49
49
|
import { MtUnaryCallErrorView } from "../components/MtUnaryCallErrorView";
|
|
50
50
|
import { useMutation, useSuspenseInfiniteQuery } from "../connectquery";
|
|
51
|
+
import { useMtmApp } from "../providers/GomtmProvider";
|
|
51
52
|
import { DlgCurdDebugInfo, DlgCurdDebugInfoTriggerButton } from "./CurdDetailProvider";
|
|
52
53
|
import CurdCreatePanel, { CurdCreatePanelTriggerButton } from "./create/CurdCreatePanel";
|
|
53
54
|
import CurdEditPanel, { CurdEditPanelTriggerButton } from "./edit/CurdEditPanel";
|
|
@@ -56,12 +57,19 @@ import { ListLayout } from "./list-item/ListLayout";
|
|
|
56
57
|
const commonListViewContext = createContext(void 0);
|
|
57
58
|
function ListViewProvider(props) {
|
|
58
59
|
const { children, methodList, methodDelete, slugPath, methodCreate } = props;
|
|
60
|
+
const mtapp = useMtmApp();
|
|
59
61
|
const [openRemove, setOpenRemove] = useState(false);
|
|
60
62
|
const [openCreate, setOpenCreate] = useState(false);
|
|
61
63
|
const [activateItem, setActivateItem] = useState(void 0);
|
|
62
64
|
const [openEdit, setOpenEdit] = useState(false);
|
|
63
65
|
const [openDebug, setOpenDebug] = useState(false);
|
|
64
|
-
const [
|
|
66
|
+
const [_params, setParams] = useState(mtapp.globalSearchParams);
|
|
67
|
+
const params = useMemo(() => {
|
|
68
|
+
var _a;
|
|
69
|
+
return {
|
|
70
|
+
q: (_a = mtapp.globalSearchParams) == null ? void 0 : _a.q
|
|
71
|
+
};
|
|
72
|
+
}, [mtapp.globalSearchParams]);
|
|
65
73
|
return /* @__PURE__ */ jsx(commonListViewContext.Provider, { value: {
|
|
66
74
|
methodList,
|
|
67
75
|
slugPath,
|
|
@@ -81,13 +89,16 @@ function ListViewProvider(props) {
|
|
|
81
89
|
setParams
|
|
82
90
|
}, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading list" }), children }) });
|
|
83
91
|
}
|
|
84
|
-
|
|
92
|
+
function useListView() {
|
|
85
93
|
const ctx = useContext(commonListViewContext);
|
|
86
94
|
return __spreadValues({}, ctx);
|
|
87
|
-
}
|
|
95
|
+
}
|
|
88
96
|
function CommonListView() {
|
|
89
|
-
const
|
|
90
|
-
const listQuery = useSuspenseInfiniteQuery(
|
|
97
|
+
const listView = useListView();
|
|
98
|
+
const listQuery = useSuspenseInfiniteQuery(listView.methodList, {
|
|
99
|
+
Params: {
|
|
100
|
+
q: listView.params.q
|
|
101
|
+
},
|
|
91
102
|
pagination: {
|
|
92
103
|
page: 1
|
|
93
104
|
}
|
|
@@ -95,15 +106,15 @@ function CommonListView() {
|
|
|
95
106
|
pageParamKey: "pagination",
|
|
96
107
|
getNextPageParam: (lastPage, allPages, lastPageParam, allPageParams) => {
|
|
97
108
|
var _a;
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
return a2;
|
|
109
|
+
const a = __spreadProps(__spreadValues({}, lastPageParam), { page: (((_a = lastPage.Pagination) == null ? void 0 : _a.page) || 1) + 1 });
|
|
110
|
+
return a;
|
|
101
111
|
}
|
|
102
112
|
});
|
|
103
113
|
if (!(listQuery == null ? void 0 : listQuery.data)) {
|
|
104
114
|
return null;
|
|
105
115
|
}
|
|
106
116
|
return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
117
|
+
JSON.stringify(listView.params, null, 2),
|
|
107
118
|
/* @__PURE__ */ jsx(
|
|
108
119
|
"div",
|
|
109
120
|
{
|
|
@@ -29,10 +29,7 @@ const LayoutBase = (props) => {
|
|
|
29
29
|
" ",
|
|
30
30
|
children,
|
|
31
31
|
" "
|
|
32
|
-
] }) : (
|
|
33
|
-
// layoutName == "front" ? <FrontLayout>{children}</FrontLayout> :
|
|
34
|
-
layoutName == "dash5" ? /* @__PURE__ */ jsx(LzDash5, { children }) : layoutName == "debug" ? /* @__PURE__ */ jsx(LzDebugLayout, { children }) : layoutName == "demo1" ? /* @__PURE__ */ jsx(LzDemoLayout, { children }) : layoutName == "default" ? /* @__PURE__ */ jsx(Fragment, { children }) : children
|
|
35
|
-
),
|
|
32
|
+
] }) : layoutName == "dash5" ? /* @__PURE__ */ jsx(LzDash5, { children }) : layoutName == "debug" ? /* @__PURE__ */ jsx(LzDebugLayout, { children }) : layoutName == "demo1" ? /* @__PURE__ */ jsx(LzDemoLayout, { children }) : layoutName == "default" ? /* @__PURE__ */ jsx(Fragment, { children }) : children,
|
|
36
33
|
/* @__PURE__ */ jsx(
|
|
37
34
|
ProgressBar,
|
|
38
35
|
{
|
|
@@ -26,11 +26,15 @@ import { MtForm } from "mtxuilib/ui/ui-mt/MtForm";
|
|
|
26
26
|
import { useState } from "react";
|
|
27
27
|
import { useForm } from "react-hook-form";
|
|
28
28
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
29
|
+
import { useGlobalsearchParams, useMtmApp } from "../../providers/GomtmProvider";
|
|
29
30
|
const PageSearchCmd = () => {
|
|
31
|
+
var _a;
|
|
30
32
|
const [open, setOpen] = useState(false);
|
|
31
33
|
useHotkeys("alt+s", () => {
|
|
32
34
|
setOpen((open2) => !open2);
|
|
33
35
|
}, []);
|
|
36
|
+
const mtapp = useMtmApp();
|
|
37
|
+
const search = useGlobalsearchParams();
|
|
34
38
|
const form = useForm();
|
|
35
39
|
return /* @__PURE__ */ jsxs(MtForm, __spreadProps(__spreadValues({}, form), { children: [
|
|
36
40
|
/* @__PURE__ */ jsx("form", { onSubmit: form.handleSubmit(() => {
|
|
@@ -42,7 +46,11 @@ const PageSearchCmd = () => {
|
|
|
42
46
|
type: "search",
|
|
43
47
|
placeholder: "Search...",
|
|
44
48
|
className: "bg-background w-full rounded-lg pl-8 md:w-[200px] lg:w-[336px]",
|
|
49
|
+
defaultValue: (_a = search.searchParams) == null ? void 0 : _a.q,
|
|
45
50
|
onChange: (e) => {
|
|
51
|
+
search.setSearchParams({
|
|
52
|
+
q: e.target.value
|
|
53
|
+
});
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
)
|
|
@@ -18,6 +18,8 @@ export declare function useMtmApp(): {
|
|
|
18
18
|
openLayoutSwitchDlg?: boolean | undefined;
|
|
19
19
|
setOpenLayoutSwitchDlg: Dispatch<SetStateAction<boolean>>;
|
|
20
20
|
setCookieStr: Dispatch<SetStateAction<string>>;
|
|
21
|
+
globalSearchParams?: any;
|
|
22
|
+
setGlobalSearchParams: Dispatch<any>;
|
|
21
23
|
backendUrl?: string | null | undefined;
|
|
22
24
|
isDebug?: boolean | undefined;
|
|
23
25
|
layoutName?: string | undefined;
|
|
@@ -25,4 +27,8 @@ export declare function useMtmApp(): {
|
|
|
25
27
|
};
|
|
26
28
|
export declare const useHostname: () => string;
|
|
27
29
|
export declare const MtConnectProvider: (props: PropsWithChildren) => import("react").JSX.Element;
|
|
30
|
+
export declare const useGlobalsearchParams: () => {
|
|
31
|
+
searchParams: any;
|
|
32
|
+
setSearchParams: Dispatch<any>;
|
|
33
|
+
};
|
|
28
34
|
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
3
5
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -15,11 +17,16 @@ var __spreadValues = (a, b) => {
|
|
|
15
17
|
}
|
|
16
18
|
return a;
|
|
17
19
|
};
|
|
18
|
-
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
22
|
import { createContext, useContext, useMemo, useState } from "react";
|
|
20
23
|
import { createConnectTransport } from "@connectrpc/connect-web";
|
|
24
|
+
import { debounce } from "lodash";
|
|
25
|
+
import { useSearchParams } from "next/navigation";
|
|
21
26
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
27
|
+
import { GoMtmDebug } from "../components/devtools/GoMtmDebug";
|
|
22
28
|
import { TransportProvider } from "../connectquery";
|
|
29
|
+
import { HOTKEY_Debug } from "../consts";
|
|
23
30
|
import { anypbTypeReg } from "../messageTypeRegistry";
|
|
24
31
|
import { gomtmFetcher } from "../mtmFetcher";
|
|
25
32
|
import { MtReactQueryProvider } from "./ReactQueryProvider";
|
|
@@ -31,9 +38,22 @@ function GomtmProvider(props) {
|
|
|
31
38
|
const [_layoutName, setLayoutName] = useState("front");
|
|
32
39
|
const [openLayoutSwitchDlg, setOpenLayoutSwitchDlg] = useState(false);
|
|
33
40
|
const [_cookieStr, setCookieStr] = useState("");
|
|
34
|
-
|
|
41
|
+
const [_globalSearchParams, setGlobalSearchParams] = useState({});
|
|
42
|
+
useHotkeys(HOTKEY_Debug, () => {
|
|
35
43
|
setDebug(!_isDebug);
|
|
36
44
|
}, [_isDebug, setDebug]);
|
|
45
|
+
const searchParams = useSearchParams();
|
|
46
|
+
const globalSearchParams = useMemo(() => {
|
|
47
|
+
debounce(() => {
|
|
48
|
+
const q = searchParams.get("q");
|
|
49
|
+
console.log("search changed", q);
|
|
50
|
+
if (q) {
|
|
51
|
+
setGlobalSearchParams((pre) => {
|
|
52
|
+
return __spreadProps(__spreadValues({}, pre), { q });
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}, 500);
|
|
56
|
+
}, [searchParams]);
|
|
37
57
|
return /* @__PURE__ */ jsx(AppContext.Provider, { value: {
|
|
38
58
|
isDebug: _isDebug,
|
|
39
59
|
setIsDebug: setDebug,
|
|
@@ -44,13 +64,18 @@ function GomtmProvider(props) {
|
|
|
44
64
|
openLayoutSwitchDlg,
|
|
45
65
|
setOpenLayoutSwitchDlg,
|
|
46
66
|
cookieStr: _cookieStr,
|
|
47
|
-
setCookieStr
|
|
48
|
-
|
|
67
|
+
setCookieStr,
|
|
68
|
+
globalSearchParams,
|
|
69
|
+
setGlobalSearchParams
|
|
70
|
+
}, children: /* @__PURE__ */ jsx(MtConnectProvider, { children: /* @__PURE__ */ jsxs(MtReactQueryProvider, { children: [
|
|
71
|
+
children,
|
|
72
|
+
/* @__PURE__ */ jsx(GoMtmDebug, {})
|
|
73
|
+
] }) }) });
|
|
49
74
|
}
|
|
50
75
|
function useMtmApp() {
|
|
51
76
|
const mtappContext = useContext(AppContext);
|
|
52
77
|
if (mtappContext === void 0) {
|
|
53
|
-
throw new Error("useMtmApp must be used within a
|
|
78
|
+
throw new Error("useMtmApp must be used within a GomtmProvider");
|
|
54
79
|
}
|
|
55
80
|
return __spreadValues({}, mtappContext);
|
|
56
81
|
}
|
|
@@ -80,9 +105,17 @@ const MtConnectProvider = (props) => {
|
|
|
80
105
|
}, [mtapp.backendUrl, mtapp.cookieStr]);
|
|
81
106
|
return /* @__PURE__ */ jsx(TransportProvider, { transport, children });
|
|
82
107
|
};
|
|
108
|
+
const useGlobalsearchParams = () => {
|
|
109
|
+
const mtapp = useMtmApp();
|
|
110
|
+
return {
|
|
111
|
+
searchParams: mtapp.globalSearchParams,
|
|
112
|
+
setSearchParams: mtapp.setGlobalSearchParams
|
|
113
|
+
};
|
|
114
|
+
};
|
|
83
115
|
export {
|
|
84
116
|
GomtmProvider,
|
|
85
117
|
MtConnectProvider,
|
|
118
|
+
useGlobalsearchParams,
|
|
86
119
|
useHostname,
|
|
87
120
|
useMtmApp
|
|
88
121
|
};
|