gomtm 0.0.276 → 0.0.277

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,4 @@ 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";
@@ -28,6 +28,7 @@ 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";
31
32
  export {
32
33
  ADMIN_ROLE,
33
34
  ActionCreate,
@@ -41,6 +42,7 @@ export {
41
42
  DEFAULT_revalidate_SECONDS,
42
43
  ExtKey_Hostname,
43
44
  HOTKEY_Debug,
45
+ HOTKEY_ListViewCMDK,
44
46
  HOTKEY_Switchlayout,
45
47
  HeaderMtmApi,
46
48
  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,41 @@
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 { jsx } from "react/jsx-runtime";
34
+ import { ListViewProvider } from "./ListViewProvider";
35
+ function ListViewPage(props) {
36
+ const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
37
+ return /* @__PURE__ */ jsx(ListViewProvider, __spreadProps(__spreadValues({}, etc), { children }));
38
+ }
39
+ export {
40
+ ListViewPage as default
41
+ };
@@ -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;
@@ -65,6 +65,7 @@ function ListViewProvider(props) {
65
65
  const [openEdit, setOpenEdit] = useState(false);
66
66
  const [openDebug, setOpenDebug] = useState(false);
67
67
  const [_params, _setParams] = useState(mtapp.globalSearchParams);
68
+ const [detailData, setDetailData] = useState(void 0);
68
69
  const params = useMemo(() => {
69
70
  var _a;
70
71
  return {
@@ -90,13 +91,22 @@ function ListViewProvider(props) {
90
91
  openDebug,
91
92
  setOpenDebug,
92
93
  params,
93
- setParams
94
+ setParams,
95
+ detailData,
96
+ setDetailData
94
97
  }, children });
95
98
  }
96
99
  function useListView() {
97
100
  const ctx = useContext(commonListViewContext);
98
101
  return __spreadValues({}, ctx);
99
102
  }
103
+ function useDetail() {
104
+ const mtappContext = useContext(commonListViewContext);
105
+ if (mtappContext === void 0) {
106
+ throw new Error("useDetail must be used within a MtAppProvider");
107
+ }
108
+ return __spreadValues({}, mtappContext);
109
+ }
100
110
  function CommonListView() {
101
111
  const listView = useListView();
102
112
  const listQuery = useSuspenseInfiniteQuery(listView.methodList, {
@@ -105,9 +115,6 @@ function CommonListView() {
105
115
  q: listView.params.q || ""
106
116
  }
107
117
  },
108
- // pagination: {
109
- // page: 1
110
- // }
111
118
  pagination: void 0
112
119
  }, {
113
120
  pageParamKey: "pagination",
@@ -199,5 +206,6 @@ export {
199
206
  CommonListView,
200
207
  ListViewActions,
201
208
  ListViewProvider,
209
+ useDetail,
202
210
  useListView
203
211
  };