gomtm 0.0.338 → 0.0.340
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/MtDate.js +1 -1
- package/dist/esm/curd/edit/CurdEditPanel.d.ts +3 -1
- package/dist/esm/curd/edit/CurdEditPanel.js +30 -6
- package/dist/esm/curd/edit/useCurdUpdateForm.d.ts +7 -0
- package/dist/esm/curd/edit/useCurdUpdateForm.js +25 -0
- package/dist/esm/curd/list-item/ListViewLayoutRender.js +0 -3
- package/dist/esm/curd/listview/ListViewComponentsSetup.js +2 -2
- package/dist/esm/curd/listview/MtListView.js +1 -1
- package/dist/esm/curd/listview/list-store.d.ts +3 -0
- package/dist/esm/curd/listview/list-store.js +10 -1
- package/dist/esm/gomtmQuery.js +0 -1
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -10,7 +10,7 @@ const MtDateView = (props) => {
|
|
|
10
10
|
date1.setFullYear(date.year);
|
|
11
11
|
date1.setMonth(date.month);
|
|
12
12
|
date1.setDate(date.day);
|
|
13
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("
|
|
13
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("span", { children: formatDate(date1.toString(), "en-US") }) });
|
|
14
14
|
};
|
|
15
15
|
export {
|
|
16
16
|
MtDateView
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { ComponentType } from "react";
|
|
2
2
|
export default function CurdEditPanel(props: {
|
|
3
3
|
fullScreen?: boolean;
|
|
4
4
|
}): import("react").JSX.Element | null;
|
|
5
5
|
export declare const CurdEditPanelTriggerButton: () => import("react").JSX.Element;
|
|
6
|
+
export declare const RenderEditorComponent: () => import("react").JSX.Element;
|
|
7
|
+
export declare const RegisterEditorComponent: (name: string, Component: ComponentType<any>) => void;
|
|
@@ -12,6 +12,7 @@ function CurdEditPanel(props) {
|
|
|
12
12
|
const setOpenEdit = useListview((x) => x.setOpenEdit);
|
|
13
13
|
const openEdit = useListview((x) => x.openEdit);
|
|
14
14
|
const editRender = useListview((x) => x.editRender);
|
|
15
|
+
const editorComponentName = useListview((x) => x.editorComponentName);
|
|
15
16
|
if (!openEdit) {
|
|
16
17
|
return null;
|
|
17
18
|
}
|
|
@@ -20,9 +21,8 @@ function CurdEditPanel(props) {
|
|
|
20
21
|
}
|
|
21
22
|
return /* @__PURE__ */ jsx(Dialog, { open: openEdit, onOpenChange: setOpenEdit, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
22
23
|
/* @__PURE__ */ jsx(DialogTitle, { children: " Edit " }),
|
|
23
|
-
|
|
24
|
+
/* @__PURE__ */ jsx(RenderEditorComponent, {}),
|
|
24
25
|
/* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
25
|
-
console.log("editRender", editRender);
|
|
26
26
|
}, children: "xxxxx" })
|
|
27
27
|
] }) });
|
|
28
28
|
}
|
|
@@ -41,10 +41,7 @@ const WithLoadGetData = (props) => {
|
|
|
41
41
|
if (detailQuery.isLoading) {
|
|
42
42
|
return /* @__PURE__ */ jsx("div", { children: "loading detail" });
|
|
43
43
|
}
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
"WithLoadGetData",
|
|
46
|
-
children
|
|
47
|
-
] });
|
|
44
|
+
return /* @__PURE__ */ jsx("div", { className: "bg-red-200 p-2", children });
|
|
48
45
|
};
|
|
49
46
|
const CurdEditPanelTriggerButton = () => {
|
|
50
47
|
const setOpenEdit = useListview((x) => x.setOpenEdit);
|
|
@@ -52,7 +49,34 @@ const CurdEditPanelTriggerButton = () => {
|
|
|
52
49
|
setOpenEdit(true);
|
|
53
50
|
}, children: "Edit" }) });
|
|
54
51
|
};
|
|
52
|
+
const RenderEditorComponent = () => {
|
|
53
|
+
const editorComponentName = useListview((x) => x.editorComponentName);
|
|
54
|
+
const editRender = useListview((x) => x.editRender);
|
|
55
|
+
const Comp = useMemo(() => {
|
|
56
|
+
const c = allEditorComponent[editorComponentName || ""];
|
|
57
|
+
return c || null;
|
|
58
|
+
}, [editorComponentName]);
|
|
59
|
+
if (!editorComponentName) {
|
|
60
|
+
return /* @__PURE__ */ jsx("div", { children: "missing editorComponentName" });
|
|
61
|
+
}
|
|
62
|
+
if (Comp) {
|
|
63
|
+
return /* @__PURE__ */ jsx(Comp, {});
|
|
64
|
+
}
|
|
65
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-red-200 p-2", children: [
|
|
66
|
+
"missing Component:",
|
|
67
|
+
editorComponentName
|
|
68
|
+
] });
|
|
69
|
+
};
|
|
70
|
+
const allEditorComponent = {};
|
|
71
|
+
const RegisterEditorComponent = (name, Component) => {
|
|
72
|
+
allEditorComponent[name] = Component;
|
|
73
|
+
};
|
|
74
|
+
RegisterEditorComponent("hello_editor", () => {
|
|
75
|
+
return /* @__PURE__ */ jsx("div", { children: "HelloEditorComponent" });
|
|
76
|
+
});
|
|
55
77
|
export {
|
|
56
78
|
CurdEditPanelTriggerButton,
|
|
79
|
+
RegisterEditorComponent,
|
|
80
|
+
RenderEditorComponent,
|
|
57
81
|
CurdEditPanel as default
|
|
58
82
|
};
|
|
@@ -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
|
+
};
|
|
@@ -6,7 +6,6 @@ import { cn } from "mtxuilib/lib/utils";
|
|
|
6
6
|
import { buttonVariants } from "mtxuilib/ui/button";
|
|
7
7
|
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "mtxuilib/ui/card";
|
|
8
8
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
9
|
-
import { title } from "process";
|
|
10
9
|
import { Suspense, useState } from "react";
|
|
11
10
|
import { MtDateView } from "../../components/MtDate";
|
|
12
11
|
import Tag from "../../components/Tag";
|
|
@@ -55,7 +54,6 @@ const CommonListItemView = (props) => {
|
|
|
55
54
|
return /* @__PURE__ */ jsxs(
|
|
56
55
|
"div",
|
|
57
56
|
{
|
|
58
|
-
"aria-label": item.id,
|
|
59
57
|
onClick: handleSelect,
|
|
60
58
|
className: cn(
|
|
61
59
|
buttonVariants({
|
|
@@ -117,7 +115,6 @@ const PostCardListItem = (props) => {
|
|
|
117
115
|
{
|
|
118
116
|
href: `/blog/${item.slug}`,
|
|
119
117
|
className: "text-primary-500 hover:text-primary-600 dark:hover:text-primary-400",
|
|
120
|
-
"aria-label": `Read more: "${title}"`,
|
|
121
118
|
children: "Read more \u2192"
|
|
122
119
|
}
|
|
123
120
|
) })
|
|
@@ -4,10 +4,10 @@ import { useListview } from "./list-store";
|
|
|
4
4
|
const ListViewSetupEditView = (props) => {
|
|
5
5
|
const { children } = props;
|
|
6
6
|
const setEditRender = useListview((x) => x.setEditRender);
|
|
7
|
-
const openEdit = useListview((x) => x.openEdit);
|
|
8
7
|
useMemo(() => {
|
|
8
|
+
console.log("setEditRender", children == null ? void 0 : children.toString());
|
|
9
9
|
setEditRender(children);
|
|
10
|
-
}, [children, setEditRender
|
|
10
|
+
}, [children, setEditRender]);
|
|
11
11
|
return null;
|
|
12
12
|
};
|
|
13
13
|
export {
|
|
@@ -17,6 +17,7 @@ interface ListViewStateProps {
|
|
|
17
17
|
data?: any;
|
|
18
18
|
error?: any;
|
|
19
19
|
editRender?: Renderable<any>;
|
|
20
|
+
editorComponentName?: string;
|
|
20
21
|
}
|
|
21
22
|
export interface ListViewState extends ListViewStateProps {
|
|
22
23
|
openRemove: boolean;
|
|
@@ -30,10 +31,12 @@ export interface ListViewState extends ListViewStateProps {
|
|
|
30
31
|
nextPage: () => void;
|
|
31
32
|
setEditRender: (a: Renderable<any>) => void;
|
|
32
33
|
setDetailData: (detailData: any) => void;
|
|
34
|
+
setEeditorComponentName: (editorComponentName: string) => void;
|
|
33
35
|
}
|
|
34
36
|
export declare const listViewContext: import("react").Context<import("zustand").StoreApi<ListViewState> | null>;
|
|
35
37
|
type BearProviderProps = React.PropsWithChildren<ListViewStateProps>;
|
|
36
38
|
export declare const ListViewStoreProvider: (props: BearProviderProps) => import("react").JSX.Element;
|
|
37
39
|
export declare const ListView: (props: Omit<ComponentProps<typeof ListViewStoreProvider>, 'backendUrl'> & PropsWithChildren) => import("react").JSX.Element;
|
|
38
40
|
export declare function useListview<T>(selector: (state: ListViewState) => T): T;
|
|
41
|
+
export declare const useCurdUpdateMutation: () => import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
|
|
39
42
|
export {};
|
|
@@ -36,6 +36,7 @@ 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";
|
|
39
40
|
import { useGomtm } from "../../store/mtapp-store";
|
|
40
41
|
const createListviewStore = (initProps) => {
|
|
41
42
|
const DEFAULT_PROPS = {
|
|
@@ -77,7 +78,8 @@ const createListviewStore = (initProps) => {
|
|
|
77
78
|
nextPage: () => {
|
|
78
79
|
},
|
|
79
80
|
setEditRender: (editRender) => set({ editRender }),
|
|
80
|
-
setDetailData: (detailData) => set({ detailData })
|
|
81
|
+
setDetailData: (detailData) => set({ detailData }),
|
|
82
|
+
setEeditorComponentName: (editorComponentName) => set({ editorComponentName })
|
|
81
83
|
}));
|
|
82
84
|
};
|
|
83
85
|
const listViewContext = createContext(null);
|
|
@@ -100,9 +102,16 @@ function useListview(selector) {
|
|
|
100
102
|
throw new Error("useListview Missing ListViewProvider in the tree");
|
|
101
103
|
return useStore(store, selector);
|
|
102
104
|
}
|
|
105
|
+
const useCurdUpdateMutation = () => {
|
|
106
|
+
const svc = useListview((x) => x.svc);
|
|
107
|
+
const methodUpdate = useListview((x) => x.methodUpdate);
|
|
108
|
+
const mutationUpdate = useGomtmMutation(svc, methodUpdate);
|
|
109
|
+
return mutationUpdate;
|
|
110
|
+
};
|
|
103
111
|
export {
|
|
104
112
|
ListView,
|
|
105
113
|
ListViewStoreProvider,
|
|
106
114
|
listViewContext,
|
|
115
|
+
useCurdUpdateMutation,
|
|
107
116
|
useListview
|
|
108
117
|
};
|
package/dist/esm/gomtmQuery.js
CHANGED
|
@@ -43,7 +43,6 @@ function useGomtmSuspenseInfiniteQuery(svc, method, input) {
|
|
|
43
43
|
queryFn: (k) => fn(svc, method, input),
|
|
44
44
|
initialPageParam: input,
|
|
45
45
|
getNextPageParam: (lastPage, allPages, lastPageParam, allPageParams) => {
|
|
46
|
-
console.log("lastPage", lastPage);
|
|
47
46
|
return lastPage;
|
|
48
47
|
}
|
|
49
48
|
});
|