gomtm 0.0.288 → 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 +0 -7
- package/dist/esm/consts.js +0 -7
- package/dist/esm/providers/ConfigStateProvider.d.ts +11 -0
- package/dist/esm/providers/ConfigStateProvider.js +44 -0
- package/dist/esm/providers/GomtmAppSS.js +1 -2
- package/dist/esm/providers/GomtmProvider.d.ts +3 -8
- package/dist/esm/providers/GomtmProvider.js +5 -18
- 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
|
@@ -41,10 +41,3 @@ export declare const getGomtmConfig: () => {
|
|
|
41
41
|
CookieLayout: string;
|
|
42
42
|
CookieConfigState: string;
|
|
43
43
|
};
|
|
44
|
-
export interface ConfigState {
|
|
45
|
-
debug?: boolean;
|
|
46
|
-
theme?: string;
|
|
47
|
-
layout?: string;
|
|
48
|
-
listviewLayout?: string;
|
|
49
|
-
}
|
|
50
|
-
export declare const configState: ConfigState;
|
package/dist/esm/consts.js
CHANGED
|
@@ -38,12 +38,6 @@ const gomtmAppConfig = {
|
|
|
38
38
|
const getGomtmConfig = () => {
|
|
39
39
|
return gomtmAppConfig;
|
|
40
40
|
};
|
|
41
|
-
const configState = {
|
|
42
|
-
debug: false,
|
|
43
|
-
theme: "",
|
|
44
|
-
layout: "",
|
|
45
|
-
listviewLayout: ""
|
|
46
|
-
};
|
|
47
41
|
export {
|
|
48
42
|
ADMIN_ROLE,
|
|
49
43
|
ActionCreate,
|
|
@@ -75,7 +69,6 @@ export {
|
|
|
75
69
|
MTM_SITE_HOSTNAME,
|
|
76
70
|
MtM_TOKEN_NAME,
|
|
77
71
|
TRPC_API_PREFIX,
|
|
78
|
-
configState,
|
|
79
72
|
fetchMaxRetry,
|
|
80
73
|
getGomtmConfig,
|
|
81
74
|
gomtmAppConfig
|
|
@@ -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
|
+
};
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { Dispatch, PropsWithChildren, SetStateAction } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { getGomtmConfig } from '../consts';
|
|
3
|
+
import { ConfigState } from '../store/config-store';
|
|
3
4
|
export type ActionHandler = (props: {
|
|
4
5
|
action: string;
|
|
5
6
|
values?: any;
|
|
6
7
|
}) => void;
|
|
7
8
|
interface GomtmAppProps {
|
|
8
9
|
config: ReturnType<typeof getGomtmConfig>;
|
|
9
|
-
configState: ConfigState;
|
|
10
10
|
backendUrl?: string | null;
|
|
11
|
-
isDebug?: boolean;
|
|
12
11
|
layoutName?: string;
|
|
13
12
|
listviewLayout?: string;
|
|
14
13
|
cookieStr?: string;
|
|
15
14
|
}
|
|
16
|
-
export declare function GomtmProvider(props: {} & GomtmAppProps & PropsWithChildren): import("react").JSX.Element;
|
|
15
|
+
export declare function GomtmProvider(props: {} & GomtmAppProps & ConfigState & PropsWithChildren): import("react").JSX.Element;
|
|
17
16
|
export declare function useMtmApp(): {
|
|
18
17
|
hostname?: string | null | undefined;
|
|
19
|
-
setDebug: (arg0: boolean) => void;
|
|
20
18
|
setBackendUrl: Dispatch<SetStateAction<string | null | undefined>>;
|
|
21
19
|
setLayout: (arg0: string) => void;
|
|
22
20
|
setListViewLayout: (arg0: string) => void;
|
|
@@ -29,16 +27,13 @@ export declare function useMtmApp(): {
|
|
|
29
27
|
CookieLayout: string;
|
|
30
28
|
CookieConfigState: string;
|
|
31
29
|
}>>;
|
|
32
|
-
setConfigState: Dispatch<SetStateAction<ConfigState>>;
|
|
33
30
|
config: {
|
|
34
31
|
cookieBackendUrl: string;
|
|
35
32
|
cookieListViewLayout: string;
|
|
36
33
|
CookieLayout: string;
|
|
37
34
|
CookieConfigState: string;
|
|
38
35
|
};
|
|
39
|
-
configState: ConfigState;
|
|
40
36
|
backendUrl?: string | null | undefined;
|
|
41
|
-
isDebug?: boolean | undefined;
|
|
42
37
|
layoutName?: string | undefined;
|
|
43
38
|
listviewLayout?: string | undefined;
|
|
44
39
|
cookieStr?: string | undefined;
|
|
@@ -21,19 +21,17 @@ import { createConnectTransport } from "@connectrpc/connect-web";
|
|
|
21
21
|
import { debounce } from "lodash";
|
|
22
22
|
import { setCookie } from "mtxlib/clientlib";
|
|
23
23
|
import { useSearchParams } from "next/navigation";
|
|
24
|
-
import { useHotkeys } from "react-hotkeys-hook";
|
|
25
24
|
import { GoMtmDebug } from "../components/devtools/GoMtmDebug";
|
|
26
25
|
import { TransportProvider } from "../connectquery";
|
|
27
|
-
import {
|
|
26
|
+
import { getGomtmConfig } from "../consts";
|
|
28
27
|
import { anypbTypeReg } from "../messageTypeRegistry";
|
|
29
28
|
import { gomtmFetcher } from "../mtmFetcher";
|
|
29
|
+
import { ConfigStoreProvider } from "./ConfigStateProvider";
|
|
30
30
|
import { MtReactQueryProvider } from "./ReactQueryProvider";
|
|
31
31
|
const AppContext = createContext(void 0);
|
|
32
32
|
function GomtmProvider(props) {
|
|
33
|
-
const { backendUrl, layoutName,
|
|
33
|
+
const { backendUrl, layoutName, debug, children, listviewLayout, config } = props;
|
|
34
34
|
const [_config, setConfig] = useState(config);
|
|
35
|
-
const [_configState, _setConfigState] = useState(configState);
|
|
36
|
-
const [_isDebug, _setDebug] = useState(isDebug || false);
|
|
37
35
|
const [_backendUrl, setBackendUrl] = useState(backendUrl);
|
|
38
36
|
const [_layoutName, setLayoutName] = useState(layoutName);
|
|
39
37
|
const [_listviewLayout, _setListViewLayout] = useState(listviewLayout);
|
|
@@ -55,20 +53,9 @@ function GomtmProvider(props) {
|
|
|
55
53
|
setLayoutName(name);
|
|
56
54
|
setCookie(getGomtmConfig().cookieListViewLayout, name);
|
|
57
55
|
}, []);
|
|
58
|
-
const setDebug = useCallback((debug) => {
|
|
59
|
-
_setDebug(debug);
|
|
60
|
-
setCookie(IsDebugCookie, debug);
|
|
61
|
-
}, []);
|
|
62
|
-
useHotkeys(HOTKEY_Debug, () => {
|
|
63
|
-
setDebug(!_isDebug);
|
|
64
|
-
}, [_isDebug, setDebug]);
|
|
65
56
|
return /* @__PURE__ */ jsx(AppContext.Provider, { value: {
|
|
66
57
|
config,
|
|
67
58
|
setConfig,
|
|
68
|
-
configState: _configState,
|
|
69
|
-
setConfigState: _setConfigState,
|
|
70
|
-
isDebug: _isDebug,
|
|
71
|
-
setDebug,
|
|
72
59
|
backendUrl,
|
|
73
60
|
setBackendUrl,
|
|
74
61
|
layoutName: _layoutName,
|
|
@@ -79,10 +66,10 @@ function GomtmProvider(props) {
|
|
|
79
66
|
setCookieStr,
|
|
80
67
|
globalSearchParams,
|
|
81
68
|
setGlobalSearchParams
|
|
82
|
-
}, children: /* @__PURE__ */ jsx(MtConnectProvider, { children: /* @__PURE__ */ jsxs(MtReactQueryProvider, { children: [
|
|
69
|
+
}, children: /* @__PURE__ */ jsx(ConfigStoreProvider, { debug, children: /* @__PURE__ */ jsx(MtConnectProvider, { children: /* @__PURE__ */ jsxs(MtReactQueryProvider, { children: [
|
|
83
70
|
children,
|
|
84
71
|
/* @__PURE__ */ jsx(GoMtmDebug, {})
|
|
85
|
-
] }) }) });
|
|
72
|
+
] }) }) }) });
|
|
86
73
|
}
|
|
87
74
|
function useMtmApp() {
|
|
88
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
|
+
};
|