gomtm 0.0.253 → 0.0.255
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 +0 -4
- package/dist/esm/curd/CommonListViewV2.js +0 -13
- package/dist/esm/curd/CurdDetailProvider.d.ts +13 -7
- package/dist/esm/curd/CurdDetailProvider.js +40 -15
- 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>;
|
|
@@ -36,7 +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
39
|
import { Icons } from "mtxuilib/icons/icons";
|
|
41
40
|
import { cn } from "mtxuilib/lib/utils";
|
|
42
41
|
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
@@ -51,16 +50,6 @@ import { DlgCurdDebugInfo, DlgCurdDebugInfoTriggerButton } from "./dlg/DlgCurdDe
|
|
|
51
50
|
import CurdEditPanel, { CurdEditPanelTriggerButton } from "./edit/CurdEditPanel";
|
|
52
51
|
import { ListItemView } from "./list-item/ListItem";
|
|
53
52
|
import { ListLayout } from "./list-item/ListLayout";
|
|
54
|
-
const exampleListItemValueComponent = atom(void 0);
|
|
55
|
-
const exampleListItemComponent = atom((get) => {
|
|
56
|
-
const v = get(exampleListItemValueComponent);
|
|
57
|
-
if (v) {
|
|
58
|
-
return v;
|
|
59
|
-
}
|
|
60
|
-
return () => {
|
|
61
|
-
return /* @__PURE__ */ jsx("div", { children: "missing exampleListItemComponent" });
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
53
|
const commonListViewContext = createContext(void 0);
|
|
65
54
|
function CommonListViewProvider(props) {
|
|
66
55
|
const { children, methodList, methodDelete, slugPath, methodCreate } = props;
|
|
@@ -187,7 +176,5 @@ export {
|
|
|
187
176
|
CommonListView,
|
|
188
177
|
CommonListViewProvider,
|
|
189
178
|
ListViewActions,
|
|
190
|
-
exampleListItemComponent,
|
|
191
|
-
exampleListItemValueComponent,
|
|
192
179
|
useListView
|
|
193
180
|
};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { Message, PartialMessage } from "@bufbuild/protobuf";
|
|
2
|
-
import { PropsWithChildren } from "react";
|
|
2
|
+
import { Dispatch, PropsWithChildren } from "react";
|
|
3
3
|
import { MethodUnaryDescriptor } from "../connectquery";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
interface CurdDetailProps {
|
|
5
|
+
curdDetailPageData?: any | null;
|
|
6
|
+
methodGet: MethodUnaryDescriptor<any, any>;
|
|
7
|
+
params?: PartialMessage<any>;
|
|
8
|
+
}
|
|
9
|
+
export declare function CurdDetailProvider<I extends Message<I>, O extends Message<O>>(props: CurdDetailProps & PropsWithChildren): import("react").JSX.Element;
|
|
10
|
+
export declare function useDetail(): {
|
|
11
|
+
setCurdDetailPageData: Dispatch<any>;
|
|
12
|
+
curdDetailPageData?: any;
|
|
13
|
+
methodGet: MethodUnaryDescriptor<any, any>;
|
|
14
|
+
params?: PartialMessage<any> | undefined;
|
|
6
15
|
};
|
|
7
|
-
export declare function CurdDetailProvider<I extends Message<I>, O extends Message<O>>(props: {
|
|
8
|
-
methodGet: MethodUnaryDescriptor<I, O>;
|
|
9
|
-
params?: PartialMessage<I>;
|
|
10
|
-
} & PropsWithChildren): import("react").JSX.Element;
|
|
11
16
|
export declare const DetailViewDataDlg: () => import("react").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -1,33 +1,58 @@
|
|
|
1
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
|
+
};
|
|
2
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { atom, useAtom } from "jotai";
|
|
4
|
-
import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
5
19
|
import { Dialog, DialogContent, DialogTrigger } from "mtxuilib/ui/dialog";
|
|
6
20
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
7
|
-
import { Suspense } from "react";
|
|
21
|
+
import { Suspense, createContext, useContext, useState } from "react";
|
|
8
22
|
import { useSuspenseQuery } from "../connectquery";
|
|
9
|
-
import {
|
|
10
|
-
const
|
|
23
|
+
import { useMtmApp } from "../providers/GomtmProvider";
|
|
24
|
+
const CurdDetailContext = createContext(void 0);
|
|
11
25
|
function CurdDetailProvider(props) {
|
|
12
|
-
const {
|
|
13
|
-
const [
|
|
14
|
-
const
|
|
15
|
-
return /* @__PURE__ */ jsxs(
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
const { params, methodGet, children } = props;
|
|
27
|
+
const [curdDetailPageData, setCurdDetailPageData] = useState(null);
|
|
28
|
+
const mtApp = useMtmApp();
|
|
29
|
+
return /* @__PURE__ */ jsxs(CurdDetailContext.Provider, { value: {
|
|
30
|
+
params,
|
|
31
|
+
methodGet,
|
|
32
|
+
curdDetailPageData,
|
|
33
|
+
setCurdDetailPageData
|
|
34
|
+
}, children: [
|
|
18
35
|
children,
|
|
19
|
-
isDebug && /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(DetailViewDataDlg, {}) })
|
|
36
|
+
mtApp.isDebug && /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(DetailViewDataDlg, {}) })
|
|
20
37
|
] });
|
|
21
38
|
}
|
|
39
|
+
function useDetail() {
|
|
40
|
+
const mtappContext = useContext(CurdDetailContext);
|
|
41
|
+
if (mtappContext === void 0) {
|
|
42
|
+
throw new Error("useMtmApp must be used within a MtAppProvider");
|
|
43
|
+
}
|
|
44
|
+
return __spreadValues({}, mtappContext);
|
|
45
|
+
}
|
|
22
46
|
const DetailViewDataDlg = () => {
|
|
23
|
-
const
|
|
47
|
+
const detail = useDetail();
|
|
48
|
+
const query = useSuspenseQuery(detail.methodGet);
|
|
24
49
|
return /* @__PURE__ */ jsxs(Dialog, { children: [
|
|
25
50
|
/* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx(MtButton, { children: "DetailData" }) }),
|
|
26
|
-
/* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx("pre", { children: JSON.stringify(
|
|
51
|
+
/* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx("pre", { children: JSON.stringify(query.data, null, 2) }) })
|
|
27
52
|
] });
|
|
28
53
|
};
|
|
29
54
|
export {
|
|
30
55
|
CurdDetailProvider,
|
|
31
56
|
DetailViewDataDlg,
|
|
32
|
-
|
|
57
|
+
useDetail
|
|
33
58
|
};
|
|
@@ -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,
|