gomtm 0.0.287 → 0.0.289
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.js +3 -2
- package/dist/esm/consts.d.ts +12 -2
- package/dist/esm/consts.js +12 -5
- package/dist/esm/curd/listview/ListViewProvider.d.ts +2 -2
- package/dist/esm/curd/listview/ListViewProvider.js +7 -3
- package/dist/esm/ly/LayoutBase.js +1 -1
- package/dist/esm/providers/ConfigStateProvider.d.ts +11 -0
- package/dist/esm/providers/ConfigStateProvider.js +44 -0
- package/dist/esm/providers/GomtmAppSS.js +14 -6
- package/dist/esm/providers/GomtmProvider.d.ts +20 -5
- package/dist/esm/providers/GomtmProvider.js +22 -16
- package/dist/esm/providers/ListViewProvider.d.ts +11 -0
- package/dist/esm/providers/ListViewProvider.js +43 -0
- package/dist/esm/providers/counter-store-provider.d.ts +9 -0
- package/dist/esm/providers/counter-store-provider.js +32 -0
- package/dist/esm/store/config-store.d.ts +16 -0
- package/dist/esm/store/config-store.js +44 -0
- package/dist/esm/store/counter-store.d.ts +11 -0
- package/dist/esm/store/counter-store.js +37 -0
- package/dist/esm/store/list-store.d.ts +15 -0
- package/dist/esm/store/list-store.js +44 -0
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +4 -3
|
@@ -5,11 +5,12 @@ import { CommandDialog, CommandEmpty, CommandInput, CommandList, CommandSeparato
|
|
|
5
5
|
import { Dialog, DialogContent, DialogTrigger } from "mtxuilib/ui/dialog";
|
|
6
6
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
7
7
|
import { useState } from "react";
|
|
8
|
+
import { useConfigStore } from "../../providers/ConfigStateProvider";
|
|
8
9
|
import { useMtmApp } from "../../providers/GomtmProvider";
|
|
9
10
|
const GoMtmDebug = () => {
|
|
10
11
|
const [open, setOpen] = useState(false);
|
|
11
|
-
const
|
|
12
|
-
if (!
|
|
12
|
+
const debug = useConfigStore((x) => x.debug);
|
|
13
|
+
if (!debug) {
|
|
13
14
|
return null;
|
|
14
15
|
}
|
|
15
16
|
return /* @__PURE__ */ jsxs("div", { className: "fixed bottom-12 right-2 bg-red-300", children: [
|
package/dist/esm/consts.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const COOKIE_MTM_SITE_ID = "mtm-site-id";
|
|
2
|
-
export declare const COOKIE_IS_DEBUG = "DEBUG";
|
|
3
2
|
export declare const MTM_SITE_HOSTNAME = "mtm-site-hostname";
|
|
4
3
|
export declare const MtM_TOKEN_NAME = "mtmToken";
|
|
5
4
|
export declare const fetchMaxRetry = 3;
|
|
@@ -11,7 +10,6 @@ export declare const MTM_SERVER_COOKIE_ACTIVATE_SELFBACKEND_URL = "mtm:selfbacke
|
|
|
11
10
|
export declare const DEFAULT_revalidate_SECONDS = 3;
|
|
12
11
|
export declare const LOGIN_CALLBACK_URL_KEY = "back";
|
|
13
12
|
export declare const MTM_API_PREFIX = "/api";
|
|
14
|
-
export declare const LayoutNameCookie = "layout";
|
|
15
13
|
export declare const IsDebugCookie = "is_debug";
|
|
16
14
|
export declare const ExtKey_Hostname = "host";
|
|
17
15
|
export declare const ItemAction_list_new_item = "list_new_item";
|
|
@@ -31,3 +29,15 @@ export declare const HOTKEY_Switchlayout = "alt+l";
|
|
|
31
29
|
export declare const HOTKEY_Listview_Switchlayout = "alt+m";
|
|
32
30
|
export declare const HOTKEY_ListViewCMDK = "alt+c";
|
|
33
31
|
export declare const CONST_debounce_INPUT = 300;
|
|
32
|
+
export declare const gomtmAppConfig: {
|
|
33
|
+
cookieBackendUrl: string;
|
|
34
|
+
cookieListViewLayout: string;
|
|
35
|
+
CookieLayout: string;
|
|
36
|
+
CookieConfigState: string;
|
|
37
|
+
};
|
|
38
|
+
export declare const getGomtmConfig: () => {
|
|
39
|
+
cookieBackendUrl: string;
|
|
40
|
+
cookieListViewLayout: string;
|
|
41
|
+
CookieLayout: string;
|
|
42
|
+
CookieConfigState: string;
|
|
43
|
+
};
|
package/dist/esm/consts.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const COOKIE_MTM_SITE_ID = "mtm-site-id";
|
|
2
|
-
const COOKIE_IS_DEBUG = "DEBUG";
|
|
3
2
|
const MTM_SITE_HOSTNAME = "mtm-site-hostname";
|
|
4
3
|
const MtM_TOKEN_NAME = "mtmToken";
|
|
5
4
|
const fetchMaxRetry = 3;
|
|
@@ -11,7 +10,6 @@ const MTM_SERVER_COOKIE_ACTIVATE_SELFBACKEND_URL = "mtm:selfbackendUrl";
|
|
|
11
10
|
const DEFAULT_revalidate_SECONDS = 3;
|
|
12
11
|
const LOGIN_CALLBACK_URL_KEY = "back";
|
|
13
12
|
const MTM_API_PREFIX = "/api";
|
|
14
|
-
const LayoutNameCookie = "layout";
|
|
15
13
|
const IsDebugCookie = "is_debug";
|
|
16
14
|
const ExtKey_Hostname = "host";
|
|
17
15
|
const ItemAction_list_new_item = "list_new_item";
|
|
@@ -31,6 +29,15 @@ const HOTKEY_Switchlayout = "alt+l";
|
|
|
31
29
|
const HOTKEY_Listview_Switchlayout = "alt+m";
|
|
32
30
|
const HOTKEY_ListViewCMDK = "alt+c";
|
|
33
31
|
const CONST_debounce_INPUT = 300;
|
|
32
|
+
const gomtmAppConfig = {
|
|
33
|
+
cookieBackendUrl: "backendUrl",
|
|
34
|
+
cookieListViewLayout: "listViewLayout",
|
|
35
|
+
CookieLayout: "layout",
|
|
36
|
+
CookieConfigState: "_config"
|
|
37
|
+
};
|
|
38
|
+
const getGomtmConfig = () => {
|
|
39
|
+
return gomtmAppConfig;
|
|
40
|
+
};
|
|
34
41
|
export {
|
|
35
42
|
ADMIN_ROLE,
|
|
36
43
|
ActionCreate,
|
|
@@ -39,7 +46,6 @@ export {
|
|
|
39
46
|
ActionFetchNextPage,
|
|
40
47
|
ActionRefetch,
|
|
41
48
|
CONST_debounce_INPUT,
|
|
42
|
-
COOKIE_IS_DEBUG,
|
|
43
49
|
COOKIE_MTM_SITE_ID,
|
|
44
50
|
Cookie_Site_Host,
|
|
45
51
|
DEFAULT_revalidate_SECONDS,
|
|
@@ -54,7 +60,6 @@ export {
|
|
|
54
60
|
IsDebugCookie,
|
|
55
61
|
ItemAction_list_new_item,
|
|
56
62
|
LOGIN_CALLBACK_URL_KEY,
|
|
57
|
-
LayoutNameCookie,
|
|
58
63
|
ListView_DefaultPageSize,
|
|
59
64
|
Listview_list_filter,
|
|
60
65
|
MEMBER_ROLE,
|
|
@@ -64,5 +69,7 @@ export {
|
|
|
64
69
|
MTM_SITE_HOSTNAME,
|
|
65
70
|
MtM_TOKEN_NAME,
|
|
66
71
|
TRPC_API_PREFIX,
|
|
67
|
-
fetchMaxRetry
|
|
72
|
+
fetchMaxRetry,
|
|
73
|
+
getGomtmConfig,
|
|
74
|
+
gomtmAppConfig
|
|
68
75
|
};
|
|
@@ -39,7 +39,7 @@ export declare function useListView<I extends Message<I>, O extends Message<O>>(
|
|
|
39
39
|
setOpenDebug?: Dispatch<SetStateAction<boolean>> | undefined;
|
|
40
40
|
setParams?: Dispatch<any> | undefined;
|
|
41
41
|
setDetailData?: Dispatch<any> | undefined;
|
|
42
|
-
setLayout?:
|
|
42
|
+
setLayout?: ((arg0: string) => void) | undefined;
|
|
43
43
|
};
|
|
44
44
|
export declare function useDetail(): {
|
|
45
45
|
svc: string;
|
|
@@ -64,7 +64,7 @@ export declare function useDetail(): {
|
|
|
64
64
|
setOpenDebug: Dispatch<SetStateAction<boolean>>;
|
|
65
65
|
setParams: Dispatch<any>;
|
|
66
66
|
setDetailData: Dispatch<any>;
|
|
67
|
-
setLayout:
|
|
67
|
+
setLayout: (arg0: string) => void;
|
|
68
68
|
};
|
|
69
69
|
export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
|
|
70
70
|
export declare const ListViewActions: () => import("react").JSX.Element;
|
|
@@ -65,7 +65,7 @@ const LzListViewLayoutDefault = lazy(() => import("./listview-layouts/default"))
|
|
|
65
65
|
const commonListViewContext = createContext(void 0);
|
|
66
66
|
function ListViewProvider(props) {
|
|
67
67
|
var _a;
|
|
68
|
-
const { children, svc, methodList, methodDelete, slugPath, methodCreate, methodGet, params } = props;
|
|
68
|
+
const { children, svc, methodList, methodDelete, slugPath, methodCreate, methodGet, params, layout } = props;
|
|
69
69
|
const mtapp = useMtmApp();
|
|
70
70
|
const [_svc, setSvc] = useState(svc);
|
|
71
71
|
const [openRemove, setOpenRemove] = useState(false);
|
|
@@ -75,7 +75,7 @@ function ListViewProvider(props) {
|
|
|
75
75
|
const [openDebug, setOpenDebug] = useState(false);
|
|
76
76
|
const [_params, _setParams] = useState(params);
|
|
77
77
|
const [detailData, setDetailData] = useState(void 0);
|
|
78
|
-
const [
|
|
78
|
+
const [_layout, _setLayout] = useState(mtapp.listviewLayout);
|
|
79
79
|
const __params = useMemo(() => {
|
|
80
80
|
var _a2, _b;
|
|
81
81
|
return __spreadProps(__spreadValues({}, params), {
|
|
@@ -87,6 +87,10 @@ function ListViewProvider(props) {
|
|
|
87
87
|
const setParams = useCallback(debounce((values) => {
|
|
88
88
|
_setParams(values);
|
|
89
89
|
}, CONST_debounce_INPUT), [_setParams]);
|
|
90
|
+
const setLayout = useCallback((name) => {
|
|
91
|
+
_setLayout(name);
|
|
92
|
+
mtapp.setListViewLayout(name);
|
|
93
|
+
}, [mtapp]);
|
|
90
94
|
return /* @__PURE__ */ jsx(commonListViewContext.Provider, { value: {
|
|
91
95
|
svc: _svc,
|
|
92
96
|
methodList,
|
|
@@ -108,7 +112,7 @@ function ListViewProvider(props) {
|
|
|
108
112
|
setParams,
|
|
109
113
|
detailData,
|
|
110
114
|
setDetailData,
|
|
111
|
-
layout,
|
|
115
|
+
layout: _layout,
|
|
112
116
|
setLayout
|
|
113
117
|
}, children: /* @__PURE__ */ jsxs(ListViewLayout, { children: [
|
|
114
118
|
" ",
|
|
@@ -69,7 +69,7 @@ const LayoutSwitchDlg = () => {
|
|
|
69
69
|
] }),
|
|
70
70
|
/* @__PURE__ */ jsx("div", { className: "flex gap-2 bg-red-100 p-2", children: ALL_Layouts.map((layout) => {
|
|
71
71
|
return /* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
72
|
-
mtapp.
|
|
72
|
+
mtapp.setLayout(layout);
|
|
73
73
|
setOpen(false);
|
|
74
74
|
}, children: layout }, layout);
|
|
75
75
|
}) })
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type StoreApi } from 'zustand';
|
|
3
|
+
import { ConfigStore } from "../store/config-store";
|
|
4
|
+
export declare const CounterStoreContext: import("react").Context<StoreApi<ConfigStore> | null>;
|
|
5
|
+
export interface ConfigStoreProviderProps {
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const ConfigStoreProvider: ({ children, }: ConfigStoreProviderProps) => import("react").JSX.Element;
|
|
10
|
+
export declare const SetupDebugHotKey: () => null;
|
|
11
|
+
export declare const useConfigStore: <T>(selector: (store: ConfigStore) => T) => T;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useRef } from "react";
|
|
4
|
+
import { useHotkeys } from "react-hotkeys-hook";
|
|
5
|
+
import { useStore } from "zustand";
|
|
6
|
+
import { HOTKEY_Debug } from "../consts";
|
|
7
|
+
import { createConfigStore, initConfigStore } from "../store/config-store";
|
|
8
|
+
const CounterStoreContext = createContext(
|
|
9
|
+
null
|
|
10
|
+
);
|
|
11
|
+
const ConfigStoreProvider = ({
|
|
12
|
+
children
|
|
13
|
+
}) => {
|
|
14
|
+
const storeRef = useRef();
|
|
15
|
+
if (!storeRef.current) {
|
|
16
|
+
storeRef.current = createConfigStore(initConfigStore());
|
|
17
|
+
}
|
|
18
|
+
return /* @__PURE__ */ jsxs(CounterStoreContext.Provider, { value: storeRef.current, children: [
|
|
19
|
+
children,
|
|
20
|
+
/* @__PURE__ */ jsx(SetupDebugHotKey, {})
|
|
21
|
+
] });
|
|
22
|
+
};
|
|
23
|
+
const SetupDebugHotKey = () => {
|
|
24
|
+
const debug = useConfigStore((x) => x.debug);
|
|
25
|
+
const setDebug = useConfigStore((x) => x.setDebug);
|
|
26
|
+
useHotkeys(HOTKEY_Debug, () => {
|
|
27
|
+
console.log("set debug", debug);
|
|
28
|
+
setDebug(!debug);
|
|
29
|
+
}, [debug, setDebug]);
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
const useConfigStore = (selector) => {
|
|
33
|
+
const counterStoreContext = useContext(CounterStoreContext);
|
|
34
|
+
if (!counterStoreContext) {
|
|
35
|
+
throw new Error(`useConfigStore must be use within ConfigStoreProvider`);
|
|
36
|
+
}
|
|
37
|
+
return useStore(counterStoreContext, selector);
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
ConfigStoreProvider,
|
|
41
|
+
CounterStoreContext,
|
|
42
|
+
SetupDebugHotKey,
|
|
43
|
+
useConfigStore
|
|
44
|
+
};
|
|
@@ -20,27 +20,35 @@ var __async = (__this, __arguments, generator) => {
|
|
|
20
20
|
};
|
|
21
21
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
22
22
|
import { cookies, headers } from "next/headers";
|
|
23
|
-
import { IsDebugCookie,
|
|
23
|
+
import { IsDebugCookie, getGomtmConfig } from "../consts";
|
|
24
24
|
import { ssrGetBackendUrl } from "../mtmFetcher";
|
|
25
25
|
import { GomtmProvider } from "./GomtmProvider";
|
|
26
26
|
function GomtmAppSS(props) {
|
|
27
27
|
return __async(this, null, function* () {
|
|
28
|
-
var _a, _b;
|
|
28
|
+
var _a, _b, _c, _d;
|
|
29
29
|
const { children } = props;
|
|
30
|
-
const
|
|
30
|
+
const gomtmAppConfig = getGomtmConfig();
|
|
31
|
+
let backend = ssrGetBackendUrl();
|
|
32
|
+
const backendFromCookie = (_a = cookies().get(gomtmAppConfig.cookieBackendUrl)) == null ? void 0 : _a.value;
|
|
33
|
+
if (backendFromCookie) {
|
|
34
|
+
backend = backendFromCookie;
|
|
35
|
+
}
|
|
31
36
|
if (!backend) {
|
|
32
37
|
return /* @__PURE__ */ jsx(Fragment, { children: "missing backend" });
|
|
33
38
|
}
|
|
34
39
|
const cookiesStr = headers().get("Cookie");
|
|
35
|
-
const layoutName = (
|
|
36
|
-
const isDebug = !!((
|
|
40
|
+
const layoutName = (_b = cookies().get(gomtmAppConfig.CookieLayout)) == null ? void 0 : _b.value;
|
|
41
|
+
const isDebug = !!((_c = cookies().get(IsDebugCookie)) == null ? void 0 : _c.value);
|
|
42
|
+
const configStateJson = ((_d = cookies().get(gomtmAppConfig.CookieConfigState)) == null ? void 0 : _d.value) || "{}";
|
|
43
|
+
const configState = JSON.parse(configStateJson);
|
|
37
44
|
return /* @__PURE__ */ jsx(
|
|
38
45
|
GomtmProvider,
|
|
39
46
|
{
|
|
40
47
|
backendUrl: backend,
|
|
41
|
-
isDebug,
|
|
48
|
+
debug: isDebug,
|
|
42
49
|
layoutName,
|
|
43
50
|
cookieStr: cookiesStr || "",
|
|
51
|
+
config: gomtmAppConfig,
|
|
44
52
|
children
|
|
45
53
|
}
|
|
46
54
|
);
|
|
@@ -1,26 +1,41 @@
|
|
|
1
1
|
import { Dispatch, PropsWithChildren, SetStateAction } from 'react';
|
|
2
|
+
import { getGomtmConfig } from '../consts';
|
|
3
|
+
import { ConfigState } from '../store/config-store';
|
|
2
4
|
export type ActionHandler = (props: {
|
|
3
5
|
action: string;
|
|
4
6
|
values?: any;
|
|
5
7
|
}) => void;
|
|
6
8
|
interface GomtmAppProps {
|
|
9
|
+
config: ReturnType<typeof getGomtmConfig>;
|
|
7
10
|
backendUrl?: string | null;
|
|
8
|
-
isDebug?: boolean;
|
|
9
11
|
layoutName?: string;
|
|
12
|
+
listviewLayout?: string;
|
|
10
13
|
cookieStr?: string;
|
|
11
14
|
}
|
|
12
|
-
export declare function GomtmProvider(props: {} & GomtmAppProps & PropsWithChildren): import("react").JSX.Element;
|
|
15
|
+
export declare function GomtmProvider(props: {} & GomtmAppProps & ConfigState & PropsWithChildren): import("react").JSX.Element;
|
|
13
16
|
export declare function useMtmApp(): {
|
|
14
17
|
hostname?: string | null | undefined;
|
|
15
|
-
setIsDebug: Dispatch<SetStateAction<boolean>>;
|
|
16
18
|
setBackendUrl: Dispatch<SetStateAction<string | null | undefined>>;
|
|
17
|
-
|
|
19
|
+
setLayout: (arg0: string) => void;
|
|
20
|
+
setListViewLayout: (arg0: string) => void;
|
|
18
21
|
setCookieStr: Dispatch<SetStateAction<string>>;
|
|
19
22
|
globalSearchParams?: any;
|
|
20
23
|
setGlobalSearchParams: Dispatch<any>;
|
|
24
|
+
setConfig: Dispatch<SetStateAction<{
|
|
25
|
+
cookieBackendUrl: string;
|
|
26
|
+
cookieListViewLayout: string;
|
|
27
|
+
CookieLayout: string;
|
|
28
|
+
CookieConfigState: string;
|
|
29
|
+
}>>;
|
|
30
|
+
config: {
|
|
31
|
+
cookieBackendUrl: string;
|
|
32
|
+
cookieListViewLayout: string;
|
|
33
|
+
CookieLayout: string;
|
|
34
|
+
CookieConfigState: string;
|
|
35
|
+
};
|
|
21
36
|
backendUrl?: string | null | undefined;
|
|
22
|
-
isDebug?: boolean | undefined;
|
|
23
37
|
layoutName?: string | undefined;
|
|
38
|
+
listviewLayout?: string | undefined;
|
|
24
39
|
cookieStr?: string | undefined;
|
|
25
40
|
};
|
|
26
41
|
export declare const useHostname: () => string;
|
|
@@ -19,26 +19,24 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
19
19
|
import { createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
20
20
|
import { createConnectTransport } from "@connectrpc/connect-web";
|
|
21
21
|
import { debounce } from "lodash";
|
|
22
|
+
import { setCookie } from "mtxlib/clientlib";
|
|
22
23
|
import { useSearchParams } from "next/navigation";
|
|
23
|
-
import { useHotkeys } from "react-hotkeys-hook";
|
|
24
24
|
import { GoMtmDebug } from "../components/devtools/GoMtmDebug";
|
|
25
25
|
import { TransportProvider } from "../connectquery";
|
|
26
|
-
import {
|
|
26
|
+
import { getGomtmConfig } from "../consts";
|
|
27
27
|
import { anypbTypeReg } from "../messageTypeRegistry";
|
|
28
28
|
import { gomtmFetcher } from "../mtmFetcher";
|
|
29
|
+
import { ConfigStoreProvider } from "./ConfigStateProvider";
|
|
29
30
|
import { MtReactQueryProvider } from "./ReactQueryProvider";
|
|
30
31
|
const AppContext = createContext(void 0);
|
|
31
32
|
function GomtmProvider(props) {
|
|
32
|
-
const { backendUrl, children } = props;
|
|
33
|
-
const [
|
|
33
|
+
const { backendUrl, layoutName, debug, children, listviewLayout, config } = props;
|
|
34
|
+
const [_config, setConfig] = useState(config);
|
|
34
35
|
const [_backendUrl, setBackendUrl] = useState(backendUrl);
|
|
35
|
-
const [_layoutName, setLayoutName] = useState(
|
|
36
|
-
const [
|
|
36
|
+
const [_layoutName, setLayoutName] = useState(layoutName);
|
|
37
|
+
const [_listviewLayout, _setListViewLayout] = useState(listviewLayout);
|
|
37
38
|
const [_cookieStr, setCookieStr] = useState("");
|
|
38
39
|
const [_globalSearchParams, _setGlobalSearchParams] = useState({});
|
|
39
|
-
useHotkeys(HOTKEY_Debug, () => {
|
|
40
|
-
setDebug((pre) => !pre);
|
|
41
|
-
}, [_isDebug, setDebug]);
|
|
42
40
|
const searchParams = useSearchParams();
|
|
43
41
|
const setGlobalSearchParams = useCallback(debounce((values) => {
|
|
44
42
|
_setGlobalSearchParams(values);
|
|
@@ -47,23 +45,31 @@ function GomtmProvider(props) {
|
|
|
47
45
|
const q = searchParams.get("q");
|
|
48
46
|
return __spreadValues({ q }, _globalSearchParams);
|
|
49
47
|
}, [searchParams, _globalSearchParams]);
|
|
48
|
+
const setLayout = useCallback((name) => {
|
|
49
|
+
setLayoutName(name);
|
|
50
|
+
setCookie(config == null ? void 0 : config.CookieLayout, name);
|
|
51
|
+
}, [config == null ? void 0 : config.CookieLayout]);
|
|
52
|
+
const setListViewLayout = useCallback((name) => {
|
|
53
|
+
setLayoutName(name);
|
|
54
|
+
setCookie(getGomtmConfig().cookieListViewLayout, name);
|
|
55
|
+
}, []);
|
|
50
56
|
return /* @__PURE__ */ jsx(AppContext.Provider, { value: {
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
config,
|
|
58
|
+
setConfig,
|
|
53
59
|
backendUrl,
|
|
54
60
|
setBackendUrl,
|
|
55
61
|
layoutName: _layoutName,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
setLayout,
|
|
63
|
+
setListViewLayout,
|
|
64
|
+
listviewLayout,
|
|
59
65
|
cookieStr: _cookieStr,
|
|
60
66
|
setCookieStr,
|
|
61
67
|
globalSearchParams,
|
|
62
68
|
setGlobalSearchParams
|
|
63
|
-
}, children: /* @__PURE__ */ jsx(MtConnectProvider, { children: /* @__PURE__ */ jsxs(MtReactQueryProvider, { children: [
|
|
69
|
+
}, children: /* @__PURE__ */ jsx(ConfigStoreProvider, { debug, children: /* @__PURE__ */ jsx(MtConnectProvider, { children: /* @__PURE__ */ jsxs(MtReactQueryProvider, { children: [
|
|
64
70
|
children,
|
|
65
71
|
/* @__PURE__ */ jsx(GoMtmDebug, {})
|
|
66
|
-
] }) }) });
|
|
72
|
+
] }) }) }) });
|
|
67
73
|
}
|
|
68
74
|
function useMtmApp() {
|
|
69
75
|
const mtappContext = useContext(AppContext);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type StoreApi } from 'zustand';
|
|
3
|
+
import { ListViewStore } from '../store/list-store';
|
|
4
|
+
export declare const ListViewStoreContext: import("react").Context<StoreApi<ListViewStore> | null>;
|
|
5
|
+
export interface ListViewStoreProviderProps {
|
|
6
|
+
svc: string;
|
|
7
|
+
methodList: string;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare const ListViewStoreProvider: (props: ListViewStoreProviderProps & ListViewStoreProviderProps) => import("react").JSX.Element;
|
|
11
|
+
export declare const useListviewStore: <T>(selector: (store: ListViewStore) => T) => T;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __objRest = (source, exclude) => {
|
|
6
|
+
var target = {};
|
|
7
|
+
for (var prop in source)
|
|
8
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
9
|
+
target[prop] = source[prop];
|
|
10
|
+
if (source != null && __getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
12
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
13
|
+
target[prop] = source[prop];
|
|
14
|
+
}
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
17
|
+
import { jsx } from "react/jsx-runtime";
|
|
18
|
+
import { createContext, useContext, useRef } from "react";
|
|
19
|
+
import { useStore } from "zustand";
|
|
20
|
+
import { createListviewStore, initListViewStore } from "../store/list-store";
|
|
21
|
+
const ListViewStoreContext = createContext(
|
|
22
|
+
null
|
|
23
|
+
);
|
|
24
|
+
const ListViewStoreProvider = (props) => {
|
|
25
|
+
const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
|
|
26
|
+
const storeRef = useRef();
|
|
27
|
+
if (!storeRef.current) {
|
|
28
|
+
storeRef.current = createListviewStore(initListViewStore(etc));
|
|
29
|
+
}
|
|
30
|
+
return /* @__PURE__ */ jsx(ListViewStoreContext.Provider, { value: storeRef.current, children });
|
|
31
|
+
};
|
|
32
|
+
const useListviewStore = (selector) => {
|
|
33
|
+
const listviewStoreContext = useContext(ListViewStoreContext);
|
|
34
|
+
if (!listviewStoreContext) {
|
|
35
|
+
throw new Error(`useListviewStore must be use within ListViewStoreProvider`);
|
|
36
|
+
}
|
|
37
|
+
return useStore(listviewStoreContext, selector);
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
ListViewStoreContext,
|
|
41
|
+
ListViewStoreProvider,
|
|
42
|
+
useListviewStore
|
|
43
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type StoreApi } from 'zustand';
|
|
3
|
+
import { type CounterStore } from '../store/counter-store';
|
|
4
|
+
export declare const CounterStoreContext: import("react").Context<StoreApi<CounterStore> | null>;
|
|
5
|
+
export interface CounterStoreProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const CounterStoreProvider: ({ children, }: CounterStoreProviderProps) => import("react").JSX.Element;
|
|
9
|
+
export declare const useCounterStore: <T>(selector: (store: CounterStore) => T) => T;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useRef } from "react";
|
|
4
|
+
import { useStore } from "zustand";
|
|
5
|
+
import {
|
|
6
|
+
createCounterStore,
|
|
7
|
+
initCounterStore
|
|
8
|
+
} from "../store/counter-store";
|
|
9
|
+
const CounterStoreContext = createContext(
|
|
10
|
+
null
|
|
11
|
+
);
|
|
12
|
+
const CounterStoreProvider = ({
|
|
13
|
+
children
|
|
14
|
+
}) => {
|
|
15
|
+
const storeRef = useRef();
|
|
16
|
+
if (!storeRef.current) {
|
|
17
|
+
storeRef.current = createCounterStore(initCounterStore());
|
|
18
|
+
}
|
|
19
|
+
return /* @__PURE__ */ jsx(CounterStoreContext.Provider, { value: storeRef.current, children });
|
|
20
|
+
};
|
|
21
|
+
const useCounterStore = (selector) => {
|
|
22
|
+
const counterStoreContext = useContext(CounterStoreContext);
|
|
23
|
+
if (!counterStoreContext) {
|
|
24
|
+
throw new Error(`useCounterStore must be use within CounterStoreProvider`);
|
|
25
|
+
}
|
|
26
|
+
return useStore(counterStoreContext, selector);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
CounterStoreContext,
|
|
30
|
+
CounterStoreProvider,
|
|
31
|
+
useCounterStore
|
|
32
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ConfigState {
|
|
2
|
+
debug?: boolean;
|
|
3
|
+
theme?: string;
|
|
4
|
+
layout?: string;
|
|
5
|
+
listviewLayout?: string;
|
|
6
|
+
}
|
|
7
|
+
export type ConfigActions = {
|
|
8
|
+
setLayout: () => void;
|
|
9
|
+
setDebug: (debug: boolean) => void;
|
|
10
|
+
setTheme: (theme: string) => void;
|
|
11
|
+
setListViewLayout: (listviewLayout: string) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const initConfigStore: () => ConfigState;
|
|
14
|
+
export declare const defaultInitState: ConfigState;
|
|
15
|
+
export declare const createConfigStore: (initState?: ConfigState) => import("zustand").StoreApi<ConfigStore>;
|
|
16
|
+
export type ConfigStore = ConfigState & ConfigActions;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { createStore } from "zustand";
|
|
21
|
+
const initConfigStore = () => {
|
|
22
|
+
return {
|
|
23
|
+
debug: false,
|
|
24
|
+
theme: "",
|
|
25
|
+
layout: "",
|
|
26
|
+
listviewLayout: ""
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const defaultInitState = {
|
|
30
|
+
layout: ""
|
|
31
|
+
};
|
|
32
|
+
const createConfigStore = (initState = defaultInitState) => {
|
|
33
|
+
return createStore()((set) => __spreadProps(__spreadValues({}, initState), {
|
|
34
|
+
setLayout: () => set((state) => ({ layout: state.layout })),
|
|
35
|
+
setDebug: () => set((state) => ({ debug: state.debug })),
|
|
36
|
+
setTheme: () => set((state) => ({ theme: state.theme })),
|
|
37
|
+
setListViewLayout: () => set((state) => ({ listviewLayout: state.listviewLayout }))
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
createConfigStore,
|
|
42
|
+
defaultInitState,
|
|
43
|
+
initConfigStore
|
|
44
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type CounterState = {
|
|
2
|
+
count: number;
|
|
3
|
+
};
|
|
4
|
+
export type CounterActions = {
|
|
5
|
+
decrementCount: () => void;
|
|
6
|
+
incrementCount: () => void;
|
|
7
|
+
};
|
|
8
|
+
export type CounterStore = CounterState & CounterActions;
|
|
9
|
+
export declare const initCounterStore: () => CounterState;
|
|
10
|
+
export declare const defaultInitState: CounterState;
|
|
11
|
+
export declare const createCounterStore: (initState?: CounterState) => import("zustand/vanilla").StoreApi<CounterStore>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { createStore } from "zustand/vanilla";
|
|
21
|
+
const initCounterStore = () => {
|
|
22
|
+
return { count: (/* @__PURE__ */ new Date()).getFullYear() };
|
|
23
|
+
};
|
|
24
|
+
const defaultInitState = {
|
|
25
|
+
count: 0
|
|
26
|
+
};
|
|
27
|
+
const createCounterStore = (initState = defaultInitState) => {
|
|
28
|
+
return createStore()((set) => __spreadProps(__spreadValues({}, initState), {
|
|
29
|
+
decrementCount: () => set((state) => ({ count: state.count - 1 })),
|
|
30
|
+
incrementCount: () => set((state) => ({ count: state.count + 1 }))
|
|
31
|
+
}));
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
createCounterStore,
|
|
35
|
+
defaultInitState,
|
|
36
|
+
initCounterStore
|
|
37
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ListViewStateProps {
|
|
2
|
+
svc: string;
|
|
3
|
+
methodList: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ListViewState extends ListViewStateProps {
|
|
6
|
+
count: number;
|
|
7
|
+
items: any[];
|
|
8
|
+
}
|
|
9
|
+
export type ListViewActions = {
|
|
10
|
+
loadList: () => void;
|
|
11
|
+
};
|
|
12
|
+
export type ListViewStore = ListViewState & ListViewActions;
|
|
13
|
+
export declare const initListViewStore: (props: ListViewStateProps) => ListViewState;
|
|
14
|
+
export declare const defaultInitState: ListViewState;
|
|
15
|
+
export declare const createListviewStore: (initState?: ListViewState) => import("zustand/vanilla").StoreApi<ListViewStore>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { createStore } from "zustand/vanilla";
|
|
21
|
+
const initListViewStore = (props) => {
|
|
22
|
+
return {
|
|
23
|
+
svc: props.svc,
|
|
24
|
+
methodList: props.methodList,
|
|
25
|
+
count: 0,
|
|
26
|
+
items: []
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const defaultInitState = {
|
|
30
|
+
svc: "",
|
|
31
|
+
methodList: "",
|
|
32
|
+
count: 0,
|
|
33
|
+
items: []
|
|
34
|
+
};
|
|
35
|
+
const createListviewStore = (initState = defaultInitState) => {
|
|
36
|
+
return createStore()((set) => __spreadProps(__spreadValues({}, initState), {
|
|
37
|
+
loadList: () => set((state) => ({ items: state.items }))
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
createListviewStore,
|
|
42
|
+
defaultInitState,
|
|
43
|
+
initListViewStore
|
|
44
|
+
};
|