gomtm 0.0.365 → 0.0.367

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,3 +2,4 @@
2
2
  export default function CurdViewEditor(props: {
3
3
  name: string;
4
4
  }): import("react").JSX.Element;
5
+ export declare const CurdViewContentField: () => import("react").JSX.Element;
@@ -19,9 +19,9 @@ var __spreadValues = (a, b) => {
19
19
  };
20
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
21
  import { jsx, jsxs } from "react/jsx-runtime";
22
- import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "mtxuilib/ui/form";
22
+ import { FormControl, FormField, FormItem, FormLabel, FormMessage } from "mtxuilib/ui/form";
23
23
  import { Input } from "mtxuilib/ui/input";
24
- import { useFormContext } from "react-hook-form";
24
+ import { useForm, useFormContext } from "react-hook-form";
25
25
  import { FormShell } from "../../curd/form/FormShell";
26
26
  function CurdViewEditor(props) {
27
27
  const form = useFormContext();
@@ -34,7 +34,6 @@ function CurdViewEditor(props) {
34
34
  render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
35
35
  /* @__PURE__ */ jsx(FormLabel, { children: "name" }),
36
36
  /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Input, __spreadProps(__spreadValues({ placeholder: "name" }, field), { readOnly: true, disabled: true })) }),
37
- /* @__PURE__ */ jsx(FormDescription, { children: "name" }),
38
37
  /* @__PURE__ */ jsx(FormMessage, {})
39
38
  ] })
40
39
  }
@@ -47,13 +46,46 @@ function CurdViewEditor(props) {
47
46
  render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
48
47
  /* @__PURE__ */ jsx(FormLabel, { children: "Svc" }),
49
48
  /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Input, __spreadValues({ placeholder: "svcName" }, field)) }),
50
- /* @__PURE__ */ jsx(FormDescription, { children: "svcName" }),
51
49
  /* @__PURE__ */ jsx(FormMessage, {})
52
50
  ] })
53
51
  }
54
- )
52
+ ),
53
+ /* @__PURE__ */ jsx(FormField, { control: form.control, name: "title", render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
54
+ /* @__PURE__ */ jsx(FormLabel, { children: "title" }),
55
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Input, __spreadValues({ placeholder: "title" }, field)) }),
56
+ /* @__PURE__ */ jsx(FormMessage, {})
57
+ ] }) }),
58
+ /* @__PURE__ */ jsx(FormField, { control: form.control, name: "methodList", render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
59
+ /* @__PURE__ */ jsx(FormLabel, { children: "methodList" }),
60
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Input, __spreadValues({ placeholder: "methodList" }, field)) }),
61
+ /* @__PURE__ */ jsx(FormMessage, {})
62
+ ] }) }),
63
+ /* @__PURE__ */ jsx(FormField, { control: form.control, name: "methodGet", render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
64
+ /* @__PURE__ */ jsx(FormLabel, { children: "methodGet" }),
65
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Input, __spreadValues({ placeholder: "methodGet" }, field)) }),
66
+ /* @__PURE__ */ jsx(FormMessage, {})
67
+ ] }) }),
68
+ /* @__PURE__ */ jsx(FormField, { control: form.control, name: "methodUpdate", render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
69
+ /* @__PURE__ */ jsx(FormLabel, { children: "methodUpdate" }),
70
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Input, __spreadValues({ placeholder: "methodUpdate" }, field)) }),
71
+ /* @__PURE__ */ jsx(FormMessage, {})
72
+ ] }) }),
73
+ /* @__PURE__ */ jsx(CurdViewContentField, {})
55
74
  ] });
56
75
  }
76
+ const CurdViewContentField = () => {
77
+ const form = useFormContext();
78
+ const contentForm = useForm();
79
+ return /* @__PURE__ */ jsxs("div", { children: [
80
+ "CurdViewContentField",
81
+ /* @__PURE__ */ jsx(FormField, { control: contentForm.control, name: "someField", render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
82
+ /* @__PURE__ */ jsx(FormLabel, { children: "someField" }),
83
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Input, __spreadValues({ placeholder: "someField" }, field)) }),
84
+ /* @__PURE__ */ jsx(FormMessage, {})
85
+ ] }) })
86
+ ] });
87
+ };
57
88
  export {
89
+ CurdViewContentField,
58
90
  CurdViewEditor as default
59
91
  };
