gomtm 0.0.276 → 0.0.278

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.
@@ -28,3 +28,5 @@ export declare const MEMBER_ROLE = "member";
28
28
  export declare const TRPC_API_PREFIX = "/api.v1/trpc";
29
29
  export declare const HOTKEY_Debug = "alt+j";
30
30
  export declare const HOTKEY_Switchlayout = "alt+l";
31
+ export declare const HOTKEY_ListViewCMDK = "alt+c";
32
+ export declare const CONST_debounce_INPUT = 300;
@@ -28,6 +28,8 @@ const MEMBER_ROLE = "member";
28
28
  const TRPC_API_PREFIX = "/api.v1/trpc";
29
29
  const HOTKEY_Debug = "alt+j";
30
30
  const HOTKEY_Switchlayout = "alt+l";
31
+ const HOTKEY_ListViewCMDK = "alt+c";
32
+ const CONST_debounce_INPUT = 300;
31
33
  export {
32
34
  ADMIN_ROLE,
33
35
  ActionCreate,
@@ -35,12 +37,14 @@ export {
35
37
  ActionEdit,
36
38
  ActionFetchNextPage,
37
39
  ActionRefetch,
40
+ CONST_debounce_INPUT,
38
41
  COOKIE_IS_DEBUG,
39
42
  COOKIE_MTM_SITE_ID,
40
43
  Cookie_Site_Host,
41
44
  DEFAULT_revalidate_SECONDS,
42
45
  ExtKey_Hostname,
43
46
  HOTKEY_Debug,
47
+ HOTKEY_ListViewCMDK,
44
48
  HOTKEY_Switchlayout,
45
49
  HeaderMtmApi,
46
50
  HeaderMtmHost,
@@ -1,19 +1,4 @@
1
- import type { Message, PartialMessage } from "@bufbuild/protobuf";
2
- import { Dispatch, PropsWithChildren } from "react";
3
- import { MethodUnaryDescriptor } from "../connectquery";
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;
15
- };
1
+ /// <reference types="react" />
16
2
  export declare const DetailViewDataDlg: () => import("react").JSX.Element;
17
3
  export declare function DlgCurdDebugInfo(): import("react").JSX.Element;
18
4
  export declare const DlgCurdDebugInfoTriggerButton: () => import("react").JSX.Element | null;
19
- export {};
@@ -1,52 +1,12 @@
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
- };
18
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
19
2
  import { Dialog, DialogContent, DialogTitle, DialogTrigger } from "mtxuilib/ui/dialog";
20
3
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
21
- import { Suspense, createContext, useContext, useState } from "react";
22
4
  import { useSuspenseQuery } from "../connectquery";
23
5
  import { useMtmApp } from "../providers/GomtmProvider";
24
6
  import { useListView } from "./ListViewProvider";
