gomtm 0.0.252 → 0.0.254
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/curd/CommonListViewV2.d.ts +4 -6
- package/dist/esm/curd/CommonListViewV2.js +7 -21
- package/dist/esm/curd/CurdDetailProvider.js +3 -3
- package/dist/esm/curd/create/CurdCreatePanel.d.ts +0 -3
- package/dist/esm/curd/create/CurdCreatePanel.js +6 -8
- package/dist/esm/curd/dlg/DlgCurdDebugInfo.d.ts +0 -3
- package/dist/esm/curd/dlg/DlgCurdDebugInfo.js +10 -18
- package/dist/esm/ly/LayoutBase.d.ts +0 -1
- package/dist/esm/ly/LayoutBase.js +8 -17
- package/dist/esm/providers/GomtmAppSS.js +16 -9
- package/dist/esm/providers/GomtmProvider.d.ts +14 -9
- package/dist/esm/providers/GomtmProvider.js +35 -18
- package/dist/esm/providers/logger.context.js +0 -2
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Message } from "@bufbuild/protobuf";
|
|
2
2
|
import { Dispatch, PropsWithChildren, SetStateAction } from "react";
|
|
3
3
|
import { MethodUnaryDescriptor } from "../connectquery";
|
|
4
|
-
export declare const exampleListItemValueComponent: import("jotai").PrimitiveAtom<any> & {
|
|
5
|
-
init: any;
|
|
6
|
-
};
|
|
7
|
-
export declare const exampleListItemComponent: import("jotai").Atom<any>;
|
|
8
4
|
export declare function CommonListViewProvider<I extends Message<I>, O extends Message<O>>(props: {
|
|
9
5
|
methodList: MethodUnaryDescriptor<I, any>;
|
|
10
6
|
methodDelete: MethodUnaryDescriptor<any, any>;
|
|
@@ -17,15 +13,17 @@ export declare const useListView: () => {
|
|
|
17
13
|
methodCreate?: MethodUnaryDescriptor<any, any> | undefined;
|
|
18
14
|
slugPath?: string | undefined;
|
|
19
15
|
activateItem?: any;
|
|
20
|
-
|
|
21
|
-
openDebug?: boolean | undefined;
|
|
16
|
+
params?: any;
|
|
22
17
|
openRemove?: boolean | undefined;
|
|
23
18
|
setOpenRemove?: Dispatch<SetStateAction<boolean>> | undefined;
|
|
24
19
|
openCreate?: boolean | undefined;
|
|
25
20
|
setOpenCreate?: Dispatch<SetStateAction<boolean>> | undefined;
|
|
26
21
|
setActivateItem?: Dispatch<any> | undefined;
|
|
22
|
+
openEdit?: boolean | undefined;
|
|
27
23
|
setOpenEdit?: Dispatch<SetStateAction<boolean>> | undefined;
|
|
24
|
+
openDebug?: boolean | undefined;
|
|
28
25
|
setOpenDebug?: Dispatch<SetStateAction<boolean>> | undefined;
|
|
26
|
+
setParams?: Dispatch<any> | undefined;
|
|
29
27
|
};
|
|
30
28
|
export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
|
|
31
29
|
export declare const ListViewActions: () => import("react").JSX.Element;
|
|
@@ -36,8 +36,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
39
|
-
import { atom } from "jotai";
|
|
40
|
-
import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
41
39
|
import { Icons } from "mtxuilib/icons/icons";
|
|
42
40
|
import { cn } from "mtxuilib/lib/utils";
|
|
43
41
|
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
@@ -47,21 +45,11 @@ import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
|
47
45
|
import { Suspense, createContext, useContext, useState } from "react";
|
|
48
46
|
import { MtUnaryCallErrorView } from "../components/MtUnaryCallErrorView";
|
|
49
47
|
import { useMutation, useSuspenseInfiniteQuery } from "../connectquery";
|
|
50
|
-
import CurdCreatePanel, { CurdCreatePanelTriggerButton
|
|
51
|
-
import { DlgCurdDebugInfo, DlgCurdDebugInfoTriggerButton
|
|
48
|
+
import CurdCreatePanel, { CurdCreatePanelTriggerButton } from "./create/CurdCreatePanel";
|
|
49
|
+
import { DlgCurdDebugInfo, DlgCurdDebugInfoTriggerButton } from "./dlg/DlgCurdDebugInfo";
|
|
52
50
|
import CurdEditPanel, { CurdEditPanelTriggerButton } from "./edit/CurdEditPanel";
|
|
53
51
|
import { ListItemView } from "./list-item/ListItem";
|
|
54
52
|
import { ListLayout } from "./list-item/ListLayout";
|
|
55
|
-
const exampleListItemValueComponent = atom(void 0);
|
|
56
|
-
const exampleListItemComponent = atom((get) => {
|
|
57
|
-
const v = get(exampleListItemValueComponent);
|
|
58
|
-
if (v) {
|
|
59
|
-
return v;
|
|
60
|
-
}
|
|
61
|
-
return () => {
|
|
62
|
-
return /* @__PURE__ */ jsx("div", { children: "missing exampleListItemComponent" });
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
53
|
const commonListViewContext = createContext(void 0);
|
|
66
54
|
function CommonListViewProvider(props) {
|
|
67
55
|
const { children, methodList, methodDelete, slugPath, methodCreate } = props;
|
|
@@ -70,6 +58,7 @@ function CommonListViewProvider(props) {
|
|
|
70
58
|
const [activateItem, setActivateItem] = useState(void 0);
|
|
71
59
|
const [openEdit, setOpenEdit] = useState(false);
|
|
72
60
|
const [openDebug, setOpenDebug] = useState(false);
|
|
61
|
+
const [params, setParams] = useState(void 0);
|
|
73
62
|
return /* @__PURE__ */ jsx(commonListViewContext.Provider, { value: {
|
|
74
63
|
methodList,
|
|
75
64
|
slugPath,
|
|
@@ -84,11 +73,10 @@ function CommonListViewProvider(props) {
|
|
|
84
73
|
openEdit,
|
|
85
74
|
setOpenEdit,
|
|
86
75
|
openDebug,
|
|
87
|
-
setOpenDebug
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
], children }) });
|
|
76
|
+
setOpenDebug,
|
|
77
|
+
params,
|
|
78
|
+
setParams
|
|
79
|
+
}, children });
|
|
92
80
|
}
|
|
93
81
|
const useListView = () => {
|
|
94
82
|
const ctx = useContext(commonListViewContext);
|
|
@@ -188,7 +176,5 @@ export {
|
|
|
188
176
|
CommonListView,
|
|
189
177
|
CommonListViewProvider,
|
|
190
178
|
ListViewActions,
|
|
191
|
-
exampleListItemComponent,
|
|
192
|
-
exampleListItemValueComponent,
|
|
193
179
|
useListView
|
|
194
180
|
};
|
|
@@ -6,17 +6,17 @@ import { Dialog, DialogContent, DialogTrigger } from "mtxuilib/ui/dialog";
|
|
|
6
6
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
7
7
|
import { Suspense } from "react";
|
|
8
8
|
import { useSuspenseQuery } from "../connectquery";
|
|
9
|
-
import {
|
|
9
|
+
import { useMtmApp } from "../providers/GomtmProvider";
|
|
10
10
|
const curdDetailPageDataAtom = atom(void 0);
|
|
11
11
|
function CurdDetailProvider(props) {
|
|
12
12
|
const { children, methodGet, params } = props;
|
|
13
|
-
const
|
|
13
|
+
const mtApp = useMtmApp();
|
|
14
14
|
const query = useSuspenseQuery(methodGet, params);
|
|
15
15
|
return /* @__PURE__ */ jsxs(ScopeAtomsHydrator, { atomValues: [
|
|
16
16
|
[curdDetailPageDataAtom, query.data]
|
|
17
17
|
], children: [
|
|
18
18
|
children,
|
|
19
|
-
isDebug && /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(DetailViewDataDlg, {}) })
|
|
19
|
+
mtApp.isDebug && /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(DetailViewDataDlg, {}) })
|
|
20
20
|
] });
|
|
21
21
|
}
|
|
22
22
|
const DetailViewDataDlg = () => {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const openCurdCreatePanelAtom: import("jotai").PrimitiveAtom<boolean> & {
|
|
3
|
-
init: boolean;
|
|
4
|
-
};
|
|
5
2
|
export default function CurdCreatePanel(): import("react").JSX.Element;
|
|
6
3
|
export declare const CurdCreatePanelTriggerButton: () => import("react").JSX.Element;
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
-
import { atom, useAtom } from "jotai";
|
|
4
3
|
import { useMtRouter } from "mtxuilib/hooks/use-router";
|
|
5
4
|
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
6
5
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
7
|
-
|
|
6
|
+
import { useListView } from "../CommonListViewV2";
|
|
8
7
|
function CurdCreatePanel() {
|
|
9
8
|
const router = useMtRouter();
|
|
10
|
-
const
|
|
11
|
-
return /* @__PURE__ */ jsx(Dialog, { open:
|
|
9
|
+
const listView = useListView();
|
|
10
|
+
return /* @__PURE__ */ jsx(Dialog, { open: listView.openCreate, onOpenChange: listView.setOpenCreate, children: /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogTitle, { children: " Create " }) }) });
|
|
12
11
|
}
|
|
13
12
|
const CurdCreatePanelTriggerButton = () => {
|
|
14
|
-
const
|
|
13
|
+
const listView = useListView();
|
|
15
14
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
16
|
-
|
|
15
|
+
listView.setOpenCreate(true);
|
|
17
16
|
}, children: "OpenCreatePanel" }) });
|
|
18
17
|
};
|
|
19
18
|
export {
|
|
20
19
|
CurdCreatePanelTriggerButton,
|
|
21
|
-
CurdCreatePanel as default
|
|
22
|
-
openCurdCreatePanelAtom
|
|
20
|
+
CurdCreatePanel as default
|
|
23
21
|
};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const openDlgCurdDebugInfoAtom: import("jotai").PrimitiveAtom<boolean> & {
|
|
3
|
-
init: boolean;
|
|
4
|
-
};
|
|
5
2
|
export declare function DlgCurdDebugInfo(): import("react").JSX.Element;
|
|
6
3
|
export declare const DlgCurdDebugInfoTriggerButton: () => import("react").JSX.Element | null;
|
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Fragment, jsx
|
|
3
|
-
import { atom, useAtom } from "jotai";
|
|
4
|
-
import { flexRender } from "mtxuilib/lib/render";
|
|
2
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
5
3
|
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
6
4
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
const openDlgCurdDebugInfoAtom = atom(false);
|
|
5
|
+
import { useMtmApp } from "../../providers/GomtmProvider";
|
|
6
|
+
import { useListView } from "../CommonListViewV2";
|
|
10
7
|
function DlgCurdDebugInfo() {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Dialog, { open: openDlgCurdDebugInfo, onOpenChange: setOpenDlgCurdDebugInfo, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
14
|
-
/* @__PURE__ */ jsx(DialogTitle, { children: "list view info" }),
|
|
15
|
-
Comp && flexRender(Comp, {})
|
|
16
|
-
] }) }) });
|
|
8
|
+
const listView = useListView();
|
|
9
|
+
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" }) }) }) });
|
|
17
10
|
}
|
|
18
11
|
const DlgCurdDebugInfoTriggerButton = () => {
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
if (!isDebug) {
|
|
12
|
+
const listView = useListView();
|
|
13
|
+
const mtApp = useMtmApp();
|
|
14
|
+
if (!mtApp.isDebug) {
|
|
22
15
|
return null;
|
|
23
16
|
}
|
|
24
17
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
25
|
-
|
|
18
|
+
listView.setOpenDebug(true);
|
|
26
19
|
}, children: "DlgCurdDebug" }) });
|
|
27
20
|
};
|
|
28
21
|
export {
|
|
29
22
|
DlgCurdDebugInfo,
|
|
30
|
-
DlgCurdDebugInfoTriggerButton
|
|
31
|
-
openDlgCurdDebugInfoAtom
|
|
23
|
+
DlgCurdDebugInfoTriggerButton
|
|
32
24
|
};
|
|
@@ -14,7 +14,6 @@ export declare const LzFrontLayout: import("react").ComponentType<{
|
|
|
14
14
|
export declare const LzHelloLazyLayout: import("react").ComponentType<{
|
|
15
15
|
children?: import("react").ReactNode;
|
|
16
16
|
}>;
|
|
17
|
-
export declare const layoutNameAtom: import("jotai").WritableAtom<string, [value: string], void>;
|
|
18
17
|
export declare const LayoutBase: (props: {
|
|
19
18
|
layoutName?: string;
|
|
20
19
|
} & PropsWithChildren) => import("react").JSX.Element;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
4
|
-
import { atom, useAtom } from "jotai";
|
|
5
4
|
import { TailwindIndicator } from "mtxuilib/common/tailwind-indicator";
|
|
6
5
|
import { AppMetaRender } from "mtxuilib/store/AppMetaRender";
|
|
7
6
|
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
@@ -12,6 +11,7 @@ import dynamic from "next/dynamic";
|
|
|
12
11
|
import { Suspense } from "react";
|
|
13
12
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
14
13
|
import { Toaster } from "sonner";
|
|
14
|
+
import { useMtmApp } from "../providers/GomtmProvider";
|
|
15
15
|
import { Demo1Layout } from "./demo-layout";
|
|
16
16
|
import { FrontLayout } from "./front-layout";
|
|
17
17
|
const ALL_Layouts = [
|
|
@@ -36,13 +36,6 @@ const LzFrontLayout = dynamic(() => import("./front-layout").then((x) => x.Front
|
|
|
36
36
|
const LzHelloLazyLayout = dynamic(() => import("./Lazy").then((x) => x.HelloLazyLayout), {
|
|
37
37
|
ssr: true
|
|
38
38
|
});
|
|
39
|
-
const layoutNameValueAtom = atom("");
|
|
40
|
-
const layoutNameAtom = atom((get) => {
|
|
41
|
-
return get(layoutNameValueAtom);
|
|
42
|
-
}, (_, set, value) => {
|
|
43
|
-
set(layoutNameValueAtom, value);
|
|
44
|
-
});
|
|
45
|
-
const openLayoutSwitchDlgAtom = atom(false);
|
|
46
39
|
const LayoutBase = (props) => {
|
|
47
40
|
const { layoutName, children } = props;
|
|
48
41
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(TooltipProvider, { delayDuration: 0, children: [
|
|
@@ -67,20 +60,19 @@ const LayoutBase = (props) => {
|
|
|
67
60
|
] }) }) });
|
|
68
61
|
};
|
|
69
62
|
const LayoutSwitchDlg = () => {
|
|
70
|
-
const
|
|
71
|
-
const [layoutName, setLayoutName] = useAtom(layoutNameAtom);
|
|
63
|
+
const mtapp = useMtmApp();
|
|
72
64
|
useHotkeys("alt+l", () => {
|
|
73
|
-
setOpenLayoutSwitchDlg(!openLayoutSwitchDlg);
|
|
65
|
+
mtapp.setOpenLayoutSwitchDlg(!mtapp.openLayoutSwitchDlg);
|
|
74
66
|
}, []);
|
|
75
|
-
return /* @__PURE__ */ jsx(Dialog, { open: openLayoutSwitchDlg, onOpenChange: setOpenLayoutSwitchDlg, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
67
|
+
return /* @__PURE__ */ jsx(Dialog, { open: mtapp.openLayoutSwitchDlg, onOpenChange: mtapp.setOpenLayoutSwitchDlg, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
76
68
|
/* @__PURE__ */ jsxs(DialogTitle, { children: [
|
|
77
69
|
"LayoutSwitch,",
|
|
78
|
-
layoutName
|
|
70
|
+
mtapp.layoutName
|
|
79
71
|
] }),
|
|
80
72
|
/* @__PURE__ */ jsx("div", { className: "flex gap-2 bg-red-100 p-2", children: ALL_Layouts.map((layout) => {
|
|
81
73
|
return /* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
82
|
-
setLayoutName(layout);
|
|
83
|
-
setOpenLayoutSwitchDlg(false);
|
|
74
|
+
mtapp.setLayoutName(layout);
|
|
75
|
+
mtapp.setOpenLayoutSwitchDlg(false);
|
|
84
76
|
}, children: layout }, layout);
|
|
85
77
|
}) })
|
|
86
78
|
] }) });
|
|
@@ -91,6 +83,5 @@ export {
|
|
|
91
83
|
LzDebugLayout,
|
|
92
84
|
LzDemo,
|
|
93
85
|
LzFrontLayout,
|
|
94
|
-
LzHelloLazyLayout
|
|
95
|
-
layoutNameAtom
|
|
86
|
+
LzHelloLazyLayout
|
|
96
87
|
};
|
|
@@ -22,24 +22,31 @@ import { Fragment, jsx } from "react/jsx-runtime";
|
|
|
22
22
|
import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
23
23
|
import { cookies, headers } from "next/headers";
|
|
24
24
|
import { IsDebugCookie, LayoutNameCookie } from "../consts";
|
|
25
|
-
import { layoutNameAtom } from "../ly/LayoutBase";
|
|
26
25
|
import { ssrGetBackendUrl } from "../mtmFetcher";
|
|
27
|
-
import { GomtmProvider, cookiesAtom
|
|
26
|
+
import { GomtmProvider, cookiesAtom } from "./GomtmProvider";
|
|
28
27
|
function GomtmAppSS(props) {
|
|
29
28
|
return __async(this, null, function* () {
|
|
29
|
+
var _a, _b;
|
|
30
30
|
const { children } = props;
|
|
31
31
|
const backend = ssrGetBackendUrl();
|
|
32
32
|
if (!backend) {
|
|
33
33
|
return /* @__PURE__ */ jsx(Fragment, { children: "missing backend" });
|
|
34
34
|
}
|
|
35
35
|
const cookiesStr = headers().get("Cookie");
|
|
36
|
-
const layoutName = cookies().get(LayoutNameCookie);
|
|
37
|
-
const isDebug = cookies().get(IsDebugCookie);
|
|
38
|
-
return /* @__PURE__ */ jsx(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
const layoutName = (_a = cookies().get(LayoutNameCookie)) == null ? void 0 : _a.value;
|
|
37
|
+
const isDebug = !!((_b = cookies().get(IsDebugCookie)) == null ? void 0 : _b.value);
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
GomtmProvider,
|
|
40
|
+
{
|
|
41
|
+
backendUrl: backend,
|
|
42
|
+
isDebug,
|
|
43
|
+
layoutName,
|
|
44
|
+
children: /* @__PURE__ */ jsx(ScopeAtomsHydrator, { atomValues: [
|
|
45
|
+
[cookiesAtom, cookiesStr]
|
|
46
|
+
// [layoutNameAtom, layoutName],
|
|
47
|
+
], children })
|
|
48
|
+
}
|
|
49
|
+
);
|
|
43
50
|
});
|
|
44
51
|
}
|
|
45
52
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
1
|
+
import { Dispatch, PropsWithChildren, SetStateAction } from 'react';
|
|
2
2
|
import { Transport } from '@connectrpc/connect';
|
|
3
3
|
export declare const mtmAppStore: {
|
|
4
4
|
get: <Value>(atom: import("jotai").Atom<Value>) => Value;
|
|
@@ -47,19 +47,24 @@ export declare const gomtmBaseUrlAtom: import("jotai").PrimitiveAtom<string> & {
|
|
|
47
47
|
init: string;
|
|
48
48
|
};
|
|
49
49
|
export declare const cookiesAtom: import("jotai").WritableAtom<string | undefined, [value: string], void>;
|
|
50
|
-
export declare const isDebugValueAtom: import("jotai").PrimitiveAtom<boolean> & {
|
|
51
|
-
init: boolean;
|
|
52
|
-
};
|
|
53
|
-
export declare const isDebugAtom: import("jotai").WritableAtom<boolean, [value: boolean], void>;
|
|
54
50
|
export declare const transportAtom: import("jotai").Atom<Transport>;
|
|
55
51
|
interface GomtmAppProps {
|
|
56
52
|
backendUrl?: string | null;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
hostname?: string | null;
|
|
53
|
+
isDebug?: boolean;
|
|
54
|
+
layoutName?: string;
|
|
60
55
|
}
|
|
61
56
|
export declare function GomtmProvider(props: {} & GomtmAppProps & PropsWithChildren): import("react").JSX.Element;
|
|
62
|
-
export declare function useMtmApp():
|
|
57
|
+
export declare function useMtmApp(): {
|
|
58
|
+
hostname?: string | null | undefined;
|
|
59
|
+
setIsDebug: Dispatch<SetStateAction<boolean>>;
|
|
60
|
+
setBackendUrl: Dispatch<SetStateAction<string | null | undefined>>;
|
|
61
|
+
setLayoutName: Dispatch<SetStateAction<string>>;
|
|
62
|
+
openLayoutSwitchDlg?: boolean | undefined;
|
|
63
|
+
setOpenLayoutSwitchDlg: Dispatch<SetStateAction<boolean>>;
|
|
64
|
+
backendUrl?: string | null | undefined;
|
|
65
|
+
isDebug?: boolean | undefined;
|
|
66
|
+
layoutName?: string | undefined;
|
|
67
|
+
};
|
|
63
68
|
export declare const useHostname: () => string;
|
|
64
69
|
export declare const MtConnectProvider: (props: PropsWithChildren) => import("react").JSX.Element;
|
|
65
70
|
export {};
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
import { jsx } from "react/jsx-runtime";
|
|
19
|
+
import { createContext, useContext, useState } from "react";
|
|
4
20
|
import { createConnectTransport } from "@connectrpc/connect-web";
|
|
5
21
|
import { atom, createStore, useAtom } from "jotai";
|
|
6
|
-
import { AtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
7
22
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
8
23
|
import { TransportProvider } from "../connectquery";
|
|
9
24
|
import { anypbTypeReg } from "../messageTypeRegistry";
|
|
@@ -30,12 +45,6 @@ const cookiesAtom = atom((get) => {
|
|
|
30
45
|
}, (_, set, value) => {
|
|
31
46
|
set(cookiesValueAtom, value);
|
|
32
47
|
});
|
|
33
|
-
const isDebugValueAtom = atom(false);
|
|
34
|
-
const isDebugAtom = atom((get) => {
|
|
35
|
-
return get(isDebugValueAtom);
|
|
36
|
-
}, (_, set, value) => {
|
|
37
|
-
set(isDebugValueAtom, value);
|
|
38
|
-
});
|
|
39
48
|
const transportAtom = atom((get) => {
|
|
40
49
|
const baseUrl = get(curd3BackendUrlAtom);
|
|
41
50
|
const cookiesStr = get(cookiesAtom);
|
|
@@ -53,20 +62,30 @@ const transportAtom = atom((get) => {
|
|
|
53
62
|
const AppContext = createContext(void 0);
|
|
54
63
|
function GomtmProvider(props) {
|
|
55
64
|
const { backendUrl, children } = props;
|
|
56
|
-
const [
|
|
65
|
+
const [_isDebug, setDebug] = useState(false);
|
|
66
|
+
const [_backendUrl, setBackendUrl] = useState(backendUrl);
|
|
67
|
+
const [_layoutName, setLayoutName] = useState("front");
|
|
68
|
+
const [openLayoutSwitchDlg, setOpenLayoutSwitchDlg] = useState(false);
|
|
57
69
|
useHotkeys("alt+j", () => {
|
|
58
|
-
setDebug(!
|
|
59
|
-
}, [
|
|
60
|
-
return /* @__PURE__ */ jsx(
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
setDebug(!_isDebug);
|
|
71
|
+
}, [_isDebug, setDebug]);
|
|
72
|
+
return /* @__PURE__ */ jsx(AppContext.Provider, { value: {
|
|
73
|
+
isDebug: _isDebug,
|
|
74
|
+
setIsDebug: setDebug,
|
|
75
|
+
backendUrl,
|
|
76
|
+
setBackendUrl,
|
|
77
|
+
layoutName: _layoutName,
|
|
78
|
+
setLayoutName,
|
|
79
|
+
openLayoutSwitchDlg,
|
|
80
|
+
setOpenLayoutSwitchDlg
|
|
81
|
+
}, children: /* @__PURE__ */ jsx(MtConnectProvider, { children: /* @__PURE__ */ jsx(MtReactQueryProvider, { children }) }) });
|
|
63
82
|
}
|
|
64
83
|
function useMtmApp() {
|
|
65
84
|
const mtappContext = useContext(AppContext);
|
|
66
85
|
if (mtappContext === void 0) {
|
|
67
86
|
throw new Error("useMtmApp must be used within a MtAppProvider");
|
|
68
87
|
}
|
|
69
|
-
return mtappContext;
|
|
88
|
+
return __spreadValues({}, mtappContext);
|
|
70
89
|
}
|
|
71
90
|
const useHostname = () => {
|
|
72
91
|
const { hostname } = useMtmApp();
|
|
@@ -87,8 +106,6 @@ export {
|
|
|
87
106
|
MtConnectProvider,
|
|
88
107
|
cookiesAtom,
|
|
89
108
|
gomtmBaseUrlAtom,
|
|
90
|
-
isDebugAtom,
|
|
91
|
-
isDebugValueAtom,
|
|
92
109
|
mtmAppStore,
|
|
93
110
|
transportAtom,
|
|
94
111
|
useHostname,
|