gomtm 0.0.193 → 0.0.195

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.
@@ -6,8 +6,8 @@ import { cn } from "mtxuilib/lib/utils";
6
6
  import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
7
7
  import { MtUnaryCallErrorView } from "../components/MtUnaryCallErrorView";
8
8
  import { useSuspenseInfiniteQuery } from "../connectquery";
9
- import { ListViewLayout } from "../gomtmpb/mtm/sppb/mtm_pb";
10
9
  import { ListItemView } from "./list-item/ListItem";
10
+ import { ListLayout } from "./list-item/ListLayout";
11
11
  const listQueryAtom = atom(null);
12
12
  const curdSlugPathValueAtom = atom("");
13
13
  const curdSlugPathAtom = atom((get) => {
@@ -23,11 +23,10 @@ const exampleListItemComponent = atom((get) => {
23
23
  if (v) {
24
24
  return v;
25
25
  }
26
- return HelloComp;
26
+ return () => {
27
+ return /* @__PURE__ */ jsx("div", { children: "missing exampleListItemComponent" });
28
+ };
27
29
  });
28
- const HelloComp = () => {
29
- return /* @__PURE__ */ jsx("div", { children: "HelloComp" });
30
- };
31
30
  function CommonListViewProvider(props) {
32
31
  const { children, methodList, slugPath } = props;
33
32
  const listquery = useSuspenseInfiniteQuery(methodList, {
@@ -82,19 +81,6 @@ function CommonListView() {
82
81
  /* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1" })
83
82
  ] });
84
83
  }
85
- const ListLayout = (props) => {
86
- const { children } = props;
87
- switch (props.layout) {
88
- case ListViewLayout.simple:
89
- return /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1 rounded-md p-2 shadow-sm", children });
90
- case ListViewLayout.grid:
91
- return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children });
92
- case ListViewLayout.card:
93
- return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children });
94
- default:
95
- return children;
96
- }
97
- };
98
84
  export {
99
85
  CommonListView,
100
86
  CommonListViewProvider,
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { atom, useAtom } from "jotai";
3
+ import { atom } from "jotai";
4
4
  import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
5
5
  import { Icons } from "mtxuilib/icons/icons";
6
6
  import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
@@ -21,7 +21,6 @@ function CurdViewDetailProvider(props) {
21
21
  }
22
22
  const CurdViewDetailDefault = () => {
23
23
  var _a, _b, _c, _d;
24
- const [slugPath] = useAtom(curdDetailSlugAtom);
25
24
  const nameSlug = useCurdSlugName();
26
25
  const detailQuery = useSuspenseQuery(curdDetail, {
27
26
  slug: nameSlug
@@ -1,8 +1,5 @@
1
1
  import { AnyMessage, PlainMessage } from "@bufbuild/protobuf";
2
2
  import { CommontListRes } from "../gomtmpb/mtm/sppb/mtm_pb";
3
- export declare const curdDashPathPrefixAtom: import("jotai").PrimitiveAtom<string> & {
4
- init: string;
5
- };
6
3
  export declare const curdActivateIdAtom: import("jotai").PrimitiveAtom<string> & {
7
4
  init: string;
8
5
  };
@@ -20,11 +20,10 @@ var __async = (__this, __arguments, generator) => {
20
20
  });
21
21
  };
22
22
  import { atom } from "jotai";
23
- import { CommontListRes } from "../gomtmpb/mtm/sppb/mtm_pb";
24
- import { gomtmBaseUrlAtom } from "../providers/GomtmProvider";
25
23
  import { usePathname } from "next/navigation";
26
24
  import { useMemo } from "react";
27
- const curdDashPathPrefixAtom = atom("/gomtmadmin");
25
+ import { CommontListRes } from "../gomtmpb/mtm/sppb/mtm_pb";
26
+ import { gomtmBaseUrlAtom } from "../providers/GomtmProvider";
28
27
  const curdActivateIdAtom = atom("");
29
28
  const curd3ListParamsAtom = atom({});
30
29
  const curdPathAtom = atom("");
@@ -52,7 +51,6 @@ export {
52
51
  curd3ItemsV2Atom,
53
52
  curd3ListParamsAtom,
54
53
  curdActivateIdAtom,
55
- curdDashPathPrefixAtom,
56
54
  curdPathAtom,
57
55
  useCurdSlugName
58
56
  };
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { PlainMessage } from "@bufbuild/protobuf";
3
+ import { CommonListItem } from "../../gomtmpb/mtm/sppb/mtm_pb";
4
+ export declare const CommonListItemView: (props: {
5
+ item: PlainMessage<CommonListItem>;
6
+ }) => import("react").JSX.Element;
7
+ export declare const ListItemViewActions: (props: {
8
+ id: string;
9
+ }) => import("react").JSX.Element;
@@ -0,0 +1,69 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useAtom } from "jotai";
4
+ import { MtLink } from "mtxuilib/common/mtlink";
5
+ import { Icons } from "mtxuilib/icons/icons";
6
+ import { cn } from "mtxuilib/lib/utils";
7
+ import { buttonVariants } from "mtxuilib/ui/button";
8
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
9
+ import { MtButton } from "mtxuilib/ui/ui-mt/Button";
10
+ import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
11
+ import { curdSlugPathAtom } from "../CommonListViewV2";
12
+ const CommonListItemView = (props) => {
13
+ const { item } = props;
14
+ const handleSelect = () => {
15
+ };
16
+ const [curdSlugPath] = useAtom(curdSlugPathAtom);
17
+ return /* @__PURE__ */ jsxs(
18
+ "div",
19
+ {
20
+ "aria-label": item.id,
21
+ onClick: handleSelect,
22
+ className: cn(
23
+ buttonVariants({
24
+ variant: "ghost"
25
+ }),
26
+ "flex min-h-16 justify-start border p-4 text-left"
27
+ ),
28
+ children: [
29
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxs(MtLink, { href: `${curdSlugPath}/${item.id}`, children: [
30
+ curdSlugPath,
31
+ item.title || item.id,
32
+ item.description && /* @__PURE__ */ jsx("div", { children: item.description })
33
+ ] }) }),
34
+ /* @__PURE__ */ jsx(ListItemViewActions, { id: item.id })
35
+ ]
36
+ }
37
+ );
38
+ };
39
+ const ListItemViewActions = (props) => {
40
+ const { id } = props;
41
+ const [curdSlugPath] = useAtom(curdSlugPathAtom);
42
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
43
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
44
+ MtButton,
45
+ {
46
+ variant: "ghost",
47
+ className: "data-[state=open]:bg-muted flex size-8 p-0",
48
+ children: [
49
+ /* @__PURE__ */ jsx(Icons.chevronRight, { className: "size-4" }),
50
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Open menu" })
51
+ ]
52
+ }
53
+ ) }),
54
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-[160px]", children: [
55
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/show`, children: "show" }),
56
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/edit`, children: "edit" }),
57
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/listdebug`, children: "list debug" }),
58
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
59
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
60
+ "Delete",
61
+ /* @__PURE__ */ jsx(DropdownMenuShortcut, { children: "\u2318\u232B" })
62
+ ] })
63
+ ] })
64
+ ] });
65
+ };
66
+ export {
67
+ CommonListItemView,
68
+ ListItemViewActions
69
+ };
@@ -1,12 +1,7 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useAtom } from "jotai";
4
- import { MtLink } from "mtxuilib/common/mtlink";
5
- import { cn } from "mtxuilib/lib/utils";
6
- import { MtButton } from "mtxuilib/ui/ui-mt/Button";
7
- import { useMemo } from "react";
8
- import { PostCard } from "../../components/blog/PostCard";
9
- import { curdPathAtom } from "../curd.atoms";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { CommonListItemView } from "./CommonListItemView";
4
+ import { PostCardListItem } from "./PostCardListItem";
10
5
  const ListItemView = (props) => {
11
6
  var _a, _b;
12
7
  const { item } = props;
@@ -16,41 +11,13 @@ const ListItemView = (props) => {
16
11
  case "commonListItem":
17
12
  return /* @__PURE__ */ jsx(CommonListItemView, { item: item.item.value });
18
13
  case "postCard":
19
- return /* @__PURE__ */ jsx(PostCard, { item: item.item.value });
14
+ return /* @__PURE__ */ jsx(PostCardListItem, { item: item.item.value });
20
15
  default:
21
16
  return /* @__PURE__ */ jsx("span", { className: "bg-red-600 p-2", children: "unknow list item type" });
22
17
  }
23
18
  }
24
19
  return null;
25
20
  };
26
- const CommonListItemView = (props) => {
27
- const { item } = props;
28
- const handleSelect = () => {
29
- };
30
- const [slugPath] = useAtom(curdPathAtom);
31
- const slug = useMemo(() => {
32
- const path2 = slugPath.split("/");
33
- if (path2.length >= 2) {
34
- return path2[2];
35
- }
36
- }, [slugPath]);
37
- return /* @__PURE__ */ jsx(
38
- MtButton,
39
- {
40
- variant: "ghost",
41
- onClick: handleSelect,
42
- className: cn(
43
- "flex min-h-16 justify-start border p-4 text-left"
44
- // item.id == curd.activateId && " font-bold"
45
- ),
46
- "aria-label": item.id,
47
- children: /* @__PURE__ */ jsxs(MtLink, { href: `/admin/${slug}/${item.id}`, children: [
48
- item.title || item.id,
49
- item.description && /* @__PURE__ */ jsx("div", { children: item.description })
50
- ] })
51
- }
52
- );
53
- };
54
21
  export {
55
22
  ListItemView
56
23
  };
@@ -0,0 +1,6 @@
1
+ /// <reference types="react/experimental" />
2
+ import { PropsWithChildren } from "react";
3
+ import { ListViewLayout } from "../../gomtmpb/mtm/sppb/mtm_pb";
4
+ export declare const ListLayout: (props: {
5
+ layout: ListViewLayout;
6
+ } & PropsWithChildren) => string | number | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<import("react").AwaitedReactNode> | null | undefined;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { ListViewLayout } from "../../gomtmpb/mtm/sppb/mtm_pb";
4
+ const ListLayout = (props) => {
5
+ const { children } = props;
6
+ switch (props.layout) {
7
+ case ListViewLayout.simple:
8
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-1 rounded-md p-2 shadow-sm", children: [
9
+ /* @__PURE__ */ jsx("div", { children: "simple-list-layout" }),
10
+ children
11
+ ] });
12
+ case ListViewLayout.grid:
13
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children: [
14
+ /* @__PURE__ */ jsx("div", { children: "grid-layout" }),
15
+ children
16
+ ] });
17
+ case ListViewLayout.card:
18
+ return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children });
19
+ default:
20
+ return children;
21
+ }
22
+ };
23
+ export {
24
+ ListLayout
25
+ };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { PostCardItem } from "../../gomtmpb/mtm/sppb/mtm_pb";
3
+ export declare const PostCardListItem: (props: {
4
+ item: PostCardItem;
5
+ }) => import("react").JSX.Element;
6
+ export declare const PostCardItemActions: (props: {
7
+ id: string;
8
+ }) => import("react").JSX.Element;
@@ -0,0 +1,87 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useAtom } from "jotai";
4
+ import { MtLink } from "mtxuilib/common/mtlink";
5
+ import { cn } from "mtxuilib/lib/utils";
6
+ import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "mtxuilib/ui/card";
7
+ import { curdActivateIdAtom } from "../curd.atoms";
8
+ import { Icons } from "mtxuilib/icons/icons";
9
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
10
+ import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
11
+ import { curdSlugPathAtom } from "../CommonListViewV2";
12
+ const PostCardListItem = (props) => {
13
+ const { item } = props;
14
+ const [curdActivateId, setcurdActivateId] = useAtom(curdActivateIdAtom);
15
+ const [curdSlugPath] = useAtom(curdSlugPathAtom);
16
+ return /* @__PURE__ */ jsxs(
17
+ Card,
18
+ {
19
+ className: cn(
20
+ "m-2 w-[350px]",
21
+ item.id == curdActivateId && " p-2 shadow-md"
22
+ ),
23
+ onClick: () => {
24
+ setcurdActivateId(item.id);
25
+ },
26
+ children: [
27
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
28
+ /* @__PURE__ */ jsx(CardTitle, { children: /* @__PURE__ */ jsx(MtLink, { href: `${curdSlugPath}/${item.id}`, className: "pb-4 text-3xl font-bold hover:text-gray-700", children: item == null ? void 0 : item.title }) }),
29
+ /* @__PURE__ */ jsx(CardDescription, { children: "Deploy your new project in one-click." })
30
+ ] }),
31
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("article", { className: "my-4 flex flex-col", children: [
32
+ /* @__PURE__ */ jsx(MtLink, {
33
+ href: `${curdSlugPath}/${item.id}`,
34
+ className: "hover:opacity-75",
35
+ // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
36
+ children: item.topImage && /* @__PURE__ */ jsx("img", { src: item.topImage, alt: item.title })
37
+ }),
38
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-start bg-white p-6", children: [
39
+ /* @__PURE__ */ jsx(MtLink, { href: `${curdSlugPath}/${item.id}`, className: "pb-4 text-sm font-bold uppercase text-blue-700", children: item.category || "news" }),
40
+ /* @__PURE__ */ jsxs("p", { className: "pb-3 text-sm", children: [
41
+ "By ",
42
+ /* @__PURE__ */ jsx(MtLink, { href: "#", children: item.author }),
43
+ ","
44
+ ] }),
45
+ /* @__PURE__ */ jsx("div", { children: item.excerpt })
46
+ ] })
47
+ ] }) }),
48
+ /* @__PURE__ */ jsxs(CardFooter, { className: "flex justify-end", children: [
49
+ /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `${curdSlugPath}/${item.id}`, children: "Show" }),
50
+ /* @__PURE__ */ jsx(PostCardItemActions, { id: item.id })
51
+ ] })
52
+ ]
53
+ }
54
+ );
55
+ };
56
+ const PostCardItemActions = (props) => {
57
+ const { id } = props;
58
+ const [curdSlugPath] = useAtom(curdSlugPathAtom);
59
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
60
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
61
+ MtLink,
62
+ {
63
+ href: `${curdSlugPath}/${id}`,
64
+ variant: "ghost",
65
+ className: "data-[state=open]:bg-muted flex size-8 p-0",
66
+ children: [
67
+ /* @__PURE__ */ jsx(Icons.chevronRight, { className: "size-4" }),
68
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "more" })
69
+ ]
70
+ }
71
+ ) }),
72
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-[160px]", children: [
73
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/create/${id}`, children: "create" }),
74
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/edit/${id}`, children: "edit" }),
75
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/listdebug`, children: "list debug" }),
76
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
77
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
78
+ "Delete",
79
+ /* @__PURE__ */ jsx(DropdownMenuShortcut, { children: "\u2318\u232B" })
80
+ ] })
81
+ ] })
82
+ ] });
83
+ };
84
+ export {
85
+ PostCardItemActions,
86
+ PostCardListItem
87
+ };