25
- const CurdDetailContext = createContext(void 0);
26
- function CurdDetailProvider(props) {
27
- const { params, methodGet, children } = props;
28
- const [curdDetailPageData, setCurdDetailPageData] = useState(null);
29
- const mtApp = useMtmApp();
30
- return /* @__PURE__ */ jsxs(CurdDetailContext.Provider, { value: {
31
- params,
32
- methodGet,
33
- curdDetailPageData,
34
- setCurdDetailPageData
35
- }, children: [
36
- children,
37
- mtApp.isDebug && /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(DetailViewDataDlg, {}) })
38
- ] });
39
- }
40
- function useDetail() {
41
- const mtappContext = useContext(CurdDetailContext);
42
- if (mtappContext === void 0) {
43
- throw new Error("useMtmApp must be used within a MtAppProvider");
44
- }
45
- return __spreadValues({}, mtappContext);
46
- }
47
7
  const DetailViewDataDlg = () => {
48
- const detail = useDetail();
49
- const query = useSuspenseQuery(detail.methodGet);
8
+ const listView = useListView();
9
+ const query = useSuspenseQuery(listView.methodGet, listView.getParams);
50
10
  return /* @__PURE__ */ jsxs(Dialog, { children: [
51
11
  /* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx(MtButton, { children: "DetailData" }) }),
52
12
  /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx("pre", { children: JSON.stringify(query.data, null, 2) }) })
@@ -67,9 +27,7 @@ const DlgCurdDebugInfoTriggerButton = () => {
67
27
  }, children: "DlgCurdDebug" }) });
68
28
  };
69
29
  export {
70
- CurdDetailProvider,
71
30
  DetailViewDataDlg,
72
31
  DlgCurdDebugInfo,
73
- DlgCurdDebugInfoTriggerButton,
74
- useDetail
32
+ DlgCurdDebugInfoTriggerButton
75
33
  };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function ListPageCommands(): import("react").JSX.Element;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { HOTKEY_ListViewCMDK } from "../consts";
4
+ import { debounce } from "lodash";
5
+ import { CommandDialog, CommandEmpty, CommandInput, CommandList, CommandSeparator } from "mtxuilib/ui/command";
6
+ import { useState } from "react";
7
+ import { useHotkeys } from "react-hotkeys-hook";
8
+ function ListPageCommands() {
9
+ const [open, setOpen] = useState(false);
10
+ useHotkeys(HOTKEY_ListViewCMDK, () => {
11
+ setOpen((pre) => !pre);
12
+ }, [setOpen]);
13
+ const handleValueChange = (search) => {
14
+ };
15
+ return /* @__PURE__ */ jsxs(CommandDialog, { open, onOpenChange: setOpen, children: [
16
+ /* @__PURE__ */ jsx(CommandInput, { placeholder: "Type a command or search...", onValueChange: debounce(handleValueChange, 500) }),
17
+ /* @__PURE__ */ jsxs(CommandList, { children: [
18
+ /* @__PURE__ */ jsx(CommandEmpty, { children: "No results found." }),
19
+ /* @__PURE__ */ jsx(CommandSeparator, {})
20
+ ] })
21
+ ] });
22
+ }
23
+ export {
24
+ ListPageCommands
25
+ };
@@ -0,0 +1,4 @@
1
+ import { ComponentProps, PropsWithChildren } from "react";
2
+ import { Message } from "..";
3
+ import { ListViewProvider } from "./ListViewProvider";
4
+ export default function ListViewPage<I extends Message<I>, O extends Message<O>>(props: {} & ComponentProps<typeof ListViewProvider> & PropsWithChildren): import("react").JSX.Element;
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __objRest = (source, exclude) => {
22
+ var target = {};
23
+ for (var prop in source)
24
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
+ target[prop] = source[prop];
26
+ if (source != null && __getOwnPropSymbols)
27
+ for (var prop of __getOwnPropSymbols(source)) {
28
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
+ target[prop] = source[prop];
30
+ }
31
+ return target;
32
+ };
33
+ import { Fragment, jsx } from "react/jsx-runtime";
34
+ import { WithConnectHydrate } from "../components/SSR";
35
+ import { siteList } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
36
+ import { ListViewProvider } from "./ListViewProvider";
37
+ function ListViewPage(props) {
38
+ const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
39
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ListViewProvider, __spreadProps(__spreadValues({}, etc), { children: /* @__PURE__ */ jsx(
40
+ WithConnectHydrate,
41
+ {
42
+ methodSig: siteList,
43
+ input: etc.params,
44
+ children
45
+ }
46
+ ) })) });
47
+ }
48
+ export {
49
+ ListViewPage as default
50
+ };
@@ -5,18 +5,24 @@ interface ListViewProps<I extends Message<I>, O extends Message<O>> {
5
5
  methodList: MethodUnaryDescriptor<I, any>;
6
6
  methodDelete: MethodUnaryDescriptor<any, any>;
7
7
  methodCreate?: MethodUnaryDescriptor<any, any>;
8
+ methodGet?: MethodUnaryDescriptor<any, any>;
8
9
  slugPath?: string;
9
10
  activateItem?: any;
10
11
  params?: any;
12
+ getParams?: any;
13
+ detailData?: any;
11
14
  }
12
15
  export declare function ListViewProvider<I extends Message<I>, O extends Message<O>>(props: ListViewProps<I, O> & PropsWithChildren): import("react").JSX.Element;
