gomtm 0.0.170 → 0.0.172

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.
@@ -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 curd3activateIdAtom: 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 Curd3ListViewDebug: () => import("react").JSX.Element;
16
+ export declare const Curd2ListView: () => import("react").JSX.Element;
@@ -0,0 +1,80 @@
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 { 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 { callUnaryMethod } from "../connectquery";
27
+ import { gomtmBaseUrlAtom, transportAtom } from "../store/GomtmBackendProvider";
28
+ const curd3activateIdAtom = atom("");
29
+ const curd3ListParamsAtom = atom({});
30
+ const curd3MethodListAtom = atom(null);
31
+ const curd3ItemsAtom = atom((get) => __async(void 0, null, function* () {
32
+ const params = get(curd3ListParamsAtom);
33
+ const methodList = get(curd3MethodListAtom);
34
+ if (!methodList) {
35
+ throw new Error("curd3ItemsAtom, missing methodList");
36
+ }
37
+ const transport = get(transportAtom);
38
+ return yield callUnaryMethod(methodList, params, { transport });
39
+ }));
40
+ function Curd3ListProvider(props) {
41
+ const { params, methodList, children } = props;
42
+ return /* @__PURE__ */ jsx(ScopeProvider, { atoms: [curd3ListParamsAtom, curd3MethodListAtom], children: /* @__PURE__ */ jsx(AtomsHydrator, { atomValues: [
43
+ [curd3ListParamsAtom, params],
44
+ [curd3MethodListAtom, methodList]
45
+ ], children }) });
46
+ }
47
+ const useCurd3List = () => {
48
+ const [curd3ListParams] = useAtom(curd3ListParamsAtom);
49
+ const [curd3MethodList] = useAtom(curd3MethodListAtom);
50
+ return {
51
+ params: curd3ListParams,
52
+ curd3MethodList
53
+ };
54
+ };
55
+ const Curd3ListViewDebug = () => {
56
+ const curd3 = useCurd3List();
57
+ const [gomtmBaseUrl] = useAtom(gomtmBaseUrlAtom);
58
+ return /* @__PURE__ */ jsxs("div", { className: "bg-slate-200 p-2", children: [
59
+ /* @__PURE__ */ jsx("h1", { children: "Curd3ListViewDebug" }),
60
+ /* @__PURE__ */ jsxs("div", { children: [
61
+ "params: ",
62
+ /* @__PURE__ */ jsx("pre", { children: JSON.stringify(curd3, null, 2) })
63
+ ] }),
64
+ /* @__PURE__ */ jsxs("div", { children: [
65
+ "gomtmBaseUrl:",
66
+ gomtmBaseUrl
67
+ ] })
68
+ ] });
69
+ };
70
+ const Curd2ListView = () => {
71
+ const [items] = useAtom(curd3ItemsAtom);
72
+ return /* @__PURE__ */ jsx("div", { className: "bg-blue-100 p-2", children: /* @__PURE__ */ jsx("pre", { children: JSON.stringify(items, null, 2) }) });
73
+ };
74
+ export {
75
+ Curd2ListView,
76
+ Curd3ListProvider,
77
+ Curd3ListViewDebug,
78
+ curd3activateIdAtom,
79
+ useCurd3List
80
+ };
@@ -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 { activateIdAtom, useCurdView } from "./CurdViewView";
9
+ import { curd3activateIdAtom } from "./CurdListViewV3";
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(activateIdAtom);
20
+ const [activateId, setActivateId] = useAtom(curd3activateIdAtom);
21
21
  const search = useSearchParams();
22
22
  useMemo(() => {
23
23
  const id = search.get("id");
@@ -31,7 +31,6 @@ function CurdViewShow(props) {
31
31
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(CurdViewDetailProvider, {}) });
32
32
  }
33
33
  const DetailViewActions = () => {
34
- const curd = useCurdView();
35
34
  return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
36
35
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(MtButton, { variant: "ghost", className: "m-0 flex h-10 w-10 items-center justify-center border p-0 shadow-sm backdrop-blur", children: /* @__PURE__ */ jsx(Icons.ellipsis, {}) }) }),
37
36
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56", children: [
@@ -1,10 +1,8 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { MtLink } from "mtxuilib/common/mtlink";
2
+ import { jsx } from "react/jsx-runtime";
4
3
  import { cn } from "mtxuilib/lib/utils";
5
4
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
6
5
  import { PostCard } from "../../components/blog/PostCard";
7
- import { useCurdView } from "../CurdViewView";
8
6
  const ListItemView = (props) => {
9
7
  var _a, _b;
10
8
  const { item } = props;
@@ -23,9 +21,7 @@ const ListItemView = (props) => {
23
21
  };
24
22
  const CommonListItemView = (props) => {
25
23
  const { item } = props;
26
- const curd = useCurdView();
27
24
  const handleSelect = () => {
28
- curd.openShow(item.id);
29
25
  };
30
26
  return /* @__PURE__ */ jsx(
31
27
  MtButton,
@@ -33,14 +29,10 @@ const CommonListItemView = (props) => {
33
29
  variant: "ghost",
34
30
  onClick: handleSelect,
35
31
  className: cn(
36
- "flex min-h-16 justify-start border p-4 text-left",
37
- item.id == curd.activateId && " font-bold"
32
+ "flex min-h-16 justify-start border p-4 text-left"
33
+ // item.id == curd.activateId && " font-bold"
38
34
  ),
39
- "aria-label": item.id,
40
- children: /* @__PURE__ */ jsxs(MtLink, { href: curd.showLink(item.id), children: [
41
- item.title || item.id,
42
- item.description && /* @__PURE__ */ jsx("div", { children: item.description })
43
- ] })
35
+ "aria-label": item.id
44
36
  }
45
37
  );
46
38
  };
@@ -1,14 +1,10 @@
1
1
  "use client";
2
2
  import { Fragment, jsx } from "react/jsx-runtime";
3
- import { MtLink } from "mtxuilib/common/mtlink";
4
- import { useCurdView } from "./CurdViewView";
5
3
  const CurdEditButton = () => {
6
- const curd = useCurdView();
7
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: curd.editLink(curd.activateId), children: "edit" }) });
4
+ return /* @__PURE__ */ jsx(Fragment, {});
8
5
  };
9
6
  const CurdCreateButton = () => {
10
- const curd = useCurdView();
11
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: curd.createLink, children: "new" }) });
7
+ return /* @__PURE__ */ jsx(Fragment, {});
12
8
  };
13
9
  export {
14
10
  CurdCreateButton,