@@ -1,17 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { PlainMessage } from "@bufbuild/protobuf";
3
- import { CurdView } from "../gomtmpb/mtm/sppb/mtm_pb";
4
- interface CurdViewProps {
5
- backendUrl?: string;
6
- curdView: PlainMessage<CurdView>;
7
- }
8
- export interface ListViewState extends CurdViewProps {
9
- }
10
- export declare const curdViewContext: import("react").Context<import("zustand").StoreApi<ListViewState> | null>;
11
- type CurdViewProviderProps = React.PropsWithChildren<CurdViewProps>;
12
- export declare const CurdViewProvider: (props: CurdViewProviderProps) => import("react").JSX.Element;
13
- export declare function useCurdView<T>(selector: (state: ListViewState) => T): T;
14
2
  export declare const CurdViewView: (props: {
15
3
  name: string;
16
4
  }) => import("react").JSX.Element | null;
17
- export {};
@@ -1,70 +1,10 @@
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));
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
2
  import { jsx, jsxs } from "react/jsx-runtime";
34
- import { toPlainMessage } from "@bufbuild/protobuf";
35
- import { Suspense, createContext, useContext, useRef } from "react";
36
- import { createStore, useStore } from "zustand";
3
+ import { Suspense } from "react";
37
4
  import { useSuspenseQuery } from "../connectquery";
38
5
  import { curdViewGet } from "../gomtmpb/mtm/sppb/curd-CurdService_connectquery";
39
- import { CurdView } from "../gomtmpb/mtm/sppb/mtm_pb";
40
6
  import { CommonListView } from "./listview/CommonListView";
41
7
  import { ListViewStoreProvider } from "./listview/list-store";
