gomtm 0.0.346 → 0.0.347

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.
@@ -23,7 +23,6 @@ export declare const ListView_DefaultPageSize = 12;
23
23
  export declare const ImageNoExist = "/images/404.jpg";
24
24
  export declare const ADMIN_ROLE = "admin";
25
25
  export declare const MEMBER_ROLE = "member";
26
- export declare const TRPC_API_PREFIX = "/api.v1/trpc";
27
26
  export declare const HOTKEY_Debug = "alt+j";
28
27
  export declare const HOTKEY_Switchlayout = "alt+l";
29
28
  export declare const HOTKEY_Listview_Switchlayout = "alt+m";
@@ -23,7 +23,6 @@ const ListView_DefaultPageSize = 12;
23
23
  const ImageNoExist = "/images/404.jpg";
24
24
  const ADMIN_ROLE = "admin";
25
25
  const MEMBER_ROLE = "member";
26
- const TRPC_API_PREFIX = "/api.v1/trpc";
27
26
  const HOTKEY_Debug = "alt+j";
28
27
  const HOTKEY_Switchlayout = "alt+l";
29
28
  const HOTKEY_Listview_Switchlayout = "alt+m";
@@ -66,7 +65,6 @@ export {
66
65
  MTM_SERVER_COOKIE_ACTIVATE_SELFBACKEND_URL,
67
66
  MTM_SERVER_COOKIE_ACTIVATE_URL,
68
67
  MTM_SITE_HOSTNAME,
69
- TRPC_API_PREFIX,
70
68
  cookieBackendUrl,
71
69
  fetchMaxRetry
72
70
  };
@@ -30,15 +30,18 @@ var __objRest = (source, exclude) => {
30
30
  }
31
31
  return target;
32
32
  };
33
- import { jsx } from "react/jsx-runtime";
33
+ import { jsx, jsxs } from "react/jsx-runtime";
34
34
  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
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";
40
42
  import { CommonListViewV2 } from "./listview/CommonListViewV2";
41
43
  import { ListViewStoreProvider } from "./listview/list-store";
44
+ import { PanelRemove } from "./remove/RemovePanel";
42
45
  const createListviewStore = (initProps) => {
43
46
  const DEFAULT_PROPS = {
44
47
  backendUrl: "",
@@ -79,13 +82,26 @@ const CurdViewView = (props) => {
79
82
  return /* @__PURE__ */ jsx("div", { children: "missing curd data222" });
80
83
  }
81
84
  const curdViewData = query.data.item.value;
82
- return /* @__PURE__ */ jsx("div", { className: "bg-red-100 p-2", children: /* @__PURE__ */ jsx(CurdViewProvider, { curdView: curdViewData, children: /* @__PURE__ */ jsx(
85
+ return /* @__PURE__ */ jsx("div", { className: "bg-red-100 p-2", children: /* @__PURE__ */ jsx(CurdViewProvider, { curdView: curdViewData, children: /* @__PURE__ */ jsxs(
83
86
  ListViewStoreProvider,
84
87
  {
85
88
  slugPath: "/post",
86
89
  svc: curdViewData.svcName,
87
90
  methodList: curdViewData.methodList,
88
- children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading CommonListViewV2" }), children: /* @__PURE__ */ jsx(CommonListViewV2, {}) })
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: [
98
+ /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading CommonListViewV2" }), children: /* @__PURE__ */ jsx(CommonListViewV2, {}) }),
99
+ /* @__PURE__ */ jsxs(Suspense, { children: [
100
+ /* @__PURE__ */ jsx(CurdCreatePanel, { fullScreen: true }),
101
+ /* @__PURE__ */ jsx(CurdEditPanel, { fullScreen: true }),
102
+ /* @__PURE__ */ jsx(PanelRemove, {})
103
+ ] })
104
+ ]
89
105
  }
90
106
  ) }) });
91
107
  }
@@ -0,0 +1,5 @@
1
+ import { ComponentType } from "react";
2
+ export declare const RegisterEditorComponent: (name: string, Component: ComponentType<any>) => void;
3
+ export declare const RenderViewByName: (props: {
4
+ name: string;
5
+ }) => import("react").JSX.Element;
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Suspense, useMemo } from "react";
4
+ const allEditorComponent = {};
5
+ const RegisterEditorComponent = (name, Component) => {
6
+ allEditorComponent[name] = Component;
7
+ };
8
+ const RenderViewByName = (props) => {
9
+ const { name } = props;
10
+ const Comp = useMemo(() => {
11
+ const c = allEditorComponent[name || ""];
12
+ return c || null;
13
+ }, [name]);
14
+ if (!Comp) {
15
+ return /* @__PURE__ */ jsxs("div", { children: [
16
+ "missing dyn component \u201C",
17
+ name,
18
+ "\u201D"
19
+ ] });
20
+ }
21
+ return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "loading" }), children: /* @__PURE__ */ jsx(Comp, {}) });
22
+ };
23
+ export {
24
+ RegisterEditorComponent,
25
+ RenderViewByName
26
+ };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  export default function CurdCreatePanel(props: {
3
3
  fullScreen?: boolean;
4
- }): import("react").JSX.Element | null;
4
+ }): import("react").JSX.Element | null | undefined;
5
5
  export declare const CurdCreatePanelTriggerButton: () => import("react").JSX.Element;
