gomtm 0.0.291 → 0.0.292
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 +1 -1
- package/dist/esm/components/devtools/GoMtmDebug.js +12 -3
- package/dist/esm/consts.d.ts +3 -10
- package/dist/esm/consts.js +7 -12
- package/dist/esm/curd/list-item/ListLayout.d.ts +1 -1
- package/dist/esm/curd/listview/ListViewProvider.d.ts +1 -0
- package/dist/esm/curd/listview/ListViewProvider.js +24 -1
- package/dist/esm/curd/listview/list-store.d.ts +7 -10
- package/dist/esm/curd/listview/list-store.js +45 -2
- package/dist/esm/gomtmQuery.js +23 -7
- package/dist/esm/ly/LayoutBase.js +2 -2
- package/dist/esm/ly/UserAvatorMenus.js +1 -0
- package/dist/esm/mtmFetcher.d.ts +3 -1
- package/dist/esm/mtmFetcher.js +12 -6
- package/dist/esm/providers/AuthProvider.d.ts +1 -4
- package/dist/esm/providers/AuthProvider.js +12 -8
- package/dist/esm/providers/GomtmAppSS.js +28 -21
- package/dist/esm/store/GomtmAppSetting.d.ts +2 -0
- package/dist/esm/store/GomtmAppSetting.js +18 -0
- package/dist/esm/store/customStorage.d.ts +2 -0
- package/dist/esm/store/customStorage.js +35 -0
- package/dist/esm/store/mtapp-store.d.ts +24 -9
- package/dist/esm/store/mtapp-store.js +50 -17
- package/dist/esm/store/useStore.d.ts +2 -0
- package/dist/esm/store/useStore.js +13 -0
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/esm/curd/CurdDetailProvider.d.ts +0 -0
- package/dist/esm/curd/CurdDetailProvider.js +0 -0
- package/dist/esm/providers/ConfigStateProvider.d.ts +0 -0
- package/dist/esm/providers/ConfigStateProvider.js +0 -0
- package/dist/esm/providers/ListViewProvider.d.ts +0 -12
- package/dist/esm/providers/ListViewProvider.js +0 -47
- package/dist/esm/providers/counter-store-provider.d.ts +0 -9
- package/dist/esm/providers/counter-store-provider.js +0 -32
- package/dist/esm/store/config-store.d.ts +0 -0
- package/dist/esm/store/config-store.js +0 -0
- package/dist/esm/store/counter-store.d.ts +0 -11
- package/dist/esm/store/counter-store.js +0 -37
- package/dist/esm/store/list-store.d.ts +0 -25
- package/dist/esm/store/list-store.js +0 -97
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type ActionHandler = (props: {
|
|
3
|
+
action: string;
|
|
4
|
+
values?: any;
|
|
5
|
+
}) => void;
|
|
6
|
+
interface GomtmAppProps {
|
|
3
7
|
debug?: boolean;
|
|
4
|
-
theme?: string;
|
|
5
|
-
layout?: string;
|
|
6
8
|
listviewLayout?: string;
|
|
9
|
+
cacheEnabled?: boolean;
|
|
7
10
|
backendUrl?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
params: any;
|
|
11
|
+
layout?: string;
|
|
12
|
+
theme?: string;
|
|
13
|
+
counter?: number;
|
|
14
|
+
params?: any;
|
|
13
15
|
cookieStr?: string;
|
|
14
16
|
globalSearchParams?: any;
|
|
15
17
|
openDebug?: boolean;
|
|
16
18
|
}
|
|
17
19
|
interface GomtmAppState extends GomtmAppProps {
|
|
18
20
|
loading?: boolean;
|
|
21
|
+
setCounter: (counter: number) => void;
|
|
19
22
|
setLoading: (loading: boolean) => void;
|
|
20
23
|
setDebug: (debug: boolean) => void;
|
|
21
24
|
setLayout: (layout: string) => void;
|
|
22
25
|
setGlobalSearchParams: (globalSearchParams: any) => void;
|
|
23
26
|
setOpenDebug: (openDebug: boolean) => void;
|
|
27
|
+
setCacheEnabled: (cacheEnabled: boolean) => void;
|
|
24
28
|
}
|
|
25
|
-
export declare const BearContext: import("react").Context<import("zustand").StoreApi<GomtmAppState>
|
|
29
|
+
export declare const BearContext: import("react").Context<(Omit<import("zustand").StoreApi<GomtmAppState>, "persist"> & {
|
|
30
|
+
persist: {
|
|
31
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<GomtmAppState, unknown>>) => void;
|
|
32
|
+
clearStorage: () => void;
|
|
33
|
+
rehydrate: () => void | Promise<void>;
|
|
34
|
+
hasHydrated: () => boolean;
|
|
35
|
+
onHydrate: (fn: (state: GomtmAppState) => void) => () => void;
|
|
36
|
+
onFinishHydration: (fn: (state: GomtmAppState) => void) => () => void;
|
|
37
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<GomtmAppState, unknown>>;
|
|
38
|
+
};
|
|
39
|
+
}) | null>;
|
|
26
40
|
type BearProviderProps = React.PropsWithChildren<GomtmAppProps>;
|
|
27
41
|
export declare const GoMtmAppProvider: (props: BearProviderProps) => import("react").JSX.Element;
|
|
28
42
|
export declare function useGomtm<T>(selector: (state: GomtmAppState) => T): T;
|
|
29
43
|
export declare const MtConnectProvider: (props: PropsWithChildren) => import("react").JSX.Element;
|
|
44
|
+
export declare const DebugCounter: () => import("react").JSX.Element;
|
|
30
45
|
export {};
|
|
@@ -32,33 +32,54 @@ var __objRest = (source, exclude) => {
|
|
|
32
32
|
};
|
|
33
33
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
34
34
|
import { createConnectTransport } from "@connectrpc/connect-web";
|
|
35
|
+
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
35
36
|
import { createContext, useContext, useMemo, useRef } from "react";
|
|
36
37
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
37
38
|
import { useStore } from "zustand";
|
|
39
|
+
import { createJSONStorage, persist } from "zustand/middleware";
|
|
38
40
|
import { createStore } from "zustand/vanilla";
|
|
39
41
|
import { GoMtmDebug } from "../components/devtools/GoMtmDebug";
|
|
40
42
|
import { TransportProvider } from "../connectquery";
|
|
41
|
-
import { HOTKEY_Debug } from "../consts";
|
|
43
|
+
import { CookieConfigState, HOTKEY_Debug } from "../consts";
|
|
42
44
|
import { anypbTypeReg } from "../messageTypeRegistry";
|
|
43
45
|
import { gomtmFetcher } from "../mtmFetcher";
|
|
44
46
|
import { MtReactQueryProvider } from "../providers/ReactQueryProvider";
|
|
47
|
+
import { customCookieStorage } from "./customStorage";
|
|
45
48
|
const createGomtmAppStore = (initProps) => {
|
|
46
49
|
const DEFAULT_PROPS = {
|
|
47
50
|
debug: false,
|
|
48
|
-
configState: {},
|
|
49
|
-
params: {}
|
|
51
|
+
// configState: {},
|
|
52
|
+
params: {},
|
|
53
|
+
counter: 0
|
|
50
54
|
};
|
|
51
|
-
return createStore()(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
return createStore()(
|
|
56
|
+
persist(
|
|
57
|
+
(set) => __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_PROPS), initProps), {
|
|
58
|
+
setLoading: (loading) => set({ loading }),
|
|
59
|
+
setDebug: (debug) => set({ debug }),
|
|
60
|
+
setLayout: (layout) => set({ layout }),
|
|
61
|
+
setCacheEnabled: (cacheEnabled) => set({ cacheEnabled }),
|
|
62
|
+
setCounter: (counter) => set({ counter }),
|
|
63
|
+
setGlobalSearchParams: (globalSearchParams) => set({ globalSearchParams }),
|
|
64
|
+
openDebug: false,
|
|
65
|
+
setOpenDebug: (openDebug) => set({ openDebug })
|
|
66
|
+
}),
|
|
67
|
+
{
|
|
68
|
+
name: CookieConfigState,
|
|
69
|
+
// name of the item in the storage (must be unique)
|
|
70
|
+
storage: createJSONStorage(() => customCookieStorage),
|
|
71
|
+
partialize: (state) => {
|
|
72
|
+
return Object.fromEntries(
|
|
73
|
+
Object.entries(state).filter(
|
|
74
|
+
([key]) => {
|
|
75
|
+
return !["cookieStr", "children"].includes(key);
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
);
|
|
62
83
|
};
|
|
63
84
|
const BearContext = createContext(null);
|
|
64
85
|
const GoMtmAppProvider = (props) => {
|
|
@@ -69,8 +90,8 @@ const GoMtmAppProvider = (props) => {
|
|
|
69
90
|
}
|
|
70
91
|
return /* @__PURE__ */ jsx(BearContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ jsxs(MtConnectProvider, { children: [
|
|
71
92
|
/* @__PURE__ */ jsxs(MtReactQueryProvider, { children: [
|
|
72
|
-
|
|
73
|
-
|
|
93
|
+
/* @__PURE__ */ jsx(GoMtmDebug, {}),
|
|
94
|
+
children
|
|
74
95
|
] }),
|
|
75
96
|
/* @__PURE__ */ jsx(Setup, {})
|
|
76
97
|
] }) });
|
|
@@ -92,7 +113,7 @@ const Setup = () => {
|
|
|
92
113
|
};
|
|
93
114
|
const MtConnectProvider = (props) => {
|
|
94
115
|
const { children } = props;
|
|
95
|
-
const backendUrl = useGomtm((x) => x.
|
|
116
|
+
const backendUrl = useGomtm((x) => x.backendUrl);
|
|
96
117
|
const cookieStr = useGomtm((x) => x.cookieStr);
|
|
97
118
|
const transport = useMemo(() => {
|
|
98
119
|
const baseApiUrl = new URL("/api", backendUrl || "").toString();
|
|
@@ -110,8 +131,20 @@ const MtConnectProvider = (props) => {
|
|
|
110
131
|
}, [backendUrl, cookieStr]);
|
|
111
132
|
return /* @__PURE__ */ jsx(TransportProvider, { transport, children });
|
|
112
133
|
};
|
|
134
|
+
const DebugCounter = () => {
|
|
135
|
+
const counter = useGomtm((x) => x.counter);
|
|
136
|
+
const setCounter = useGomtm((x) => x.setCounter);
|
|
137
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(MtButton, { onClick: () => {
|
|
138
|
+
setCounter((counter || 0) + 1);
|
|
139
|
+
}, children: [
|
|
140
|
+
"counter:(",
|
|
141
|
+
counter,
|
|
142
|
+
")"
|
|
143
|
+
] }) });
|
|
144
|
+
};
|
|
113
145
|
export {
|
|
114
146
|
BearContext,
|
|
147
|
+
DebugCounter,
|
|
115
148
|
GoMtmAppProvider,
|
|
116
149
|
MtConnectProvider,
|
|
117
150
|
useGomtm
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
const useStore = (store, callback) => {
|
|
3
|
+
const result = store(callback);
|
|
4
|
+
const [data, setData] = useState();
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
setData(result);
|
|
7
|
+
}, [result]);
|
|
8
|
+
return data;
|
|
9
|
+
};
|
|
10
|
+
var useStore_default = useStore;
|
|
11
|
+
export {
|
|
12
|
+
useStore_default as default
|
|
13
|
+
};
|