gomtm 0.0.339 → 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.
@@ -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("time", { dateTime: date1.toString(), children: formatDate(date1.toString(), "en-US") }) });
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
- /// <reference types="react" />
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,20 +12,17 @@ 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
  }
18
19
  if (fullScreen) {
19
- return /* @__PURE__ */ jsx(WithLoadGetData, { children: /* @__PURE__ */ jsxs(FullScreenPanel, { children: [
20
- !editRender && /* @__PURE__ */ jsx("div", { children: "missing editRender children" }),
21
- openEdit && editRender && flexRender(editRender, {})
22
- ] }) });
20
+ return /* @__PURE__ */ jsx(WithLoadGetData, { children: /* @__PURE__ */ jsx(FullScreenPanel, { children: openEdit && editRender && flexRender(editRender, {}) }) });
23
21
  }
24
22
  return /* @__PURE__ */ jsx(Dialog, { open: openEdit, onOpenChange: setOpenEdit, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
25
23
  /* @__PURE__ */ jsx(DialogTitle, { children: " Edit " }),
26
- openEdit && editRender && flexRender(editRender, {}),
24
+ /* @__PURE__ */ jsx(RenderEditorComponent, {}),
27
25
  /* @__PURE__ */ jsx(MtButton, { onClick: () => {
28
- console.log("editRender", editRender);
29
26
  }, children: "xxxxx" })
30
27
  ] }) });
31
28
  }
@@ -44,10 +41,7 @@ const WithLoadGetData = (props) => {
44
41
  if (detailQuery.isLoading) {
45
42
  return /* @__PURE__ */ jsx("div", { children: "loading detail" });
46
43
  }
47
- return /* @__PURE__ */ jsxs("div", { className: "bg-red-200 p-2", children: [
48
- "WithLoadGetData",
49
- children
50
- ] });
44
+ return /* @__PURE__ */ jsx("div", { className: "bg-red-200 p-2", children });
51
45
  };
52
46
  const CurdEditPanelTriggerButton = () => {
53
47
  const setOpenEdit = useListview((x) => x.setOpenEdit);
@@ -55,7 +49,34 @@ const CurdEditPanelTriggerButton = () => {
55
49
  setOpenEdit(true);
56
50
  }, children: "Edit" }) });
57
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
+ });
58
77
  export {
59
78
  CurdEditPanelTriggerButton,
79
+ RegisterEditorComponent,
80
+ RenderEditorComponent,
60
81
  CurdEditPanel as default
61
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
  ) })
@@ -41,7 +41,7 @@ function MtListView(props) {
41
41
  svc: etc.svc,
42
42
  method: etc.methodList,
43
43
  input: etc.paramsList,
44
- children: /* @__PURE__ */ jsx(ListViewRender, {})
44
+ children: /* @__PURE__ */ jsx(ListViewRender, { children })
45
45
  }
46
46
  ) }));
47
47
  }
@@ -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
  };
@@ -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
  });