gomtm 0.0.192 → 0.0.194

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.
@@ -2,9 +2,11 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useAtom } from "jotai";
4
4
  import { MtLink } from "mtxuilib/common/mtlink";
5
+ import { flexRender } from "mtxuilib/lib/render";
5
6
  import { cn } from "mtxuilib/lib/utils";
6
7
  import { useDebug } from "mtxuilib/store/app.atoms";
7
8
  import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "mtxuilib/ui/card";
9
+ import { exampleListItemComponent } from "../../curd/CommonListViewV2";
8
10
  import { curdActivateIdAtom, curdDashPathPrefixAtom } from "../../curd/curd.atoms";
9
11
  import { BlogPostItemActions } from "./BlogPostActions";
10
12
  const PostCard = (props) => {
@@ -12,6 +14,7 @@ const PostCard = (props) => {
12
14
  const debug = useDebug();
13
15
  const [curdActivateId, setcurdActivateId] = useAtom(curdActivateIdAtom);
14
16
  const [dashPrefix] = useAtom(curdDashPathPrefixAtom);
17
+ const [Comp] = useAtom(exampleListItemComponent);
15
18
  return /* @__PURE__ */ jsxs(
16
19
  Card,
17
20
  {
@@ -47,7 +50,8 @@ const PostCard = (props) => {
47
50
  ] }) }),
48
51
  /* @__PURE__ */ jsxs(CardFooter, { className: "flex justify-end", children: [
49
52
  /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `/post/${item.id}`, children: "Show" }),
50
- /* @__PURE__ */ jsx(BlogPostItemActions, { postId: item.id })
53
+ /* @__PURE__ */ jsx(BlogPostItemActions, { postId: item.id }),
54
+ Comp ? flexRender(Comp, {}) : /* @__PURE__ */ jsx("div", { children: "no comp" })
51
55
  ] })
52
56
  ]
53
57
  }
@@ -2,6 +2,10 @@ import { Message } from "@bufbuild/protobuf";
2
2
  import { PropsWithChildren } from "react";
3
3
  import { MethodUnaryDescriptor } from "../connectquery";
4
4
  export declare const curdSlugPathAtom: import("jotai").Atom<string>;