@@ -1,24 +1,33 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { flexRender } from "mtxuilib/lib/render";
3
+ import { useMtRouter } from "mtxuilib/hooks/use-router";
4
4
  import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
5
5
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
6
6
  import { FullScreenPanel } from "mtxuilib/ui/ui-mt/FullScreenEditPanel";
7
+ import { RenderViewByName } from "../DynViews";
7
8
  import { useListview } from "../listview/list-store";
8
9
  function CurdCreatePanel(props) {
9
10
  const { fullScreen } = props;
10
11
  const setOpenCreate = useListview((x) => x.setOpenCreate);
11
12
  const openCreate = useListview((x) => x.openCreate);
12
- const createRender = useListview((x) => x.createRender);
13
+ const viewCreate = useListview((x) => x.viewCreate);
14
+ const router = useMtRouter();
13
15
  if (!openCreate) {
14
16
  return null;
15
17
  }
18
+ if (!viewCreate) {
19
+ return /* @__PURE__ */ jsx("div", { children: "missing viewCreate value" });
20
+ }
21
+ if (viewCreate.startsWith("/")) {
22
+ router.push(viewCreate);
23
+ return;
24
+ }
16
25
  if (fullScreen) {
17
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(FullScreenPanel, { children: openCreate && createRender && flexRender(createRender, {}) }) });
26
+ return /* @__PURE__ */ jsx(FullScreenPanel, { children: /* @__PURE__ */ jsx(RenderViewByName, { name: viewCreate }) });
18
27
  }
19
28
  return /* @__PURE__ */ jsx(Dialog, { open: openCreate, onOpenChange: setOpenCreate, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
20
29
  /* @__PURE__ */ jsx(DialogTitle, { children: " create " }),
21
- openCreate && createRender && flexRender(createRender, {})
30
+ /* @__PURE__ */ jsx(RenderViewByName, { name: viewCreate })
22
31
  ] }) });
23
32
  }
24
33
  const CurdCreatePanelTriggerButton = () => {
@@ -1,6 +1,4 @@
1
- import { ComponentType } from "react";
1
+ /// <reference types="react" />
2
2
  export default function CurdEditPanel(props: {
3
3
  fullScreen?: boolean;
4
- }): import("react").JSX.Element | null;
5
- export declare const RenderEditorComponent: () => import("react").JSX.Element;
6
- export declare const RegisterEditorComponent: (name: string, Component: ComponentType<any>) => void;
4
+ }): import("react").JSX.Element | null | undefined;
@@ -1,25 +1,34 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { flexRender } from "mtxuilib/lib/render";
3
+ import { useMtRouter } from "mtxuilib/hooks/use-router";
4
4
  import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
5
5
  import { FullScreenPanel } from "mtxuilib/ui/ui-mt/FullScreenEditPanel";
6
6
  import { useMemo } from "react";
7
7
  import { useGomtmSuspenseQuery } from "../../gomtmQuery";
8
+ import { RenderViewByName } from "../DynViews";
8
9
  import { useListview } from "../listview/list-store";
9
10
  function CurdEditPanel(props) {
10
11
  const { fullScreen } = props;
11
12
  const setOpenEdit = useListview((x) => x.setOpenEdit);
12
13
  const openEdit = useListview((x) => x.openEdit);
13
- const editRender = useListview((x) => x.editRender);
14
+ const viewUpdate = useListview((x) => x.viewUpdate);
15
+ const router = useMtRouter();
14
16
  if (!openEdit) {
15
17
  return null;
16
18
  }
19
+ if (!viewUpdate) {
20
+ return /* @__PURE__ */ jsx("div", { children: "missing viewUpdate value" });
21
+ }
22
+ if (viewUpdate.startsWith("/")) {
23
+ router.push(viewUpdate);
24
+ return;
25
+ }
17
26
  if (fullScreen) {
18
- return /* @__PURE__ */ jsx(WithLoadGetData, { children: /* @__PURE__ */ jsx(FullScreenPanel, { children: openEdit && editRender && flexRender(editRender, {}) }) });
27
+ return /* @__PURE__ */ jsx(WithLoadGetData, { children: /* @__PURE__ */ jsx(FullScreenPanel, { children: /* @__PURE__ */ jsx(RenderViewByName, { name: viewUpdate }) }) });
19
28
  }
20
29
  return /* @__PURE__ */ jsx(Dialog, { open: openEdit, onOpenChange: setOpenEdit, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
21
30
  /* @__PURE__ */ jsx(DialogTitle, { children: " Edit " }),
22
- openEdit && editRender && flexRender(editRender, {})
31
+ /* @__PURE__ */ jsx(RenderViewByName, { name: viewUpdate })
23
32
  ] }) });
