gomtm 0.0.174 → 0.0.175

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.
@@ -1,37 +1,55 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useAtom } from "jotai";
3
4
  import { MtLink } from "mtxuilib/common/mtlink";
5
+ import { cn } from "mtxuilib/lib/utils";
6
+ import { useDebug } from "mtxuilib/store/app.atoms";
4
7
  import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "mtxuilib/ui/card";
8
+ import { curdActivateIdAtom } from "../../curd/CurdListView";
5
9
  import { BlogPostItemActions } from "./BlogPostActions";
6
10
  const PostCard = (props) => {
7
11
  const { item } = props;
8
- return /* @__PURE__ */ jsxs(Card, { className: "w-[350px]", children: [
9
- /* @__PURE__ */ jsxs(CardHeader, { children: [
10
- /* @__PURE__ */ jsx(CardTitle, { children: /* @__PURE__ */ jsx(MtLink, { href: `/post/${item.id}`, className: "pb-4 text-3xl font-bold hover:text-gray-700", children: item == null ? void 0 : item.title }) }),
11
- /* @__PURE__ */ jsx(CardDescription, { children: "Deploy your new project in one-click." })
12
- ] }),
13
- /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("article", { className: "my-4 flex flex-col", children: [
14
- /* @__PURE__ */ jsx(MtLink, {
15
- href: `/post/${item.id}`,
16
- className: "hover:opacity-75",
17
- // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
18
- children: item.topImage && /* @__PURE__ */ jsx("img", { src: item.topImage, alt: item.title })
19
- }),
20
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-start bg-white p-6", children: [
21
- /* @__PURE__ */ jsx(MtLink, { href: `/post/${item.id}`, className: "pb-4 text-sm font-bold uppercase text-blue-700", children: item.category || "news" }),
22
- /* @__PURE__ */ jsxs("p", { className: "pb-3 text-sm", children: [
23
- "By ",
24
- /* @__PURE__ */ jsx(MtLink, { href: "#", children: item.author }),
25
- ","
12
+ const debug = useDebug;
13
+ const [curdActivateId, setcurdActivateId] = useAtom(curdActivateIdAtom);
14
+ return /* @__PURE__ */ jsxs(
15
+ Card,
16
+ {
17
+ className: cn(
18
+ "w-[350px]",
19
+ item.id == curdActivateId && "bg-red-300 p-2"
20
+ ),
21
+ onClick: () => {
22
+ setcurdActivateId(item.id);
23
+ },
24
+ children: [
25
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
26
+ /* @__PURE__ */ jsx(CardTitle, { children: /* @__PURE__ */ jsx(MtLink, { href: `/post/${item.id}`, className: "pb-4 text-3xl font-bold hover:text-gray-700", children: item == null ? void 0 : item.title }) }),
27
+ /* @__PURE__ */ jsx(CardDescription, { children: "Deploy your new project in one-click." })
26
28
  ] }),
27
- /* @__PURE__ */ jsx("div", { children: item.excerpt })
28
- ] })
29
- ] }) }),
30
- /* @__PURE__ */ jsxs(CardFooter, { className: "flex justify-end", children: [
31
- /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `/post/${item.id}`, children: "Show" }),
32
- /* @__PURE__ */ jsx(BlogPostItemActions, { postId: item.id })
33
- ] })
34
- ] });
29
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("article", { className: "my-4 flex flex-col", children: [
30
+ /* @__PURE__ */ jsx(MtLink, {
31
+ href: `/post/${item.id}`,
32
+ className: "hover:opacity-75",
33
+ // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
34
+ children: item.topImage && /* @__PURE__ */ jsx("img", { src: item.topImage, alt: item.title })
35
+ }),
36
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-start bg-white p-6", children: [
37
+ /* @__PURE__ */ jsx(MtLink, { href: `/post/${item.id}`, className: "pb-4 text-sm font-bold uppercase text-blue-700", children: item.category || "news" }),
38
+ /* @__PURE__ */ jsxs("p", { className: "pb-3 text-sm", children: [
39
+ "By ",
40
+ /* @__PURE__ */ jsx(MtLink, { href: "#", children: item.author }),
41
+ ","
42
+ ] }),
43
+ /* @__PURE__ */ jsx("div", { children: item.excerpt })
44
+ ] })
45
+ ] }) }),
46
+ /* @__PURE__ */ jsxs(CardFooter, { className: "flex justify-end", children: [
47
+ /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `/post/${item.id}`, children: "Show" }),
48
+ /* @__PURE__ */ jsx(BlogPostItemActions, { postId: item.id })
49
+ ] })
50
+ ]
51
+ }
52
+ );
35
53
  };
