gomtm 0.0.318 → 0.0.320

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.
@@ -1,3 +1,5 @@
1
1
  /// <reference types="react" />
2
- export default function CurdEditPanel(): import("react").JSX.Element;
2
+ export default function CurdEditPanel(props: {
3
+ fullScreen?: boolean;
4
+ }): import("react").JSX.Element | null;
3
5
  export declare const CurdEditPanelTriggerButton: () => import("react").JSX.Element;
@@ -1,16 +1,31 @@
1
1
  "use client";
2
- import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { flexRender } from "mtxuilib/lib/render";
3
4
  import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
4
5
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
6
+ import { FullScreenPanel } from "mtxuilib/ui/ui-mt/FullScreenEditPanel";
5
7
  import { useListview } from "../listview/list-store";
6
- function CurdEditPanel() {
8
+ function CurdEditPanel(props) {
9
+ const { fullScreen } = props;
7
10
  const setOpenEdit = useListview((x) => x.setOpenEdit);
8
11
  const openEdit = useListview((x) => x.openEdit);
9
- return /* @__PURE__ */ jsx(Dialog, { open: openEdit, onOpenChange: setOpenEdit, children: /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogTitle, { children: " Edit " }) }) });
12
+ const editRender = useListview((x) => x.editRender);
13
+ if (!openEdit) {
14
+ return null;
15
+ }
16
+ if (fullScreen) {
17
+ return /* @__PURE__ */ jsx(FullScreenPanel, { children: openEdit && editRender && flexRender(editRender, {}) });
18
+ }
19
+ return /* @__PURE__ */ jsx(Dialog, { open: openEdit, onOpenChange: setOpenEdit, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
20
+ /* @__PURE__ */ jsx(DialogTitle, { children: " Edit " }),
21
+ openEdit && editRender && flexRender(editRender, {}),
22
+ /* @__PURE__ */ jsx(MtButton, { onClick: () => {
23
+ console.log("editRender", editRender);
24
+ }, children: "xxxxx" })
25
+ ] }) });
10
26
  }
11
27
  const CurdEditPanelTriggerButton = () => {
12
28
  const setOpenEdit = useListview((x) => x.setOpenEdit);
13
- const openEdit = useListview((x) => x.openEdit);
14
29
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtButton, { onClick: () => {
15
30
  setOpenEdit(true);
16
31
  }, children: "Edit" }) });
@@ -5,7 +5,7 @@ import { cn } from "mtxuilib/lib/utils";
5
5
  import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "mtxuilib/ui/card";
6
6
  import { Icons } from "mtxuilib/icons/icons";
7
7
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
8
- import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
8
+ import { useState } from "react";
9
9
  import { useListview } from "../listview/list-store";
