gomtm 0.0.350 → 0.0.352

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.
@@ -37,11 +37,8 @@ import { createStore, useStore } from "zustand";
37
37
  import { useSuspenseQuery } from "../connectquery";
38
38
  import { curdViewGet } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
39
39
  import { CurdView } from "../gomtmpb/mtm/sppb/mtm_pb";
40
- import CurdCreatePanel from "./create/CurdCreatePanel";
41
- import CurdEditPanel from "./edit/CurdEditPanel";
42
40
  import { CommonListView } from "./listview/CommonListView";
43
41
  import { ListViewStoreProvider } from "./listview/list-store";
44
- import { PanelRemove } from "./remove/RemovePanel";
45
42
  const createListviewStore = (initProps) => {
46
43
  const DEFAULT_PROPS = {
47
44
  backendUrl: "",
@@ -85,7 +82,7 @@ const CurdViewView = (props) => {
85
82
  return /* @__PURE__ */ jsx("div", { children: "missing curd data222" });
86
83
  }
87
84
  const curdViewData = query.data.item.value;
88
- return /* @__PURE__ */ jsx(CurdViewProvider, { curdView: curdViewData, children: /* @__PURE__ */ jsxs(
85
+ return /* @__PURE__ */ jsx(CurdViewProvider, { curdView: curdViewData, children: /* @__PURE__ */ jsx(
89
86
  ListViewStoreProvider,
90
87
  {
91
88
  slugPath: "/post",
@@ -97,14 +94,7 @@ const CurdViewView = (props) => {
97
94
  methodDelete: curdViewData.methodDelete,
98
95
  viewUpdate: curdViewData.routeEdit,
99
96
  viewCreate: curdViewData.routeCreate,
100
- children: [
101
- /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading CommonListView" }), children: /* @__PURE__ */ jsx(CommonListView, {}) }),
102
- /* @__PURE__ */ jsxs(Suspense, { children: [
103
- /* @__PURE__ */ jsx(CurdCreatePanel, { fullScreen: true }),
104
- /* @__PURE__ */ jsx(CurdEditPanel, { fullScreen: true }),
105
- /* @__PURE__ */ jsx(PanelRemove, {})
106
- ] })
107
- ]
97
+ children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading CommonListView" }), children: /* @__PURE__ */ jsx(CommonListView, {}) })
108
98
  }
109
99
  ) });
110
100
  }
@@ -1,4 +1,2 @@
1
1
  /// <reference types="react" />
2
- export default function CurdEditPanel(props: {
3
- fullScreen?: boolean;
4
- }): import("react").JSX.Element | null | undefined;
2
+ export default function CurdEditPanel(props: {}): import("react").JSX.Element | null | undefined;
@@ -1,35 +1,42 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment, jsx } from "react/jsx-runtime";
3
3
  import { useMtRouter } from "mtxuilib/hooks/use-router";
4
- import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
5
- import { FullScreenPanel } from "mtxuilib/ui/ui-mt/FullScreenEditPanel";
4
+ import { MtPopupPanel } from "mtxuilib/ui/ui-mt/MtPopupPanel";
6
5
  import { useMemo } from "react";
7
6
  import { useGomtmSuspenseQuery } from "../../gomtmQuery";
8
7
  import { RenderViewByName } from "../DynViews";
8
+ import { useGomtmForm } from "../form-context";
9
9
  import { useListview } from "../listview/list-store";
10
10
  function CurdEditPanel(props) {
11
- const { fullScreen } = props;
12
- const setOpenEdit = useListview((x) => x.setOpenEdit);
13
- const openEdit = useListview((x) => x.openEdit);
14
- const viewUpdate = useListview((x) => x.viewUpdate);
11
+ const open = useGomtmForm((x) => x.open);
12
+ const setOpen = useGomtmForm((x) => x.setOpen);
13
+ const fullScreen = useGomtmForm((x) => x.fullScreen);
14
+ const viewName = useGomtmForm((x) => x.viewName);
15
+ const title = useGomtmForm((x) => x.title);
15
16
  const router = useMtRouter();
16
- if (!openEdit) {
17
+ if (!open) {
17
18
  return null;
18
19
  }
19
- if (!viewUpdate) {
20
+ if (!viewName) {
20
21
  return /* @__PURE__ */ jsx("div", { children: "missing viewUpdate value" });
21
22
  }
22
- if (viewUpdate.startsWith("/")) {
23
- router.push(viewUpdate);
23
+ if (viewName.startsWith("/")) {
24
+ router.push(viewName);
24
25
  return;
25
26
  }
26
- if (fullScreen) {
27
- return /* @__PURE__ */ jsx(WithLoadGetData, { children: /* @__PURE__ */ jsx(FullScreenPanel, { children: /* @__PURE__ */ jsx(RenderViewByName, { name: viewUpdate }) }) });
27
+ if (!viewName) {
28
+ return /* @__PURE__ */ jsx("div", { children: "missing viewName" });
28
29
  }
29
- return /* @__PURE__ */ jsx(Dialog, { open: openEdit, onOpenChange: setOpenEdit, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
30
- /* @__PURE__ */ jsx(DialogTitle, { children: " Edit " }),
31
- /* @__PURE__ */ jsx(RenderViewByName, { name: viewUpdate })
32
- ] }) });
30
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
31
+ MtPopupPanel,
32
+ {
33
+ open,
34
+ onOpenChange: setOpen,
35
+ fullScreen,
36
+ title,
37
+ children: /* @__PURE__ */ jsx(RenderViewByName, { name: viewName })
38
+ }
39
+ ) });
33
40
  }
34
41
  const WithLoadGetData = (props) => {
35
42
  const { children } = props;
@@ -0,0 +1,17 @@
1
+ import { PropsWithChildren } from 'react';
2
+ interface GomtmFormProps {
3
+ open?: boolean;
4
+ fullScreen?: boolean;
5
+ viewName: string;
6
+ title?: string;
7
+ }
8
+ export interface GomtmFormState extends GomtmFormProps {
9
+ setOpen: (open: boolean) => void;
10
+ setFullScreen: (open: boolean) => void;
11
+ setTitle: (title: string) => void;
12
+ }
13
+ export declare const gomtmFormContext: import("react").Context<import("zustand").StoreApi<GomtmFormState> | null>;
14
+ export declare const GomtmFormProvider: (props: PropsWithChildren<GomtmFormProps>) => import("react").JSX.Element;
15
+ export declare function useGomtmForm<T>(selector: (state: GomtmFormState) => T): T;
16
+ export declare function GomtmFormDebug(): import("react").JSX.Element;
17
+ export {};
@@ -0,0 +1,89 @@
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
+ import { jsx, jsxs } from "react/jsx-runtime";
34
+ import { MtButton } from "mtxuilib/ui/ui-mt/Button";
35
+ import { createContext, useContext, useMemo, useRef } from "react";
36
+ import { useStore } from "zustand";
37
+ import { createStore } from "zustand/vanilla";
38
+ const createGomtmFormStore = (initProps) => {
39
+ const DEFAULT_PROPS = {
40
+ open: false,
41
+ viewName: ""
42
+ };
43
+ return createStore()((set, get) => __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_PROPS), initProps), {
44
+ setOpen: (open) => set({ open }),
45
+ setFullScreen: (fullScreen) => set({ fullScreen }),
46
+ setTitle: (title) => set({ title })
47
+ }));
48
+ };
49
+ const gomtmFormContext = createContext(null);
50
+ const GomtmFormProvider = (props) => {
51
+ const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
52
+ const storeRef = useRef();
53
+ if (!storeRef.current) {
54
+ storeRef.current = createGomtmFormStore(props);
55
+ }
56
+ useMemo(() => {
57
+ var _a2;
58
+ (_a2 = storeRef.current) == null ? void 0 : _a2.setState({ open: props.open });
59
+ }, [props.open]);
60
+ useMemo(() => {
61
+ var _a2;
62
+ (_a2 = storeRef.current) == null ? void 0 : _a2.setState({ viewName: props.viewName });
63
+ }, [props.viewName]);
64
+ return /* @__PURE__ */ jsxs(gomtmFormContext.Provider, { value: storeRef.current, children: [
65
+ children,
66
+ /* @__PURE__ */ jsx(GomtmFormDebug, {})
67
+ ] });
68
+ };
69
+ function useGomtmForm(selector) {
70
+ const store = useContext(gomtmFormContext);
71
+ if (!store)
72
+ throw new Error("useGomtmForm Missing GomtmFormProvider in the tree");
73
+ return useStore(store, selector);
74
+ }
75
+ function GomtmFormDebug() {
76
+ const open = useGomtmForm((x) => x.open);
77
+ const viewName = useGomtmForm((x) => x.viewName);
78
+ return /* @__PURE__ */ jsxs("div", { children: [
79
+ /* @__PURE__ */ jsx(MtButton, { onClick: () => {
80
+ }, children: "forminfo" }),
81
+ /* @__PURE__ */ jsx("pre", { children: JSON.stringify({ open, viewName }, null, 2) })
82
+ ] });
83
+ }
84
+ export {
85
+ GomtmFormDebug,
86
+ GomtmFormProvider,
87
+ gomtmFormContext,
88
+ useGomtmForm
89
+ };
@@ -186,17 +186,6 @@ const PostCardItemActions = (props) => {
186
186
  }