24
33
  }
25
34
  const WithLoadGetData = (props) => {
@@ -37,35 +46,8 @@ const WithLoadGetData = (props) => {
37
46
  if (detailQuery.isLoading) {
38
47
  return /* @__PURE__ */ jsx("div", { children: "loading detail" });
39
48
  }
40
- return /* @__PURE__ */ jsx("div", { className: "bg-red-200 p-2", children });
41
- };
42
- const RenderEditorComponent = () => {
43
- const editorComponentName = useListview((x) => x.editorComponentName);
44
- const editRender = useListview((x) => x.editRender);
45
- const Comp = useMemo(() => {
46
- const c = allEditorComponent[editorComponentName || ""];
47
- return c || null;
48
- }, [editorComponentName]);
49
- if (!editorComponentName) {
50
- return /* @__PURE__ */ jsx("div", { children: "missing editorComponentName" });
51
- }
52
- if (Comp) {
53
- return /* @__PURE__ */ jsx(Comp, {});
54
- }
55
- return /* @__PURE__ */ jsxs("div", { className: "bg-red-200 p-2", children: [
56
- "missing Component:",
57
- editorComponentName
58
- ] });
59
- };
60
- const allEditorComponent = {};
61
- const RegisterEditorComponent = (name, Component) => {
62
- allEditorComponent[name] = Component;
49
+ return children;
63
50
  };
64
- RegisterEditorComponent("hello_editor", () => {
65
- return /* @__PURE__ */ jsx("div", { children: "HelloEditorComponent" });
66
- });
67
51
  export {
68
- RegisterEditorComponent,
69
- RenderEditorComponent,
70
52
  CurdEditPanel as default
71
53
  };
@@ -1,6 +1,5 @@
1
- import { Renderable } from 'mtxuilib/lib/render';
2
- import { ComponentProps, PropsWithChildren } from 'react';
3
1
  import { PlainMessage } from '@bufbuild/protobuf';
2
+ import { ComponentProps, PropsWithChildren } from 'react';
4
3
  import { CurdView } from '../../gomtmpb/mtm/sppb/mtm_pb';
5
4
  interface ListViewStateProps {
6
5
  backendUrl?: string;
@@ -18,10 +17,8 @@ interface ListViewStateProps {
18
17
  layout?: string;
19
18
  data?: any;
20
19
  error?: any;
21
- editRender?: Renderable<any>;
22
- editorComponentName?: string;
23
- createRender?: Renderable<any>;
24
- createComponentName?: string;
20
+ viewUpdate?: string;
21
+ viewCreate?: string;
25
22
  curdView?: PlainMessage<CurdView>;
26
23
  }
27
24
  export interface ListViewState extends ListViewStateProps {
@@ -34,10 +31,7 @@ export interface ListViewState extends ListViewStateProps {
34
31
  setLayout: (layout: string) => void;
35
32
  setActivateItem: (activateItem: any) => void;
36
33
  nextPage: () => void;
37
- setEditRender: (a: Renderable<any>) => void;
38
- setCreateRender: (a: Renderable<any>) => void;
39
34
  setDetailData: (detailData: any) => void;
40
- setEeditorComponentName: (editorComponentName: string) => void;
41
35
  }
42
36
  export declare const listViewContext: import("react").Context<import("zustand").StoreApi<ListViewState> | null>;
43
37
  type BearProviderProps = React.PropsWithChildren<ListViewStateProps>;
@@ -77,10 +77,10 @@ const createListviewStore = (initProps) => {
77
77
  // },
78
78
  nextPage: () => {
79
79
  },
80
- setEditRender: (editRender) => set({ editRender }),
81
- setCreateRender: (createRender) => set({ createRender }),
82
- setDetailData: (detailData) => set({ detailData }),
83
- setEeditorComponentName: (editorComponentName) => set({ editorComponentName })
80
+ // setEditRender: (editRender) => set({ editRender }),
81
+ // setCreateRender: (createRender) => set({ createRender }),
82
+ setDetailData: (detailData) => set({ detailData })
83
+ // setEeditorComponentName: (editorComponentName) => set({ editorComponentName }),
84
84
  }));
85
85
  };
86
86
  const listViewContext = createContext(null);