10
10
  const PostCardListItem = (props) => {
11
11
  const { item } = props;
@@ -57,7 +57,9 @@ const PostCardItemActions = (props) => {
57
57
  const setOpenCreate = useListview((x) => x.setOpenCreate);
58
58
  const setOpenRemove = useListview((x) => x.setOpenRemove);
59
59
  const slugPath = useListview((x) => x.slugPath);
60
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
60
+ const [open, setOpen] = useState(false);
61
+ const setOpenEdit = useListview((x) => x.setOpenEdit);
62
+ return /* @__PURE__ */ jsxs(DropdownMenu, { open, onOpenChange: setOpen, children: [
61
63
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
62
64
  MtLink,
63
65
  {
@@ -74,18 +76,32 @@ const PostCardItemActions = (props) => {
74
76
  /* @__PURE__ */ jsx(
75
77
  DropdownMenuItem,
76
78
  {
77
- onClick: () => {
79
+ onClick: (e) => {
80
+ e.preventDefault();
78
81
  setOpenCreate(true);
82
+ setOpen(false);
79
83
  },
80
84
  children: "create"
81
85
  }
82
86
  ),
83
- /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${slugPath}/edit/${id}`, children: "edit" }),
84
87
  /* @__PURE__ */ jsx(
85
88
  DropdownMenuItem,
86
89
  {
87
- onClick: () => {
90
+ onClick: (e) => {
91
+ e.preventDefault();
92
+ setOpenEdit(true);
93
+ setOpen(false);
94
+ },
95
+ children: "edit"
96
+ }
97
+ ),
98
+ /* @__PURE__ */ jsx(
99
+ DropdownMenuItem,
100
+ {
101
+ onClick: (e) => {
102
+ e.preventDefault();
88
103
  setOpenRemove(true);
104
+ setOpen(false);
89
105
  },
90
106
  children: "remove"
91
107
  }
@@ -0,0 +1,2 @@
1
+ import { PropsWithChildren } from "react";
2
+ export declare const ListViewSetupEditView: (props: PropsWithChildren) => null;
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { useMemo } from "react";
3
+ import { useListview } from "./list-store";
4
+ const ListViewSetupEditView = (props) => {
5
+ const { children } = props;
6
+ const setEditRender = useListview((x) => x.setEditRender);
7
+ const openEdit = useListview((x) => x.openEdit);
8
+ useMemo(() => {
9
+ setEditRender(children);
10
+ }, [children, setEditRender, openEdit]);
11
+ return null;
12
+ };
13
+ export {
14
+ ListViewSetupEditView
15
+ };
@@ -1,75 +1,23 @@
1
1
  "use client";
2
- var __async = (__this, __arguments, generator) => {
3
- return new Promise((resolve, reject) => {
4
- var fulfilled = (value) => {
5
- try {
6
- step(generator.next(value));
7
- } catch (e) {
8
- reject(e);
9
- }
10
- };
11
- var rejected = (value) => {
12
- try {
13
- step(generator.throw(value));
14
- } catch (e) {
15
- reject(e);
16
- }
17
- };
18
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
19
- step((generator = generator.apply(__this, __arguments)).next());
20
- });
21
- };
22
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
23
3
  import { CommonListView } from "./ListViewProvider";
24
- import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
25
- import { MtButton } from "mtxuilib/ui/ui-mt/Button";
26
4
  import { Suspense } from "react";
27
- import { useGomtmMutation } from "../../gomtmQuery";
28
- import { useListview } from "./list-store";
29
5
  import CurdCreatePanel from "../create/CurdCreatePanel";
30
6
  import CurdEditPanel from "../edit/CurdEditPanel";
7
+ import { PanelRemove } from "../remove/RemovePanel";
31
8
  const ListViewRender = (props) => {
32
9
  const { children } = props;
33
10
  return /* @__PURE__ */ jsxs(Fragment, { children: [
34
11
  /* @__PURE__ */ jsx(CommonListView, {}),
35
12
  /* @__PURE__ */ jsxs(Suspense, { children: [
36
- "\u5F39\u6846\u7F16\u8F91",
37
- /* @__PURE__ */ jsx(PanelCreate, {}),
38
13
  /* @__PURE__ */ jsx(PanelRemove, {}),
39
14
  /* @__PURE__ */ jsx(CurdCreatePanel, {}),
40
- /* @__PURE__ */ jsx(CurdEditPanel, {})
41
- ] })
15
+ /* @__PURE__ */ jsx(CurdEditPanel, { fullScreen: true }),
16
+ /* @__PURE__ */ jsx(PanelRemove, {})
17
+ ] }),
18
+ children
42
19
  ] });
43
20
  };
44
- const PanelRemove = () => {
45
- const svc = useListview((x) => x.svc);
46
- const openRemove = useListview((x) => x.openRemove);
47
- const setOpenRemove = useListview((x) => x.setOpenRemove);
48
- const methodDelete = useListview((x) => x.methodDelete);
49
- const mutation = useGomtmMutation(svc, methodDelete);
50
- const activateItem = useListview((x) => x.activateItem);
51
- return /* @__PURE__ */ jsx(Dialog, { open: openRemove, onOpenChange: setOpenRemove, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
52
- /* @__PURE__ */ jsx(DialogTitle, { children: "remove item" }),
53
- /* @__PURE__ */ jsx(MtButton, { onClick: () => __async(void 0, null, function* () {
54
- yield mutation.mutateAsync({
55
- id: activateItem == null ? void 0 : activateItem.id
56
- });
57
- setOpenRemove(false);
58
- }), children: "ok" })
59
- ] }) });
60
- };
61
- const PanelCreate = () => {
62
- const svc = useListview((x) => x.svc);
63
- const openCreate = useListview((x) => x.openCreate);
64
- const setOpenCreate = useListview((x) => x.setOpenCreate);
65
- const methodDelete = useListview((x) => x.methodDelete);
66
- return /* @__PURE__ */ jsx(Dialog, { open: openCreate, onOpenChange: setOpenCreate, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
67
- /* @__PURE__ */ jsx(DialogTitle, { children: "TODO create item Dlg" }),
68
- /* @__PURE__ */ jsx(MtButton, { onClick: () => __async(void 0, null, function* () {
69
- setOpenCreate(false);
70
- }), children: "ok" })
71
- ] }) });
72
- };
73
21
  export {
74
22
  ListViewRender
75
23
  };
@@ -1,3 +1,4 @@
1
+ import { Renderable } from 'mtxuilib/lib/render';
1
2
  import { ComponentProps, PropsWithChildren } from 'react';
2
3
  interface ListViewStateProps {
3
4
  backendUrl?: string;
@@ -14,6 +15,7 @@ interface ListViewStateProps {
14
15
  layout?: string;
15
16
  data?: any;
16
17
  error?: any;
18
+ editRender?: Renderable<any>;
17
19
  }
18
20
  export interface ListViewState extends ListViewStateProps {
19
21
  openRemove: boolean;
@@ -26,6 +28,7 @@ export interface ListViewState extends ListViewStateProps {
26
28
  setActivateItem: (activateItem: any) => void;
27
29
  loadListData: () => Promise<any>;
28
30
  nextPage: () => void;
31
+ setEditRender: (a: Renderable<any>) => void;
29
32
  }
30
33
  export declare const listViewContext: import("react").Context<import("zustand").StoreApi<ListViewState> | null>;
31
34
  type BearProviderProps = React.PropsWithChildren<ListViewStateProps>;
@@ -95,7 +95,8 @@ const createListviewStore = (initProps) => {
95
95
  return data;
96
96
  }),
97
97
  nextPage: () => {
98
- }
98
+ },
99
+ setEditRender: (editRender) => set({ editRender })
99
100
  }));
100
101
  };
101
102
  const listViewContext = createContext(null);
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const PanelRemove: () => import("react").JSX.Element;
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ var __async = (__this, __arguments, generator) => {
3
+ return new Promise((resolve, reject) => {
4
+ var fulfilled = (value) => {
5
+ try {
6
+ step(generator.next(value));
7
+ } catch (e) {
8
+ reject(e);
9
+ }
10
+ };
11
+ var rejected = (value) => {
12
+ try {
13
+ step(generator.throw(value));
14
+ } catch (e) {
15
+ reject(e);
16
+ }
17
+ };
18
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
19
+ step((generator = generator.apply(__this, __arguments)).next());
20
+ });
21
+ };
22
+ import { jsx, jsxs } from "react/jsx-runtime";
23
+ import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
24
+ import { MtButton } from "mtxuilib/ui/ui-mt/Button";
25
+ import { useGomtmMutation } from "../../gomtmQuery";
26
+ import { useListview } from "../listview/list-store";
27
+ const PanelRemove = () => {
28
+ const svc = useListview((x) => x.svc);
29
+ const openRemove = useListview((x) => x.openRemove);
30
+ const setOpenRemove = useListview((x) => x.setOpenRemove);
31
+ const methodDelete = useListview((x) => x.methodDelete);
32
+ const mutation = useGomtmMutation(svc, methodDelete);
33
+ const activateItem = useListview((x) => x.activateItem);
34
+ return /* @__PURE__ */ jsx(Dialog, { open: openRemove, onOpenChange: setOpenRemove, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
35
+ /* @__PURE__ */ jsx(DialogTitle, { children: "remove item" }),
36
+ /* @__PURE__ */ jsx(MtButton, { onClick: () => __async(void 0, null, function* () {
37
+ yield mutation.mutateAsync({
38
+ id: activateItem == null ? void 0 : activateItem.id
39
+ });
40
+ setOpenRemove(false);
41
+ }), children: "ok" })
42
+ ] }) });
43
+ };
44
+ export {
45
+ PanelRemove
46
+ };