187
187
  ) }),
188
188
  /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-[160px]", children: [
189
- /* @__PURE__ */ jsx(
190
- DropdownMenuItem,
191
- {
192
- onClick: (e) => {
193
- e.preventDefault();
194
- setOpenCreate(true);
195
- setOpen(false);
196
- },
197
- children: "create"
198
- }
199
- ),
200
189
  /* @__PURE__ */ jsx(
201
190
  DropdownMenuItem,
202
191
  {
@@ -1,14 +1,18 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useMtRouter } from "mtxuilib/hooks/use-router";
3
4
  import { Icons } from "mtxuilib/icons/icons";
4
5
  import { cn } from "mtxuilib/lib/utils";
5
6
  import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
6
7
  import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
7
8
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
8
- import { lazy, useState } from "react";
9
+ import { Suspense, lazy, useCallback, useMemo, useState } from "react";
9
10
  import { MtmErrorView } from "../../components/MtmErrorView";
10
11
  import { useGomtmSuspenseInfiniteQuery } from "../../gomtmQuery";
12
+ import CurdEditPanel from "../edit/CurdEditPanel";
13
+ import { GomtmFormProvider } from "../form-context";
11
14
  import { CommontListResView } from "../list-item/ListViewLayoutRender";
15
+ import { PanelRemove } from "../remove/RemovePanel";
12
16
  import { useListview } from "./list-store";
13
17
  const ALL_Layouts = [
14
18
  "default",
@@ -20,6 +24,31 @@ function CommonListView() {
20
24
  const svc = useListview((x) => x.svc);
21
25
  const methodList = useListview((x) => x.methodList);
22
26
  const paramList = useListview((x) => x.paramsList);
27
+ const setOpenEdit = useListview((x) => x.setOpenEdit);
28
+ const openEdit = useListview((x) => x.openEdit);
29
+ const openCreate = useListview((x) => x.openCreate);
30
+ const setOpenCreate = useListview((x) => x.setOpenCreate);
31
+ const viewUpdate = useListview((x) => x.viewUpdate);
32
+ const viewCreate = useListview((x) => x.viewCreate);
33
+ const open = openEdit || openCreate;
34
+ const setOpen = useCallback((open2) => {
35
+ if (openCreate) {
36
+ setOpenCreate(false);
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]);
23
52
  const listQuery = useGomtmSuspenseInfiniteQuery(svc, methodList, paramList);
24
53
  if (!(listQuery == null ? void 0 : listQuery.data)) {
25
54
  return null;
@@ -50,7 +79,27 @@ function CommonListView() {
50
79
  /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationEllipsis, {}) }),
51
80
  /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationNext, { href: "#" }) })