36
54
  export {
37
55
  PostCard
@@ -1,13 +1,7 @@
1
- import { Message, PlainMessage } from "@bufbuild/protobuf";
2
- import { ConnectError } from "@connectrpc/connect";
3
- import { InfiniteData, UseSuspenseInfiniteQueryResult } from "@tanstack/react-query";
1
+ import { Message } from "@bufbuild/protobuf";
4
2
  import { PropsWithChildren } from "react";
5
3
  import { MethodUnaryDescriptor } from "../connectquery";
6
- import { MtmError } from "../gomtmpb/mtm/sppb/mtm_pb";
7
4
  export declare function CommonListViewProvider<I extends Message<I>, O extends Message<O>>(props: {
8
5
  methodList: MethodUnaryDescriptor<I, any>;
9
6
  } & PropsWithChildren): import("react").JSX.Element;
10
7
  export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
11
- export declare function useCommonListView<T extends Message<T>>(): {
12
- listQuery: UseSuspenseInfiniteQueryResult<InfiniteData<T & PlainMessage<MtmError>, unknown>, ConnectError> | null;
13
- };
@@ -79,14 +79,7 @@ const ListLayout = (props) => {
79
79
  return children;
80
80
  }
81
81
  };
82
- function useCommonListView() {
83
- const [listQuery, setListQuery] = useAtom(listQueryAtom);
84
- return {
85
- listQuery
86
- };
87
- }
88
82
  export {
89
83
  CommonListView,
90
- CommonListViewProvider,
91
- useCommonListView
84
+ CommonListViewProvider
92
85
  };
@@ -0,0 +1,16 @@
1
+ import { AnyMessage, Message, PlainMessage } from "@bufbuild/protobuf";
2
+ import { PropsWithChildren } from "react";
3
+ import { MethodUnaryDescriptor } from "../connectquery";
4
+ export declare const curdActivateIdAtom: import("jotai").PrimitiveAtom<string> & {
5
+ init: string;
6
+ };
7
+ export declare function Curd3ListProvider<I extends Message<I>, O extends Message<O>>(props: {
8
+ params: Partial<PlainMessage<I>>;
9
+ methodList: MethodUnaryDescriptor<I, O>;
10
+ } & PropsWithChildren): import("react").JSX.Element;
11
+ export declare const useCurd3List: () => {
12
+ params: PlainMessage<AnyMessage>;
13
+ curd3MethodList: MethodUnaryDescriptor<AnyMessage, AnyMessage> | null;
14
+ };
15
+ export declare const Curd2ListView: () => import("react").JSX.Element;
16
+ export declare const Curd3ListViewDebug: () => import("react").JSX.Element;
@@ -0,0 +1,99 @@
1
+ "use client";
2
+ var __async = (__this, __arguments, generator) => {
3
+ return new Promise((resolve, reject) => {
4
+ var fulfilled = (value) => {
5
+ try {
6
+ step(generator.next(value));
7
+ } catch (e) {
8
+ reject(e);
9
+ }
10
+ };
11
+ var rejected = (value) => {
12
+ try {
13
+ step(generator.throw(value));
14
+ } catch (e) {
15
+ reject(e);
16
+ }
17
+ };
18
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
19
+ step((generator = generator.apply(__this, __arguments)).next());
20
+ });
21
+ };
22
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
23
+ import { atom, useAtom } from "jotai";
24
+ import { ScopeProvider } from "mtxlib/jotai/ScopeProvider";
25
+ import { AtomsHydrator } from "mtxlib/jotai/jotai-helper";
26
+ import { MtUnaryCallErrorView } from "../components/MtUnaryCallErrorView";
27
+ import { callUnaryMethod } from "../connectquery";
28
+ import { ListViewLayout } from "../gomtmpb/mtm/sppb/mtm_pb";
29
+ import { gomtmBaseUrlAtom, transportAtom } from "../store/GomtmBackendProvider";
30
+ import { ListItemView } from "./list-item/ListItem";
31
+ const curdActivateIdAtom = atom("");
32
+ const curd3ListParamsAtom = atom({});
33
+ const curd3MethodListAtom = atom(null);
34
+ const curd3ItemsAtom = atom((get) => __async(void 0, null, function* () {
35
+ const params = get(curd3ListParamsAtom);
36
+ const methodList = get(curd3MethodListAtom);
37
+ if (!methodList) {
38
+ throw new Error("curd3ItemsAtom, missing methodList");
39
+ }
40
+ const transport = get(transportAtom);
41
+ const data = yield callUnaryMethod(methodList, params, { transport });
42
+ return data;
43
+ }));
44
+ function Curd3ListProvider(props) {
45
+ const { params, methodList, children } = props;
46
+ return /* @__PURE__ */ jsx(ScopeProvider, { atoms: [curd3ListParamsAtom, curd3MethodListAtom], children: /* @__PURE__ */ jsx(AtomsHydrator, { atomValues: [
47
+ [curd3ListParamsAtom, params],
48
+ [curd3MethodListAtom, methodList]
49
+ ], children }) });
50
+ }
51
+ const useCurd3List = () => {
52
+ const [curd3ListParams] = useAtom(curd3ListParamsAtom);
53
+ const [curd3MethodList] = useAtom(curd3MethodListAtom);
54
+ return {
55
+ params: curd3ListParams,
56
+ curd3MethodList
57
+ };
58
+ };
59
+ const Curd2ListView = () => {
60
+ const [res] = useAtom(curd3ItemsAtom);
61
+ return /* @__PURE__ */ jsx("div", { className: "bg-blue-100 p-2", children: res.errCode ? /* @__PURE__ */ jsx(MtUnaryCallErrorView, { unaryError: res }) : /* @__PURE__ */ jsx(Fragment, { children: res.items.map((item, i) => {
62
+ return /* @__PURE__ */ jsx(ListItemView, { item }, i);
63
+ }) }) });
64
+ };
65
+ const ListLayout = (props) => {
66
+ const { children } = props;
67
+ switch (props.layout) {
68
+ case ListViewLayout.simple:
69
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1 rounded-md p-2 shadow-sm", children });
70
+ case ListViewLayout.grid:
71
+ return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children });
72
+ case ListViewLayout.card:
73
+ return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children });
74
+ default:
75
+ return children;
76
+ }
77
+ };
78
+ const Curd3ListViewDebug = () => {
79
+ const curd3 = useCurd3List();
80
+ const [gomtmBaseUrl] = useAtom(gomtmBaseUrlAtom);
81
+ return /* @__PURE__ */ jsxs("div", { className: "bg-slate-200 p-2", children: [
82
+ /* @__PURE__ */ jsx("h1", { children: "Curd3ListViewDebug" }),
83
+ /* @__PURE__ */ jsxs("div", { children: [
84
+ "params: ",
85
+ /* @__PURE__ */ jsx("pre", { children: JSON.stringify(curd3, null, 2) })
86
+ ] }),
87
+ /* @__PURE__ */ jsxs("div", { children: [
88
+ "gomtmBaseUrl:",
89
+ gomtmBaseUrl
90
+ ] })
91
+ ] });
92
+ };
93
+ export {
94
+ Curd2ListView,
95
+ Curd3ListProvider,
96
+ Curd3ListViewDebug,
97
+ curdActivateIdAtom,
98
+ useCurd3List
99
+ };
@@ -6,7 +6,7 @@ import { createContext, useMemo, useState } from "react";
6
6
  import { Icons } from "mtxuilib/icons/icons";
