gomtm 0.0.172 → 0.0.174
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.
|
@@ -12,5 +12,5 @@ export declare const useCurd3List: () => {
|
|
|
12
12
|
params: PlainMessage<AnyMessage>;
|
|
13
13
|
curd3MethodList: MethodUnaryDescriptor<AnyMessage, AnyMessage> | null;
|
|
14
14
|
};
|
|
15
|
-
export declare const Curd3ListViewDebug: () => import("react").JSX.Element;
|
|
16
15
|
export declare const Curd2ListView: () => import("react").JSX.Element;
|
|
16
|
+
export declare const Curd3ListViewDebug: () => import("react").JSX.Element;
|
|
@@ -19,12 +19,15 @@ var __async = (__this, __arguments, generator) => {
|
|
|
19
19
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
23
23
|
import { atom, useAtom } from "jotai";
|
|
24
24
|
import { ScopeProvider } from "mtxlib/jotai/ScopeProvider";
|
|
25
25
|
import { AtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
26
|
+
import { MtUnaryCallErrorView } from "../components/MtUnaryCallErrorView";
|
|
26
27
|
import { callUnaryMethod } from "../connectquery";
|
|
28
|
+
import { ListViewLayout } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
27
29
|
import { gomtmBaseUrlAtom, transportAtom } from "../store/GomtmBackendProvider";
|
|
30
|
+
import { ListItemView } from "./list-item/ListItem";
|
|
28
31
|
const curd3activateIdAtom = atom("");
|
|
29
32
|
const curd3ListParamsAtom = atom({});
|
|
30
33
|
const curd3MethodListAtom = atom(null);
|
|
@@ -35,7 +38,8 @@ const curd3ItemsAtom = atom((get) => __async(void 0, null, function* () {
|
|
|
35
38
|
throw new Error("curd3ItemsAtom, missing methodList");
|
|
36
39
|
}
|
|
37
40
|
const transport = get(transportAtom);
|
|
38
|
-
|
|
41
|
+
const data = yield callUnaryMethod(methodList, params, { transport });
|
|
42
|
+
return data;
|
|
39
43
|
}));
|
|
40
44
|
function Curd3ListProvider(props) {
|
|
41
45
|
const { params, methodList, children } = props;
|
|
@@ -52,6 +56,25 @@ const useCurd3List = () => {
|
|
|
52
56
|
curd3MethodList
|
|
53
57
|
};
|
|
54
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
|
+
};
|
|
55
78
|
const Curd3ListViewDebug = () => {
|
|
56
79
|
const curd3 = useCurd3List();
|
|
57
80
|
const [gomtmBaseUrl] = useAtom(gomtmBaseUrlAtom);
|
|
@@ -67,10 +90,6 @@ const Curd3ListViewDebug = () => {
|
|
|
67
90
|
] })
|
|
68
91
|
] });
|
|
69
92
|
};
|
|
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
93
|
export {
|
|
75
94
|
Curd2ListView,
|
|
76
95
|
Curd3ListProvider,
|