13
16
  export declare function useListView<I extends Message<I>, O extends Message<O>>(): {
14
17
  methodList?: MethodUnaryDescriptor<any, any> | undefined;
15
18
  methodDelete?: MethodUnaryDescriptor<any, any> | undefined;
16
19
  methodCreate?: MethodUnaryDescriptor<any, any> | undefined;
20
+ methodGet?: MethodUnaryDescriptor<any, any> | undefined;
17
21
  slugPath?: string | undefined;
18
22
  activateItem?: any;
19
23
  params?: any;
24
+ getParams?: any;
25
+ detailData?: any;
20
26
  openRemove?: boolean | undefined;
21
27
  setOpenRemove?: Dispatch<SetStateAction<boolean>> | undefined;
22
28
  openCreate?: boolean | undefined;
@@ -27,6 +33,29 @@ export declare function useListView<I extends Message<I>, O extends Message<O>>(
27
33
  openDebug?: boolean | undefined;
28
34
  setOpenDebug?: Dispatch<SetStateAction<boolean>> | undefined;
29
35
  setParams?: Dispatch<any> | undefined;
36
+ setDetailData?: Dispatch<any> | undefined;
37
+ };
38
+ export declare function useDetail(): {
39
+ methodList: MethodUnaryDescriptor<any, any>;
40
+ methodDelete: MethodUnaryDescriptor<any, any>;
41
+ methodCreate?: MethodUnaryDescriptor<any, any> | undefined;
42
+ methodGet?: MethodUnaryDescriptor<any, any> | undefined;
43
+ slugPath?: string | undefined;
44
+ activateItem?: any;
45
+ params?: any;
46
+ getParams?: any;
47
+ detailData?: any;
48
+ openRemove: boolean;
49
+ setOpenRemove: Dispatch<SetStateAction<boolean>>;
50
+ openCreate: boolean;
51
+ setOpenCreate: Dispatch<SetStateAction<boolean>>;
52
+ setActivateItem: Dispatch<any>;
53
+ openEdit?: boolean | undefined;
54
+ setOpenEdit: Dispatch<SetStateAction<boolean>>;
55
+ openDebug?: boolean | undefined;
56
+ setOpenDebug: Dispatch<SetStateAction<boolean>>;
57
+ setParams: Dispatch<any>;
58
+ setDetailData: Dispatch<any>;
30
59
  };
31
60
  export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
32
61
  export declare const ListViewActions: () => import("react").JSX.Element;
@@ -49,6 +49,7 @@ import { MtButton } from "mtxuilib/ui/ui-mt/Button";
49
49
  import { Suspense, createContext, useCallback, useContext, useMemo, useState } from "react";
50
50
  import { MtmErrorView } from "../components/MtmErrorView";
51
51
  import { useMutation, useSuspenseInfiniteQuery } from "../connectquery";
52
+ import { CONST_debounce_INPUT } from "../consts";
52
53
  import { useMtmApp } from "../providers/GomtmProvider";
53
54
  import { DlgCurdDebugInfo, DlgCurdDebugInfoTriggerButton } from "./CurdDetailProvider";
54
55
  import CurdCreatePanel, { CurdCreatePanelTriggerButton } from "./create/CurdCreatePanel";
@@ -57,7 +58,7 @@ import { ListItemView } from "./list-item/ListItem";
57
58
  import { ListLayout } from "./list-item/ListLayout";
58
59
  const commonListViewContext = createContext(void 0);
59
60
  function ListViewProvider(props) {
60
- const { children, methodList, methodDelete, slugPath, methodCreate } = props;
61
+ const { children, methodList, methodDelete, slugPath, methodCreate, methodGet } = props;
61
62
  const mtapp = useMtmApp();
62
63
  const [openRemove, setOpenRemove] = useState(false);
63
64
  const [openCreate, setOpenCreate] = useState(false);
@@ -65,6 +66,7 @@ function ListViewProvider(props) {
65
66
  const [openEdit, setOpenEdit] = useState(false);
66
67
  const [openDebug, setOpenDebug] = useState(false);
67
68
  const [_params, _setParams] = useState(mtapp.globalSearchParams);
69
+ const [detailData, setDetailData] = useState(void 0);
68
70
  const params = useMemo(() => {
69
71
  var _a;
70
72
  return {
@@ -73,14 +75,15 @@ function ListViewProvider(props) {
73
75
  }, [mtapp.globalSearchParams]);
74
76
  const setParams = useCallback(debounce((values) => {
75
77
  _setParams(values);
76
- }, 300), [_setParams]);
78
+ }, CONST_debounce_INPUT), [_setParams]);
77
79
  return /* @__PURE__ */ jsx(commonListViewContext.Provider, { value: {
78
80
  methodList,
81
+ methodGet,
82
+ methodDelete,
83
+ methodCreate,
79
84
  slugPath,
80
85
  openRemove,
81
86
  setOpenRemove,
82
- methodDelete,
83
- methodCreate,
84
87
  openCreate,
85
88
  setOpenCreate,
86
89
  activateItem,
@@ -90,13 +93,22 @@ function ListViewProvider(props) {
90
93
  openDebug,
91
94
  setOpenDebug,
92
95
  params,
93
- setParams
96
+ setParams,
97
+ detailData,
98
+ setDetailData
94
99
  }, children });
95
100
  }
96
101
  function useListView() {
97
102
  const ctx = useContext(commonListViewContext);
98
103
  return __spreadValues({}, ctx);
99
104
  }
105
+ function useDetail() {
106
+ const mtappContext = useContext(commonListViewContext);
107
+ if (mtappContext === void 0) {
108
+ throw new Error("useDetail must be used within a MtAppProvider");
109
+ }
110
+ return __spreadValues({}, mtappContext);
111
+ }
100
112
  function CommonListView() {
101
113
  const listView = useListView();
102
114
  const listQuery = useSuspenseInfiniteQuery(listView.methodList, {
@@ -105,9 +117,6 @@ function CommonListView() {
105
117
  q: listView.params.q || ""
106
118
  }
107
119
  },
108
- // pagination: {
109
- // page: 1
110
- // }
111
120
  pagination: void 0
112
121
  }, {
113
122
  pageParamKey: "pagination",
@@ -199,5 +208,6 @@ export {
199
208
  CommonListView,
200
209
  ListViewActions,
201
210
  ListViewProvider,
211
+ useDetail,
202
212
  useListView
203
213
  };