gomtm 0.0.358 → 0.0.360
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.
- package/dist/esm/components/curdView/curdViewEditor.d.ts +2 -0
- package/dist/esm/components/curdView/curdViewEditor.js +8 -0
- package/dist/esm/curd/CurdView.js +1 -1
- package/dist/esm/curd/CurdViewSS.js +3 -3
- package/dist/esm/curd/DynViews.d.ts +1 -0
- package/dist/esm/curd/DynViews.js +46 -3
- package/dist/esm/curd/form/CurdEditPanel.d.ts +2 -0
- package/dist/esm/curd/form/CurdEditPanel.js +56 -0
- package/dist/esm/curd/form/GomtmForm.d.ts +2 -0
- package/dist/esm/curd/form/GomtmForm.js +46 -0
- package/dist/esm/curd/form/formStore.d.ts +29 -0
- package/dist/esm/curd/form/formStore.js +159 -0
- package/dist/esm/curd/form/useCurdUpdateForm.d.ts +7 -0
- package/dist/esm/curd/form/useCurdUpdateForm.js +25 -0
- package/dist/esm/curd/listview/CommonListView.js +57 -40
- package/dist/esm/curd/listview/list-store.d.ts +2 -2
- package/dist/esm/curd/listview/list-store.js +2 -14
- package/dist/esm/curd/remove/RemovePanel.js +2 -5
- package/dist/esm/gomtmpb/mtm/sppb/curd-CurdService_connectquery.d.ts +42 -2
- package/dist/esm/gomtmpb/mtm/sppb/curd-CurdService_connectquery.js +46 -2
- package/dist/esm/gomtmpb/mtm/sppb/curd_connect.d.ts +26 -2
- package/dist/esm/gomtmpb/mtm/sppb/curd_connect.js +43 -2
- package/dist/esm/gomtmpb/mtm/sppb/curd_pb.d.ts +44 -0
- package/dist/esm/gomtmpb/mtm/sppb/curd_pb.js +106 -0
- package/dist/esm/gomtmpb/mtm/sppb/mtm-MtmService_connectquery.d.ts +1 -41
- package/dist/esm/gomtmpb/mtm/sppb/mtm-MtmService_connectquery.js +1 -45
- package/dist/esm/gomtmpb/mtm/sppb/mtm_connect.d.ts +1 -25
- package/dist/esm/gomtmpb/mtm/sppb/mtm_connect.js +1 -37
- package/dist/esm/gomtmpb/mtm/sppb/mtm_pb.d.ts +0 -42
- package/dist/esm/gomtmpb/mtm/sppb/mtm_pb.js +0 -94
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
function CurdViewEditor() {
|
|
4
|
+
return /* @__PURE__ */ jsx("div", { className: "bg-blue-100 p-2", children: /* @__PURE__ */ jsx("h1", { children: "TODO CurdViewEditor" }) });
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
CurdViewEditor as default
|
|
8
|
+
};
|
|
@@ -35,7 +35,7 @@ import { toPlainMessage } from "@bufbuild/protobuf";
|
|
|
35
35
|
import { Suspense, createContext, useContext, useRef } from "react";
|
|
36
36
|
import { createStore, useStore } from "zustand";
|
|
37
37
|
import { useSuspenseQuery } from "../connectquery";
|
|
38
|
-
import { curdViewGet } from "../gomtmpb/mtm/sppb/
|
|
38
|
+
import { curdViewGet } from "../gomtmpb/mtm/sppb/curd-CurdService_connectquery";
|
|
39
39
|
import { CurdView } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
40
40
|
import { CommonListView } from "./listview/CommonListView";
|
|
41
41
|
import { ListViewStoreProvider } from "./listview/list-store";
|
|
@@ -21,15 +21,15 @@ var __async = (__this, __arguments, generator) => {
|
|
|
21
21
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
22
22
|
import { Suspense } from "react";
|
|
23
23
|
import { PrefetchConnectInfiniteQuery, PrefetchConnectQuery } from "../components/SSR";
|
|
24
|
-
import { curdViewGet } from "../gomtmpb/mtm/sppb/
|
|
25
|
-
import {
|
|
24
|
+
import { curdViewGet } from "../gomtmpb/mtm/sppb/curd-CurdService_connectquery";
|
|
25
|
+
import { CurdService } from "../gomtmpb/mtm/sppb/curd_connect";
|
|
26
26
|
import { CurdViewGetReq } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
27
27
|
import { createMtmServiceClient } from "../mtmFetcher";
|
|
28
28
|
import { CurdViewView } from "./CurdView";
|
|
29
29
|
const CurdViewSS = (props) => __async(void 0, null, function* () {
|
|
30
30
|
var _a, _b;
|
|
31
31
|
const { name } = props;
|
|
32
|
-
const client = createMtmServiceClient(
|
|
32
|
+
const client = createMtmServiceClient(CurdService);
|
|
33
33
|
const curdViewRes = yield client.curdViewGet(new CurdViewGetReq({
|
|
34
34
|
name
|
|
35
35
|
}));
|
|
@@ -2,4 +2,5 @@ import { ComponentType } from "react";
|
|
|
2
2
|
export declare const RegisterEditorComponent: (name: string, Component: ComponentType<any>) => void;
|
|
3
3
|
export declare const RenderViewByName: (props: {
|
|
4
4
|
name: string;
|
|
5
|
+
warpper?: "fullScreen" | "none" | "form";
|
|
5
6
|
}) => import("react").JSX.Element;
|
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
2
21
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
22
|
+
import { EditFormToolbar } from "mtxuilib/form/EditFormToolbar";
|
|
23
|
+
import { Suspense, lazy, useMemo, useState } from "react";
|
|
24
|
+
import { FormProvider } from "react-hook-form";
|
|
25
|
+
import { useGomtmForm2 } from "./form/formStore";
|
|
4
26
|
const allEditorComponent = {};
|
|
5
27
|
const RegisterEditorComponent = (name, Component) => {
|
|
6
28
|
allEditorComponent[name] = Component;
|
|
7
29
|
};
|
|
8
30
|
const RenderViewByName = (props) => {
|
|
9
|
-
const { name } = props;
|
|
31
|
+
const { name, warpper } = props;
|
|
32
|
+
const [_warpper, setWrapper] = useState(warpper);
|
|
33
|
+
const form = useGomtmForm2();
|
|
10
34
|
const Comp = useMemo(() => {
|
|
11
35
|
const c = allEditorComponent[name || ""];
|
|
12
36
|
return c || null;
|
|
@@ -18,8 +42,27 @@ const RenderViewByName = (props) => {
|
|
|
18
42
|
"\u201D"
|
|
19
43
|
] });
|
|
20
44
|
}
|
|
21
|
-
|
|
45
|
+
if (!form.form) {
|
|
46
|
+
return /* @__PURE__ */ jsx("div", { children: "missing formObj2" });
|
|
47
|
+
}
|
|
48
|
+
switch (_warpper) {
|
|
49
|
+
case "none":
|
|
50
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading" }), children: /* @__PURE__ */ jsx(Comp, {}) });
|
|
51
|
+
default:
|
|
52
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading" }), children: /* @__PURE__ */ jsx(FormProvider, __spreadProps(__spreadValues({}, form.form), { children: /* @__PURE__ */ jsxs("form", { onSubmit: form.handleFormSubmit, children: [
|
|
53
|
+
/* @__PURE__ */ jsx("div", { className: " sticky top-0 z-30 p-1", children: /* @__PURE__ */ jsx(
|
|
54
|
+
EditFormToolbar,
|
|
55
|
+
{
|
|
56
|
+
onSubmit: form.handleValuesSubmit,
|
|
57
|
+
onCancel: form.handleCancel
|
|
58
|
+
}
|
|
59
|
+
) }),
|
|
60
|
+
/* @__PURE__ */ jsx(Comp, {})
|
|
61
|
+
] }) })) });
|
|
62
|
+
}
|
|
22
63
|
};
|
|
64
|
+
const LzCurdViewEditor = lazy(() => import("../components/curdView/curdViewEditor"));
|
|
65
|
+
RegisterEditorComponent("CurdViewEditor", LzCurdViewEditor);
|
|
23
66
|
export {
|
|
24
67
|
RegisterEditorComponent,
|
|
25
68
|
RenderViewByName
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMtRouter } from "mtxuilib/hooks/use-router";
|
|
4
|
+
import { MtPopupPanel } from "mtxuilib/ui/ui-mt/MtPopupPanel";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import { useGomtmSuspenseQuery } from "../../gomtmQuery";
|
|
7
|
+
import { RenderViewByName } from "../DynViews";
|
|
8
|
+
import { useListview } from "../listview/list-store";
|
|
9
|
+
import { useGomtmForm2 } from "./formStore";
|
|
10
|
+
function CurdEditPanel(props) {
|
|
11
|
+
const gomtmForm = useGomtmForm2();
|
|
12
|
+
const router = useMtRouter();
|
|
13
|
+
if (!gomtmForm.open) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (!gomtmForm.viewName) {
|
|
17
|
+
return /* @__PURE__ */ jsx("div", { children: "missing viewUpdate value" });
|
|
18
|
+
}
|
|
19
|
+
if (gomtmForm.viewName.startsWith("/")) {
|
|
20
|
+
router.push(gomtmForm.viewName);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!gomtmForm.viewName) {
|
|
24
|
+
return /* @__PURE__ */ jsx("div", { children: "missing viewName" });
|
|
25
|
+
}
|
|
26
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
27
|
+
MtPopupPanel,
|
|
28
|
+
{
|
|
29
|
+
open: gomtmForm.open,
|
|
30
|
+
onOpenChange: gomtmForm.setOpen,
|
|
31
|
+
fullScreen: gomtmForm.fullScreen,
|
|
32
|
+
title: gomtmForm.title,
|
|
33
|
+
children: /* @__PURE__ */ jsx(RenderViewByName, { name: gomtmForm.viewName })
|
|
34
|
+
}
|
|
35
|
+
) });
|
|
36
|
+
}
|
|
37
|
+
const WithLoadGetData = (props) => {
|
|
38
|
+
const { children } = props;
|
|
39
|
+
const methodGet = useListview((x) => x.methodGet);
|
|
40
|
+
const svc = useListview((x) => x.svc);
|
|
41
|
+
const activateItem = useListview((x) => x.activateItem);
|
|
42
|
+
const setDetailData = useListview((x) => x.setDetailData);
|
|
43
|
+
const detailQuery = useGomtmSuspenseQuery(svc, methodGet, {
|
|
44
|
+
id: parseInt(activateItem.id)
|
|
45
|
+
});
|
|
46
|
+
useMemo(() => {
|
|
47
|
+
setDetailData(detailQuery.data);
|
|
48
|
+
}, [detailQuery.data, setDetailData]);
|
|
49
|
+
if (detailQuery.isLoading) {
|
|
50
|
+
return /* @__PURE__ */ jsx("div", { children: "loading detail" });
|
|
51
|
+
}
|
|
52
|
+
return children;
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
CurdEditPanel as default
|
|
56
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { EditFormToolbar } from "mtxuilib/form/EditFormToolbar";
|
|
23
|
+
import { MtForm } from "mtxuilib/ui/ui-mt/MtForm";
|
|
24
|
+
import { useGomtmForm, useGomtmForm2 } from "./formStore";
|
|
25
|
+
const GomtmForm = (props) => {
|
|
26
|
+
const { children } = props;
|
|
27
|
+
const handleSubmit = useGomtmForm((x) => x.handleSubmit);
|
|
28
|
+
const handleCancel = useGomtmForm((x) => x.handleCancel);
|
|
29
|
+
const gomtmForm = useGomtmForm2();
|
|
30
|
+
if (!gomtmForm.form) {
|
|
31
|
+
return /* @__PURE__ */ jsx("div", { children: "missing form object" });
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsx(MtForm, __spreadProps(__spreadValues({}, gomtmForm.form), { children: /* @__PURE__ */ jsxs("form", { onSubmit: gomtmForm.form.handleSubmit(handleSubmit), children: [
|
|
34
|
+
/* @__PURE__ */ jsx("div", { className: " sticky top-0 z-30 p-1", children: /* @__PURE__ */ jsx(
|
|
35
|
+
EditFormToolbar,
|
|
36
|
+
{
|
|
37
|
+
onSubmit: handleSubmit,
|
|
38
|
+
onCancel: handleCancel
|
|
39
|
+
}
|
|
40
|
+
) }),
|
|
41
|
+
children
|
|
42
|
+
] }) }));
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
GomtmForm
|
|
46
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
interface GomtmFormProps {
|
|
3
|
+
svc: string;
|
|
4
|
+
method?: string;
|
|
5
|
+
open?: boolean;
|
|
6
|
+
fullScreen?: boolean;
|
|
7
|
+
viewName: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
onOpenChange?: (open: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const GomtmForm: (props: PropsWithChildren<GomtmFormProps>) => import("react").JSX.Element;
|
|
12
|
+
export declare function useGomtmForm2(): {
|
|
13
|
+
form: import("react-hook-form").UseFormReturn<import("react-hook-form").FieldValues, any, undefined>;
|
|
14
|
+
open: boolean | undefined;
|
|
15
|
+
setOpen: (open: boolean) => void;
|
|
16
|
+
fullScreen: boolean | undefined;
|
|
17
|
+
viewName: string;
|
|
18
|
+
title: string | undefined;
|
|
19
|
+
handleFormSubmit: () => void;
|
|
20
|
+
handleValuesSubmit: (values: any) => Promise<void>;
|
|
21
|
+
handleCancel: () => void;
|
|
22
|
+
setFullScreen: (open: boolean) => void;
|
|
23
|
+
setTitle: (title: string) => void;
|
|
24
|
+
svc: string;
|
|
25
|
+
method?: string | undefined;
|
|
26
|
+
onOpenChange?: ((open: boolean) => void) | undefined;
|
|
27
|
+
};
|
|
28
|
+
export declare function GomtmFormDebug(): import("react").JSX.Element | null;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
var __async = (__this, __arguments, generator) => {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
var fulfilled = (value) => {
|
|
36
|
+
try {
|
|
37
|
+
step(generator.next(value));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
reject(e);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var rejected = (value) => {
|
|
43
|
+
try {
|
|
44
|
+
step(generator.throw(value));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
reject(e);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
50
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
54
|
+
import { createContext, useCallback, useContext, useMemo, useRef } from "react";
|
|
55
|
+
import { useForm } from "react-hook-form";
|
|
56
|
+
import { useStore } from "zustand";
|
|
57
|
+
import { createStore } from "zustand/vanilla";
|
|
58
|
+
import { useGomtmMutation } from "../../gomtmQuery";
|
|
59
|
+
import { useGomtm } from "../../store/mtapp-store";
|
|
60
|
+
const createGomtmFormStore = (initProps) => {
|
|
61
|
+
const DEFAULT_PROPS = {
|
|
62
|
+
open: false,
|
|
63
|
+
viewName: "",
|
|
64
|
+
svc: ""
|
|
65
|
+
};
|
|
66
|
+
return createStore()((set, get) => __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_PROPS), initProps), {
|
|
67
|
+
setOpen: (open) => set({ open }),
|
|
68
|
+
setFullScreen: (fullScreen) => set({ fullScreen }),
|
|
69
|
+
setTitle: (title) => set({ title })
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
72
|
+
const gomtmFormContext = createContext(null);
|
|
73
|
+
const GomtmFormProvider = (props) => {
|
|
74
|
+
const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
|
|
75
|
+
const storeRef = useRef();
|
|
76
|
+
if (!storeRef.current) {
|
|
77
|
+
storeRef.current = createGomtmFormStore(props);
|
|
78
|
+
}
|
|
79
|
+
useMemo(() => {
|
|
80
|
+
var _a2;
|
|
81
|
+
(_a2 = storeRef.current) == null ? void 0 : _a2.setState({ open: props.open });
|
|
82
|
+
}, [props.open]);
|
|
83
|
+
useMemo(() => {
|
|
84
|
+
var _a2;
|
|
85
|
+
(_a2 = storeRef.current) == null ? void 0 : _a2.setState({ viewName: props.viewName });
|
|
86
|
+
}, [props.viewName]);
|
|
87
|
+
return /* @__PURE__ */ jsxs(gomtmFormContext.Provider, { value: storeRef.current, children: [
|
|
88
|
+
children,
|
|
89
|
+
/* @__PURE__ */ jsx(GomtmFormDebug, {})
|
|
90
|
+
] });
|
|
91
|
+
};
|
|
92
|
+
function useGomtmForm(selector) {
|
|
93
|
+
const store = useContext(gomtmFormContext);
|
|
94
|
+
if (!store)
|
|
95
|
+
throw new Error("useGomtmForm Missing GomtmFormProvider in the tree");
|
|
96
|
+
const formStore = useStore(store, selector);
|
|
97
|
+
return formStore;
|
|
98
|
+
}
|
|
99
|
+
const GomtmForm = (props) => {
|
|
100
|
+
const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
|
|
101
|
+
return /* @__PURE__ */ jsx(GomtmFormProvider, __spreadProps(__spreadValues({}, etc), { children }));
|
|
102
|
+
};
|
|
103
|
+
function useGomtmForm2() {
|
|
104
|
+
const storeForm = useGomtmForm();
|
|
105
|
+
const _setOpen = useGomtmForm((x) => x.setOpen);
|
|
106
|
+
const fullScreen = useGomtmForm((x) => x.fullScreen);
|
|
107
|
+
const viewName = useGomtmForm((x) => x.viewName);
|
|
108
|
+
const title = useGomtmForm((x) => x.title);
|
|
109
|
+
const _onOpenChange = useGomtmForm((x) => x.onOpenChange);
|
|
110
|
+
const method = useGomtmForm((x) => x.method);
|
|
111
|
+
const svc = useGomtmForm((x) => x.svc);
|
|
112
|
+
const mutation = useGomtmMutation(svc, method);
|
|
113
|
+
const form = useForm();
|
|
114
|
+
const setOpen = useCallback((open) => {
|
|
115
|
+
_setOpen(open);
|
|
116
|
+
}, [_setOpen]);
|
|
117
|
+
const handleValuesSubmit = useCallback((values) => __async(this, null, function* () {
|
|
118
|
+
const result = yield mutation.mutateAsync(values);
|
|
119
|
+
setOpen(false);
|
|
120
|
+
}), [setOpen, mutation]);
|
|
121
|
+
const handleFormSubmit = useCallback(() => {
|
|
122
|
+
form.handleSubmit(handleValuesSubmit);
|
|
123
|
+
}, [form, handleValuesSubmit]);
|
|
124
|
+
const handleCancel = useCallback(() => {
|
|
125
|
+
_setOpen(false);
|
|
126
|
+
if (_onOpenChange) {
|
|
127
|
+
_onOpenChange(false);
|
|
128
|
+
}
|
|
129
|
+
}, [_onOpenChange, _setOpen]);
|
|
130
|
+
return __spreadProps(__spreadValues({}, storeForm), {
|
|
131
|
+
form,
|
|
132
|
+
open: storeForm.open,
|
|
133
|
+
setOpen,
|
|
134
|
+
fullScreen,
|
|
135
|
+
viewName,
|
|
136
|
+
title,
|
|
137
|
+
handleFormSubmit,
|
|
138
|
+
handleValuesSubmit,
|
|
139
|
+
handleCancel
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function GomtmFormDebug() {
|
|
143
|
+
const viewName = useGomtmForm((x) => x.viewName);
|
|
144
|
+
const open = useGomtmForm((x) => x.open);
|
|
145
|
+
const gomtmForm = useGomtmForm2();
|
|
146
|
+
const debug = useGomtm((x) => x.debug);
|
|
147
|
+
if (!debug) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-blue-100 p-2", children: [
|
|
151
|
+
/* @__PURE__ */ jsx("h1", { children: "GomtmFormDebug" }),
|
|
152
|
+
/* @__PURE__ */ jsx("pre", { children: JSON.stringify({ viewName, open, open2: gomtmForm.open }, null, 2) })
|
|
153
|
+
] });
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
GomtmForm,
|
|
157
|
+
GomtmFormDebug,
|
|
158
|
+
useGomtmForm2
|
|
159
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FieldValues } from "react-hook-form";
|
|
2
|
+
export declare function useCurdUpdateForm<TFieldValues extends FieldValues = FieldValues>(): {
|
|
3
|
+
form: import("react-hook-form").UseFormReturn<TFieldValues, any, undefined>;
|
|
4
|
+
handleSubmit: (values: any) => void;
|
|
5
|
+
detailData: any;
|
|
6
|
+
setOpenEdit: (openEdit: boolean) => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useForm } from "react-hook-form";
|
|
3
|
+
import { useCurdUpdateMutation, useListview } from "../listview/list-store";
|
|
4
|
+
function useCurdUpdateForm() {
|
|
5
|
+
const detailData = useListview((x) => x.detailData);
|
|
6
|
+
const setOpenEdit = useListview((x) => x.setOpenEdit);
|
|
7
|
+
const mutationUpdate = useCurdUpdateMutation();
|
|
8
|
+
const form = useForm(
|
|
9
|
+
{
|
|
10
|
+
defaultValues: detailData
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
const handleSubmit = (values) => {
|
|
14
|
+
mutationUpdate.mutateAsync(values);
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
form,
|
|
18
|
+
handleSubmit,
|
|
19
|
+
detailData,
|
|
20
|
+
setOpenEdit
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
useCurdUpdateForm
|
|
25
|
+
};
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useMtRouter } from "mtxuilib/hooks/use-router";
|
|
4
3
|
import { Icons } from "mtxuilib/icons/icons";
|
|
5
4
|
import { cn } from "mtxuilib/lib/utils";
|
|
6
5
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
7
6
|
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
|
|
8
7
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
9
|
-
import { Suspense, lazy,
|
|
8
|
+
import { Suspense, lazy, useState } from "react";
|
|
10
9
|
import { MtmErrorView } from "../../components/MtmErrorView";
|
|
11
10
|
import { useGomtmSuspenseInfiniteQuery } from "../../gomtmQuery";
|
|
12
|
-
import CurdEditPanel from "../
|
|
11
|
+
import CurdEditPanel from "../form/CurdEditPanel";
|
|
12
|
+
import { GomtmForm } from "../form/formStore";
|
|
13
13
|
import { CommontListResView } from "../list-item/ListViewLayoutRender";
|
|
14
14
|
import { PanelRemove } from "../remove/RemovePanel";
|
|
15
15
|
import { useListview } from "./list-store";
|
|
16
|
-
import { GomtmFormProvider } from "../edit/formStore";
|
|
17
16
|
const ALL_Layouts = [
|
|
18
17
|
"default",
|
|
19
18
|
"demo"
|
|
@@ -30,25 +29,10 @@ function CommonListView() {
|
|
|
30
29
|
const setOpenCreate = useListview((x) => x.setOpenCreate);
|
|
31
30
|
const viewUpdate = useListview((x) => x.viewUpdate);
|
|
32
31
|
const viewCreate = useListview((x) => x.viewCreate);
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
if (openEdit) {
|
|
39
|
-
setOpenEdit(false);
|
|
40
|
-
}
|
|
41
|
-
}, [openCreate, openEdit, setOpenCreate, setOpenEdit]);
|
|
42
|
-
const router = useMtRouter();
|
|
43
|
-
const viewName = useMemo(() => {
|
|
44
|
-
if (openCreate) {
|
|
45
|
-
return viewCreate;
|
|
46
|
-
}
|
|
47
|
-
if (openEdit) {
|
|
48
|
-
return viewUpdate;
|
|
49
|
-
}
|
|
50
|
-
return "";
|
|
51
|
-
}, [openCreate, openEdit, viewCreate, viewUpdate]);
|
|
32
|
+
const methodUpdate = useListview((x) => x.methodUpdate);
|
|
33
|
+
const methodCreate = useListview((x) => x.methodCreate);
|
|
34
|
+
const openCurdViewEditor = useListview((x) => x.openCurdViewEditor);
|
|
35
|
+
const setOpenCurdViewEditor = useListview((x) => x.setOpenCurdViewEditor);
|
|
52
36
|
const listQuery = useGomtmSuspenseInfiniteQuery(svc, methodList, paramList);
|
|
53
37
|
if (!(listQuery == null ? void 0 : listQuery.data)) {
|
|
54
38
|
return null;
|
|
@@ -80,33 +64,66 @@ function CommonListView() {
|
|
|
80
64
|
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationNext, { href: "#" }) })
|
|
81
65
|
] }) }),
|
|
82
66
|
/* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1", children: /* @__PURE__ */ jsx(ListViewActions, {}) }),
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
67
|
+
/* @__PURE__ */ jsxs(Suspense, { children: [
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
GomtmForm,
|
|
70
|
+
{
|
|
71
|
+
open: openEdit,
|
|
72
|
+
fullScreen: true,
|
|
73
|
+
viewName: viewUpdate,
|
|
74
|
+
onOpenChange: setOpenEdit,
|
|
75
|
+
svc,
|
|
76
|
+
method: methodUpdate,
|
|
77
|
+
children: /* @__PURE__ */ jsx(CurdEditPanel, {})
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
GomtmForm,
|
|
82
|
+
{
|
|
83
|
+
open: openCreate,
|
|
84
|
+
fullScreen: true,
|
|
85
|
+
viewName: viewCreate,
|
|
86
|
+
onOpenChange: setOpenCreate,
|
|
87
|
+
svc,
|
|
88
|
+
method: methodCreate,
|
|
89
|
+
children: /* @__PURE__ */ jsx(CurdEditPanel, {})
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ jsx(PanelRemove, {}),
|
|
93
|
+
openCurdViewEditor && /* @__PURE__ */ jsx(
|
|
94
|
+
GomtmForm,
|
|
95
|
+
{
|
|
96
|
+
open: openCurdViewEditor,
|
|
97
|
+
fullScreen: true,
|
|
98
|
+
viewName: "CurdViewEditor",
|
|
99
|
+
onOpenChange: setOpenCurdViewEditor,
|
|
100
|
+
svc: "sppb.CurdService",
|
|
101
|
+
method: methodCreate,
|
|
102
|
+
children: /* @__PURE__ */ jsx(CurdEditPanel, {})
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] })
|
|
95
106
|
] });
|
|
96
107
|
}
|
|
97
108
|
const ListViewActions = () => {
|
|
98
109
|
const [open, setOpen] = useState(false);
|
|
99
110
|
const setOpenCreate = useListview((x) => x.setOpenCreate);
|
|
100
|
-
|
|
111
|
+
const setOpenCurdViewEditor = useListview((x) => x.setOpenCurdViewEditor);
|
|
101
112
|
return /* @__PURE__ */ jsxs(DropdownMenu, { open, onOpenChange: setOpen, children: [
|
|
102
113
|
/* @__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, {}) }) }),
|
|
103
114
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56", children: [
|
|
104
115
|
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: "List \u64CD\u4F5C" }),
|
|
105
116
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
117
|
+
/* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
|
|
118
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => {
|
|
119
|
+
setOpenCreate(true);
|
|
120
|
+
setOpen(false);
|
|
121
|
+
}, children: "create" }),
|
|
122
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => {
|
|
123
|
+
setOpenCurdViewEditor(true);
|
|
124
|
+
setOpen(false);
|
|
125
|
+
}, children: "editView" })
|
|
126
|
+
] }),
|
|
110
127
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {})
|
|
111
128
|
] })
|
|
112
129
|
] });
|
|
@@ -20,6 +20,7 @@ interface ListViewStateProps {
|
|
|
20
20
|
viewUpdate: string;
|
|
21
21
|
viewCreate: string;
|
|
22
22
|
curdView?: PlainMessage<CurdView>;
|
|
23
|
+
openCurdViewEditor?: boolean;
|
|
23
24
|
}
|
|
24
25
|
export interface ListViewState extends ListViewStateProps {
|
|
25
26
|
openRemove: boolean;
|
|
@@ -32,11 +33,10 @@ export interface ListViewState extends ListViewStateProps {
|
|
|
32
33
|
setActivateItem: (activateItem: any) => void;
|
|
33
34
|
nextPage: () => void;
|
|
34
35
|
setDetailData: (detailData: any) => void;
|
|
36
|
+
setOpenCurdViewEditor: (openCurdViewEditor: boolean) => void;
|
|
35
37
|
}
|
|
36
38
|
export declare const listViewContext: import("react").Context<import("zustand").StoreApi<ListViewState> | null>;
|
|
37
39
|
export declare const ListViewStoreProvider: (props: PropsWithChildren<ListViewStateProps>) => import("react").JSX.Element;
|
|
38
40
|
export declare const ListView: (props: Omit<ComponentProps<typeof ListViewStoreProvider>, 'backendUrl'> & PropsWithChildren) => import("react").JSX.Element;
|
|
39
41
|
export declare function useListview<T>(selector: (state: ListViewState) => T): T;
|
|
40
|
-
export declare const useCurdUpdateMutation: () => import("@tanstack/react-query").UseMutationResult<unknown, any, any, any>;
|
|
41
|
-
export declare const useCurdCreateMutation: () => import("@tanstack/react-query").UseMutationResult<unknown, any, any, any>;
|
|
42
42
|
export {};
|
|
@@ -36,7 +36,6 @@ import { createContext, useContext, useRef } from "react";
|
|
|
36
36
|
import { useStore } from "zustand";
|
|
37
37
|
import { createStore } from "zustand/vanilla";
|
|
38
38
|
import { CONST_cookieListViewLayout } from "../../consts";
|
|
39
|
-
import { useGomtmMutation } from "../../gomtmQuery";
|
|
40
39
|
import { useGomtm } from "../../store/mtapp-store";
|
|
41
40
|
const createListviewStore = (initProps) => {
|
|
42
41
|
const DEFAULT_PROPS = {
|
|
@@ -64,7 +63,8 @@ const createListviewStore = (initProps) => {
|
|
|
64
63
|
},
|
|
65
64
|
nextPage: () => {
|
|
66
65
|
},
|
|
67
|
-
setDetailData: (detailData) => set({ detailData })
|
|
66
|
+
setDetailData: (detailData) => set({ detailData }),
|
|
67
|
+
setOpenCurdViewEditor: (openCurdViewEditor) => set({ openCurdViewEditor })
|
|
68
68
|
}));
|
|
69
69
|
};
|
|
70
70
|
const listViewContext = createContext(null);
|
|
@@ -87,21 +87,9 @@ function useListview(selector) {
|
|
|
87
87
|
throw new Error("useListview Missing ListViewProvider in the tree");
|
|
88
88
|
return useStore(store, selector);
|
|
89
89
|
}
|
|
90
|
-
const useCurdUpdateMutation = () => {
|
|
91
|
-
const svc = useListview((x) => x.svc);
|
|
92
|
-
const methodUpdate = useListview((x) => x.methodUpdate);
|
|
93
|
-
return useGomtmMutation(svc, methodUpdate);
|
|
94
|
-
};
|
|
95
|
-
const useCurdCreateMutation = () => {
|
|
96
|
-
const svc = useListview((x) => x.svc);
|
|
97
|
-
const methodCreate = useListview((x) => x.methodCreate);
|
|
98
|
-
return useGomtmMutation(svc, methodCreate);
|
|
99
|
-
};
|
|
100
90
|
export {
|
|
101
91
|
ListView,
|
|
102
92
|
ListViewStoreProvider,
|
|
103
93
|
listViewContext,
|
|
104
|
-
useCurdCreateMutation,
|
|
105
|
-
useCurdUpdateMutation,
|
|
106
94
|
useListview
|
|
107
95
|
};
|