52
81
  ] }) }),
53
- /* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1", children: /* @__PURE__ */ jsx(ListViewActions, {}) })
82
+ /* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1", children: /* @__PURE__ */ jsx(ListViewActions, {}) }),
83
+ /* @__PURE__ */ jsxs(Suspense, { children: [
84
+ /* @__PURE__ */ jsx("pre", { children: JSON.stringify({
85
+ open,
86
+ viewName,
87
+ viewUpdate,
88
+ viewCreate
89
+ }, null, 2) }),
90
+ /* @__PURE__ */ jsxs(
91
+ GomtmFormProvider,
92
+ {
93
+ open,
94
+ fullScreen: true,
95
+ viewName,
96
+ children: [
97
+ /* @__PURE__ */ jsx(CurdEditPanel, {}),
98
+ /* @__PURE__ */ jsx(PanelRemove, {})
99
+ ]
100
+ }
101
+ )
102
+ ] })
54
103
  ] });
55
104
  }
56
105
  const ListViewActions = () => {
@@ -63,6 +112,7 @@ const ListViewActions = () => {
63
112
  /* @__PURE__ */ jsx(DropdownMenuLabel, { children: "List \u64CD\u4F5C" }),
64
113
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
65
114
  /* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => {
115
+ console.log("setOpenCreate");
66
116
  setOpenCreate(true);
67
117
  setOpen(false);
68
118
  }, children: "create" }) }),
@@ -2,7 +2,6 @@
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { CommonListView } from "./CommonListView";
4
4
  import { Suspense } from "react";
5
- import CurdCreatePanel from "../create/CurdCreatePanel";
6
5
  import CurdEditPanel from "../edit/CurdEditPanel";
7
6
  import { PanelRemove } from "../remove/RemovePanel";
8
7
  const ListViewRender = (props) => {
@@ -10,7 +9,6 @@ const ListViewRender = (props) => {
10
9
  return /* @__PURE__ */ jsxs(Fragment, { children: [
11
10
  /* @__PURE__ */ jsx(CommonListView, {}),
12
11
  /* @__PURE__ */ jsxs(Suspense, { children: [
13
- /* @__PURE__ */ jsx(CurdCreatePanel, { fullScreen: true }),
14
12
  /* @__PURE__ */ jsx(CurdEditPanel, { fullScreen: true }),
15
13
  /* @__PURE__ */ jsx(PanelRemove, {})
16
14
  ] }),
@@ -17,8 +17,8 @@ interface ListViewStateProps {
17
17
  layout?: string;
18
18
  data?: any;
19
19
  error?: any;
20
- viewUpdate?: string;
21
- viewCreate?: string;
20
+ viewUpdate: string;
21
+ viewCreate: string;
22
22
  curdView?: PlainMessage<CurdView>;
23
23
  }
24
24
  export interface ListViewState extends ListViewStateProps {
@@ -34,8 +34,7 @@ export interface ListViewState extends ListViewStateProps {
34
34
  setDetailData: (detailData: any) => void;
35
35
  }
36
36
  export declare const listViewContext: import("react").Context<import("zustand").StoreApi<ListViewState> | null>;
37
- type BearProviderProps = React.PropsWithChildren<ListViewStateProps>;
38
- export declare const ListViewStoreProvider: (props: BearProviderProps) => import("react").JSX.Element;
37
+ export declare const ListViewStoreProvider: (props: PropsWithChildren<ListViewStateProps>) => import("react").JSX.Element;
39
38
  export declare const ListView: (props: Omit<ComponentProps<typeof ListViewStoreProvider>, 'backendUrl'> & PropsWithChildren) => import("react").JSX.Element;
40
39
  export declare function useListview<T>(selector: (state: ListViewState) => T): T;
41
40
  export declare const useCurdUpdateMutation: () => import("@tanstack/react-query").UseMutationResult<unknown, any, any, any>;
@@ -46,7 +46,9 @@ const createListviewStore = (initProps) => {
46
46
  methodGet: "",
47
47
  methodDelete: "",
48
48
  methodCreate: "",
49
- backendUrl: ""
49
+ backendUrl: "",
50
+ viewUpdate: "",
51
+ viewCreate: ""
50
52
  };
51
53
  return createStore()((set, get) => __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_PROPS), initProps), {
52
54
  openRemove: false,
@@ -60,27 +62,9 @@ const createListviewStore = (initProps) => {
60
62
  setCookie(CONST_cookieListViewLayout, layout);
61
63
  return set((state) => ({ layout }));
62
64
  },
63
- // loadListData: async () => {
64
- // const baseUrl = get().backendUrl || ""
65
- // const apiUrl = (new URL(MTM_API_PREFIX, baseUrl)).toString()
66
- // console.log("loadListData, apiUrl:", apiUrl)
67
- // const data = await goMtmQueryFn({
68
- // svc: get().svc,
69
- // method: get().methodList,
70
- // input: get().paramsList,
71
- // options: {
72
- // url: apiUrl
73
- // }
74
- // })
75
- // set({ data })
76
- // return data
77
- // },
78
65
  nextPage: () => {
79
66
  },
80
- // setEditRender: (editRender) => set({ editRender }),
81
- // setCreateRender: (createRender) => set({ createRender }),
82
67
  setDetailData: (detailData) => set({ detailData })
83
- // setEeditorComponentName: (editorComponentName) => set({ editorComponentName }),
84
68
  }));
85
69
  };
86
70
  const listViewContext = createContext(null);
@@ -0,0 +1,5 @@
1
+ import { PropsWithChildren } from 'react';
2
+ export declare const GomtmForm: (props: {
3
+ methodGet: string;
4
+ methodSutmit: string;
5
+ } & PropsWithChildren) => import("react").JSX.Element;
@@ -0,0 +1,31 @@
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 } from "react/jsx-runtime";
22
+ import { Form } from "mtxuilib/ui/form";
23
+ import { useForm } from "react-hook-form";
24
+ const GomtmForm = (props) => {
25
+ const { children } = props;
26
+ const form = useForm();
27
+ return /* @__PURE__ */ jsx(Form, __spreadProps(__spreadValues({}, form), { children }));
28
+ };
29
+ export {
30
+ GomtmForm
31
+ };