5
+ export declare const exampleListItemValueComponent: import("jotai").PrimitiveAtom<any> & {
6
+ init: any;
7
+ };
8
+ export declare const exampleListItemComponent: import("jotai").Atom<any>;
5
9
  export declare function CommonListViewProvider<I extends Message<I>, O extends Message<O>>(props: {
6
10
  methodList: MethodUnaryDescriptor<I, any>;
7
11
  slugPath?: string;
@@ -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) => {
@@ -17,6 +17,16 @@ const curdSlugPathAtom = atom((get) => {
17
17
  }
18
18
  return value || "";
19
19
  });
20
+ const exampleListItemValueComponent = atom(void 0);
21
+ const exampleListItemComponent = atom((get) => {
22
+ const v = get(exampleListItemValueComponent);
23
+ if (v) {
24
+ return v;
25
+ }
26
+ return () => {
27
+ return /* @__PURE__ */ jsx("div", { children: "missing exampleListItemComponent" });
28
+ };
29
+ });
20
30
  function CommonListViewProvider(props) {
21
31
  const { children, methodList, slugPath } = props;
22
32
  const listquery = useSuspenseInfiniteQuery(methodList, {
@@ -71,21 +81,10 @@ function CommonListView() {
71
81
  /* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1" })
72
82
  ] });
73
83
  }
74
- const ListLayout = (props) => {
75
- const { children } = props;
76
- switch (props.layout) {
77
- case ListViewLayout.simple:
78
- return /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1 rounded-md p-2 shadow-sm", children });
79
- case ListViewLayout.grid:
80
- return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children });
81
- case ListViewLayout.card:
82
- return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children });
83
- default:
84
- return children;
85
- }
86
- };
87
84
  export {
88
85
  CommonListView,
89
86
  CommonListViewProvider,
90
- curdSlugPathAtom
87
+ curdSlugPathAtom,
88
+ exampleListItemComponent,
89
+ exampleListItemValueComponent
91
90
  };
@@ -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
@@ -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
+ postId: string;
8
+ }) => import("react").JSX.Element;
@@ -0,0 +1,88 @@
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, curdDashPathPrefixAtom } 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 { MtButton } from "mtxuilib/ui/ui-mt/Button";
11
+ import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
12
+ import { curdSlugPathAtom } from "../CommonListViewV2";
13
+ const PostCardListItem = (props) => {
14
+ const { item } = props;
15
+ const [curdActivateId, setcurdActivateId] = useAtom(curdActivateIdAtom);
16
+ const [dashPrefix] = useAtom(curdDashPathPrefixAtom);
17
+ return /* @__PURE__ */ jsxs(
18
+ Card,
19
+ {
20
+ className: cn(
21
+ "m-2 w-[350px]",
22
+ item.id == curdActivateId && " p-2 shadow-md"
23
+ ),
24
+ onClick: () => {
25
+ setcurdActivateId(item.id);
26
+ },
27
+ children: [
28
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
29
+ /* @__PURE__ */ jsx(CardTitle, { children: /* @__PURE__ */ jsx(MtLink, { href: `${dashPrefix}/post/${item.id}`, className: "pb-4 text-3xl font-bold hover:text-gray-700", children: item == null ? void 0 : item.title }) }),
30
+ /* @__PURE__ */ jsx(CardDescription, { children: "Deploy your new project in one-click." })
31
+ ] }),
32
+ /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("article", { className: "my-4 flex flex-col", children: [
33
+ /* @__PURE__ */ jsx(MtLink, {
34
+ href: `/post/${item.id}`,
35
+ className: "hover:opacity-75",
36
+ // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
37
+ children: item.topImage && /* @__PURE__ */ jsx("img", { src: item.topImage, alt: item.title })
38
+ }),
39
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-start bg-white p-6", children: [
40
+ /* @__PURE__ */ jsx(MtLink, { href: `/post/${item.id}`, className: "pb-4 text-sm font-bold uppercase text-blue-700", children: item.category || "news" }),
41
+ /* @__PURE__ */ jsxs("p", { className: "pb-3 text-sm", children: [
42
+ "By ",
43
+ /* @__PURE__ */ jsx(MtLink, { href: "#", children: item.author }),
44
+ ","
45
+ ] }),
46
+ /* @__PURE__ */ jsx("div", { children: item.excerpt })
47
+ ] })
48
+ ] }) }),
49
+ /* @__PURE__ */ jsxs(CardFooter, { className: "flex justify-end", children: [
50
+ /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `/post/${item.id}`, children: "Show" }),
51
+ /* @__PURE__ */ jsx(PostCardItemActions, { postId: item.id })
52
+ ] })
53
+ ]
54
+ }
55
+ );
56
+ };
57
+ const PostCardItemActions = (props) => {
58
+ const { postId } = props;
59
+ const [curdSlugPath] = useAtom(curdSlugPathAtom);
60
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
61
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
62
+ MtButton,
63
+ {
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: "Open menu" })
69
+ ]
70
+ }
71
+ ) }),
72
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-[160px]", children: [
73
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `/post/${postId}/create`, children: "create" }),
74
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `/post/show`, children: "show" }),
75
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/edit`, children: "edit" }),
76
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/listdebug`, children: "list debug" }),
77
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
78
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
79
+ "Delete",
80
+ /* @__PURE__ */ jsx(DropdownMenuShortcut, { children: "\u2318\u232B" })
81
+ ] })
82
+ ] })
83
+ ] });
84
+ };
85
+ export {
86
+ PostCardItemActions,
87
+ PostCardListItem
88
+ };