42
- const createListviewStore = (initProps) => {
43
- const DEFAULT_PROPS = {
44
- backendUrl: "",
45
- curdView: toPlainMessage(new CurdView())
46
- };
47
- return createStore()((set, get) => __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_PROPS), initProps), {
48
- openRemove: false,
49
- nextPage: () => {
50
- }
51
- }));
52
- };
53
- const curdViewContext = createContext(null);
54
- const CurdViewProvider = (props) => {
55
- const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
56
- const storeRef = useRef();
57
- if (!storeRef.current) {
58
- storeRef.current = createListviewStore(props);
59
- }
60
- return /* @__PURE__ */ jsx(curdViewContext.Provider, { value: storeRef.current, children });
61
- };
62
- function useCurdView(selector) {
63
- const store = useContext(curdViewContext);
64
- if (!store)
65
- throw new Error("useCurd Missing CurdViewProvider in the tree");
66
- return useStore(store, selector);
67
- }
68
8
  const CurdViewView = (props) => {
69
9
  const { name } = props;
70
10
  const query = useSuspenseQuery(curdViewGet, { name });
@@ -81,27 +21,9 @@ const CurdViewView = (props) => {
81
21
  if (!query.data.item.value) {
82
22
  return /* @__PURE__ */ jsx("div", { children: "missing curd data222" });
83
23
  }
84
- const curdViewData = query.data.item.value;
85
- return /* @__PURE__ */ jsx(CurdViewProvider, { curdView: curdViewData, children: /* @__PURE__ */ jsx(
86
- ListViewStoreProvider,
87
- {
88
- slugPath: "/post",
89
- svc: curdViewData.svcName,
90
- methodList: curdViewData.methodList,
91
- methodGet: curdViewData.methodGet,
92
- methodCreate: curdViewData.methodCreate,
93
- methodUpdate: curdViewData.methodUpdate,
94
- methodDelete: curdViewData.methodDelete,
95
- viewUpdate: curdViewData.routeEdit,
96
- viewCreate: curdViewData.routeCreate,
97
- children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading CommonListView" }), children: /* @__PURE__ */ jsx(CommonListView, {}) })
98
- }
99
- ) });
24
+ return /* @__PURE__ */ jsx(ListViewStoreProvider, { curdView: query.data.item.value, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading CommonListView" }), children: /* @__PURE__ */ jsx(CommonListView, {}) }) });
100
25
  }
101
26
  };
102
27
  export {
103
- CurdViewProvider,
104
- CurdViewView,
105
- curdViewContext,
106
- useCurdView
28
+ CurdViewView
107
29
  };
@@ -36,8 +36,8 @@ function CurdEditPanel(props) {
36
36
  }
37
37
  const WithLoadGetData = (props) => {
38
38
  const { children } = props;
39
- const methodGet = useListview((x) => x.methodGet);
40
- const svc = useListview((x) => x.svc);
39
+ const methodGet = useListview((x) => x.curdView.methodGet);
40
+ const svc = useListview((x) => x.curdView.svcName);
41
41
  const activateItem = useListview((x) => x.activateItem);
42
42
  const setDetailData = useListview((x) => x.setDetailData);
43
43
  const detailQuery = useGomtmSuspenseQuery(svc, methodGet, {
@@ -2,7 +2,7 @@
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  const FormShell = (props) => {
4
4
  const { children } = props;
5
- return /* @__PURE__ */ jsx("div", { children });
5
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4 space-y-4", children });
6
6
  };
7
7
  export {
8
8
  FormShell
@@ -3,6 +3,7 @@ interface GomtmFormProps {
3
3
  svc: string;
4
4
  method?: string;
5
5
  open?: boolean;
6
+ defaultValues?: any;
6
7
  fullScreen?: boolean;
7
8
  viewName: string;
8
9
  title?: string;
@@ -10,7 +11,7 @@ interface GomtmFormProps {
10
11
  }
11
12
  export declare const GomtmForm: (props: PropsWithChildren<GomtmFormProps>) => import("react").JSX.Element;
12
13
  export declare function useGomtmForm2(): {
13
- form: import("react-hook-form").UseFormReturn<import("react-hook-form").FieldValues, any, undefined>;
14
+ form: import("react-hook-form").UseFormReturn<any, any, undefined>;
14
15
  open: boolean | undefined;
15
16
  setOpen: (open: boolean) => void;
16
17
  fullScreen: boolean | undefined;
@@ -23,6 +24,7 @@ export declare function useGomtmForm2(): {
23
24
  setTitle: (title: string) => void;
24
25
  svc: string;
25
26
  method?: string | undefined;
27
+ defaultValues?: any;
26
28
  onOpenChange?: ((open: boolean) => void) | undefined;
27
29
  };
28
30
  export declare function GomtmFormDebug(): import("react").JSX.Element | null;
@@ -111,27 +111,28 @@ function useGomtmForm2() {
111
111
  const method = useGomtmForm((x) => x.method);
112
112
  const svc = useGomtmForm((x) => x.svc);
113
113
  const mutation = useGomtmMutation(svc, method);
114
- const form = useForm();
114
+ const defaultValues = useGomtmForm((x) => x.defaultValues);
115
+ const form = useForm({
116
+ defaultValues
117
+ });
115
118
  const setOpen = useCallback((open) => {
116
119
  _setOpen(open);
117
120
  }, [_setOpen]);
118
121
  const handleValuesSubmit = useCallback((values) => __async(this, null, function* () {
119
122
  try {
120
- const result = yield mutation.mutateAsync(values);
121
- console.log("result", result, "errCode", result.errCode);
122
- const a = result;
123
- if (a.errCode) {
124
- toast("Error:" + a.errCode, {
125
- description: a.errMessage.substring(0, 100),
123
+ const m = mutation;
124
+ const result = yield m.mutateAsync({
125
+ input: values
126
+ });
127
+ if (result.errCode) {
128
+ console.log({ result, values });
129
+ toast("Error:" + result.errCode, {
130
+ description: result.errMessage.substring(0, 100),
126
131
  closeButton: true
127
132
  });
128
133
  } else {
129
134
  toast("OK", {
130
135
  description: "ok",
131
- // action: {
132
- // label: "close",
133
- // onClick: () => console.log("close"),
134
- // },
135
136
  closeButton: true
136
137
  });
137
138
  }
@@ -20,19 +20,20 @@ const ALL_Layouts = [
20
20
  const LzListViewLayoutDemo = lazy(() => import("./listview-layouts/listviewlayout-demo"));
21
21
  const LzListViewLayoutDefault = lazy(() => import("./listview-layouts/default"));
22
22
  function CommonListView() {
23
- const svc = useListview((x) => x.svc);
24
- const methodList = useListview((x) => x.methodList);
23
+ const svc = useListview((x) => x.curdView.svcName);
24
+ const methodList = useListview((x) => x.curdView.methodList);
25
25
  const paramList = useListview((x) => x.paramsList);
26
26
  const setOpenEdit = useListview((x) => x.setOpenEdit);
27
27
  const openEdit = useListview((x) => x.openEdit);
28
28
  const openCreate = useListview((x) => x.openCreate);
29
29
  const setOpenCreate = useListview((x) => x.setOpenCreate);
30
- const viewUpdate = useListview((x) => x.viewUpdate);
31
- const viewCreate = useListview((x) => x.viewCreate);
32
- const methodUpdate = useListview((x) => x.methodUpdate);
33
- const methodCreate = useListview((x) => x.methodCreate);
30
+ const viewUpdate = useListview((x) => x.curdView.routeEdit);
31
+ const viewCreate = useListview((x) => x.curdView.routeCreate);
32
+ const methodUpdate = useListview((x) => x.curdView.methodUpdate);
33
+ const methodCreate = useListview((x) => x.curdView.methodCreate);
34
34
  const openCurdViewEditor = useListview((x) => x.openCurdViewEditor);
35
35
  const setOpenCurdViewEditor = useListview((x) => x.setOpenCurdViewEditor);
36
+ const curdView = useListview((x) => x.curdView);
36
37
  const listQuery = useGomtmSuspenseInfiniteQuery(svc, methodList, paramList);
37
38
  if (!(listQuery == null ? void 0 : listQuery.data)) {
38
39
  return null;
@@ -93,6 +94,7 @@ function CommonListView() {
93
94
  openCurdViewEditor && /* @__PURE__ */ jsx(
94
95
  GomtmForm,
95
96
  {
97
+ defaultValues: curdView,
96
98
  open: openCurdViewEditor,
97
99
  fullScreen: true,
98
100
  viewName: "CurdViewEditor",
@@ -3,12 +3,7 @@ import { ComponentProps, PropsWithChildren } from 'react';
3
3
  import { CurdView } from '../../gomtmpb/mtm/sppb/mtm_pb';
4
4
  interface ListViewStateProps {
5
5
  backendUrl?: string;
6
- svc: string;
7
- methodList: string;
8
- methodGet?: string;
9
- methodUpdate?: string;
10
- methodCreate?: string;
11
- methodDelete?: string;
6
+ curdView: PlainMessage<CurdView>;
12
7
  paramsGet?: any;
13
8
  paramsList?: any;
14
9
  slugPath?: string;
@@ -17,9 +12,6 @@ interface ListViewStateProps {
17
12
  layout?: string;
18
13
  data?: any;
19
14
  error?: any;
20
- viewUpdate: string;
21
- viewCreate: string;
22
- curdView?: PlainMessage<CurdView>;
23
15
  openCurdViewEditor?: boolean;
24
16
  }
25
17
  export interface ListViewState extends ListViewStateProps {
@@ -36,20 +36,15 @@ 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 { CurdView } from "../../gomtmpb/mtm/sppb/mtm_pb";
39
40
  import { useGomtm } from "../../store/mtapp-store";
40
41
  const createListviewStore = (initProps) => {
41
- const DEFAULT_PROPS = {
42
- svc: initProps.svc || "",
43
- methodList: initProps.methodList || "",
44
- methodUpdate: "",
45
- methodGet: "",
46
- methodDelete: "",
47
- methodCreate: "",
42
+ return createStore()((set, get) => __spreadProps(__spreadValues({
43
+ curdView: new CurdView(),
48
44
  backendUrl: "",
49
45
  viewUpdate: "",
50
46
  viewCreate: ""
51
- };
52
- return createStore()((set, get) => __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_PROPS), initProps), {
47
+ }, initProps), {
53
48
  openRemove: false,
54
49
  setOpenRemove: (openRemove) => set({ openRemove }),
55
50
  openCreate: false,
@@ -28,11 +28,11 @@ import { useGomtmMutation } from "../../gomtmQuery";
28
28
  import { createQueryKey } from "../../mtmFetcher";
29
29
  import { useListview } from "../listview/list-store";
30
30
  function useCurdRemove() {
31
- const svc = useListview((x) => x.svc);
31
+ const svc = useListview((x) => x.curdView.svcName);
32
32
  const openRemove = useListview((x) => x.openRemove);
33
33
  const setOpenRemove = useListview((x) => x.setOpenRemove);
34
- const methodDelete = useListview((x) => x.methodDelete);
35
- const methodList = useListview((x) => x.methodList);
34
+ const methodDelete = useListview((x) => x.curdView.methodDelete);
35
+ const methodList = useListview((x) => x.curdView.methodList);
36
36
  const mutation = useGomtmMutation(svc, methodDelete, {
37
37
  onSuccess(data, variables, context) {
38
38
  queryClient.invalidateQueries({