7
7
  import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
8
8
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
9
- import { curd3activateIdAtom } from "./CurdListViewV3";
9
+ import { curdActivateIdAtom } from "./CurdListView";
10
10
  const curdDetailViewContext = createContext(void 0);
11
11
  function CurdViewDetailProvider(props) {
12
12
  const [isOpenEdit, setIsOpenEdit] = useState(false);
@@ -17,7 +17,7 @@ function CurdViewDetailProvider(props) {
17
17
  }
18
18
  function CurdViewShow(props) {
19
19
  const { children } = props;
20
- const [activateId, setActivateId] = useAtom(curd3activateIdAtom);
20
+ const [activateId, setActivateId] = useAtom(curdActivateIdAtom);
21
21
  const search = useSearchParams();
22
22
  useMemo(() => {
23
23
  const id = search.get("id");
@@ -3,4 +3,7 @@ import { PlainMessage } from "@bufbuild/protobuf";
3
3
  import { ListItem } from "../../gomtmpb/mtm/sppb/mtm_pb";
4
4
  export declare const ListItemView: (props: {
5
5
  item: PlainMessage<ListItem>;
6
+ }) => import("react").JSX.Element;
7
+ export declare const ListItemViewInner: (props: {
8
+ item: PlainMessage<ListItem>;
6
9
  }) => import("react").JSX.Element | null;
@@ -1,9 +1,13 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
2
+ import { Fragment, jsx } from "react/jsx-runtime";
3
3
  import { cn } from "mtxuilib/lib/utils";
4
4
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
5
5
  import { PostCard } from "../../components/blog/PostCard";
6
6
  const ListItemView = (props) => {
7
+ const { item } = props;
8
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ListItemViewInner, { item }) });
9
+ };
10
+ const ListItemViewInner = (props) => {
7
11
  var _a, _b;
8
12
  const { item } = props;
9
13
  if ((_a = item == null ? void 0 : item.item) == null ? void 0 : _a.value) {
@@ -37,5 +41,6 @@ const CommonListItemView = (props) => {
37
41
  );
38
42
  };
39
43
  export {
40
- ListItemView
44
+ ListItemView,
45
+ ListItemViewInner
41
46
  };