gomtm 0.0.289 → 0.0.290

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.
Files changed (34) hide show
  1. package/dist/esm/components/devtools/GoMtmDebug.d.ts +1 -1
  2. package/dist/esm/components/devtools/GoMtmDebug.js +3 -8
  3. package/dist/esm/consts.d.ts +1 -2
  4. package/dist/esm/consts.js +3 -1
  5. package/dist/esm/curd/create/CurdCreatePanel.js +7 -5
  6. package/dist/esm/curd/edit/CurdEditPanel.js +8 -6
  7. package/dist/esm/curd/list-item/CommonListItemView.js +8 -8
  8. package/dist/esm/curd/list-item/PostCardListItem.js +18 -15
  9. package/dist/esm/curd/listview/ListViewProvider.d.ts +1 -66
  10. package/dist/esm/curd/listview/ListViewProvider.js +35 -116
  11. package/dist/esm/curd/listview/MtListView.d.ts +2 -2
  12. package/dist/esm/curd/listview/MtListView.js +18 -9
  13. package/dist/esm/curd/listview/list-store.d.ts +38 -0
  14. package/dist/esm/curd/listview/list-store.js +80 -0
  15. package/dist/esm/gomtmQuery.js +7 -7
  16. package/dist/esm/ly/LayoutBase.js +10 -9
  17. package/dist/esm/ly/front-layout/PageSearchCmd.js +23 -21
  18. package/dist/esm/providers/ConfigStateProvider.d.ts +0 -11
  19. package/dist/esm/providers/ConfigStateProvider.js +0 -44
  20. package/dist/esm/providers/GomtmAppSS.js +10 -11
  21. package/dist/esm/providers/GomtmProvider.d.ts +0 -43
  22. package/dist/esm/providers/GomtmProvider.js +0 -121
  23. package/dist/esm/providers/ListViewProvider.d.ts +1 -0
  24. package/dist/esm/providers/ListViewProvider.js +5 -1
  25. package/dist/esm/store/App_useTransition.d.ts +2 -0
  26. package/dist/esm/store/App_useTransition.js +59 -0
  27. package/dist/esm/store/config-store.d.ts +0 -16
  28. package/dist/esm/store/config-store.js +0 -44
  29. package/dist/esm/store/list-store.d.ts +11 -1
  30. package/dist/esm/store/list-store.js +64 -11
  31. package/dist/esm/store/mtapp-store.d.ts +30 -0
  32. package/dist/esm/store/mtapp-store.js +115 -0
  33. package/dist/tsconfig.type.tsbuildinfo +1 -1
  34. package/package.json +3 -3
@@ -1,2 +1,2 @@
1
1
  /// <reference types="react" />
2
- export declare const GoMtmDebug: () => import("react").JSX.Element | null;
2
+ export declare const GoMtmDebug: () => import("react").JSX.Element;
@@ -5,14 +5,9 @@ import { CommandDialog, CommandEmpty, CommandInput, CommandList, CommandSeparato
5
5
  import { Dialog, DialogContent, DialogTrigger } from "mtxuilib/ui/dialog";
6
6
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
7
7
  import { useState } from "react";
8
- import { useConfigStore } from "../../providers/ConfigStateProvider";
9
- import { useMtmApp } from "../../providers/GomtmProvider";
8
+ import { useGomtm } from "../../store/mtapp-store";
10
9
  const GoMtmDebug = () => {
11
10
  const [open, setOpen] = useState(false);
12
- const debug = useConfigStore((x) => x.debug);
13
- if (!debug) {
14
- return null;
15
- }
16
11
  return /* @__PURE__ */ jsxs("div", { className: "fixed bottom-12 right-2 bg-red-300", children: [
17
12
  /* @__PURE__ */ jsx(MtButton, { onClick: () => {
18
13
  setOpen(true);
@@ -30,12 +25,12 @@ const GoMtmDebug = () => {
30
25
  ] });
31
26
  };
32
27
  const DebugAppMainStateDlg = () => {
33
- const matpp = useMtmApp();
28
+ const globalSearchParams = useGomtm((x) => x.globalSearchParams);
34
29
  return /* @__PURE__ */ jsxs(Dialog, { children: [
35
30
  /* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx(MtButton, { children: "appState" }) }),
36
31
  /* @__PURE__ */ jsxs(DialogContent, { children: [
37
32
  "appstate",
38
- /* @__PURE__ */ jsx("pre", { children: JSON.stringify(matpp.globalSearchParams || "null", null, 2) })
33
+ /* @__PURE__ */ jsx("pre", { children: JSON.stringify(globalSearchParams, null, 2) })
39
34
  ] })
40
35
  ] });
41
36
  };
@@ -28,16 +28,15 @@ export declare const HOTKEY_Debug = "alt+j";
28
28
  export declare const HOTKEY_Switchlayout = "alt+l";
29
29
  export declare const HOTKEY_Listview_Switchlayout = "alt+m";
30
30
  export declare const HOTKEY_ListViewCMDK = "alt+c";
31
+ export declare const CONST_cookieListViewLayout = "listViewLayout";
31
32
  export declare const CONST_debounce_INPUT = 300;
32
33
  export declare const gomtmAppConfig: {
33
34
  cookieBackendUrl: string;
34
- cookieListViewLayout: string;
35
35
  CookieLayout: string;
36
36
  CookieConfigState: string;
37
37
  };
38
38
  export declare const getGomtmConfig: () => {
39
39
  cookieBackendUrl: string;
40
- cookieListViewLayout: string;
41
40
  CookieLayout: string;
42
41
  CookieConfigState: string;
43
42
  };
@@ -28,10 +28,11 @@ const HOTKEY_Debug = "alt+j";
28
28
  const HOTKEY_Switchlayout = "alt+l";
29
29
  const HOTKEY_Listview_Switchlayout = "alt+m";
30
30
  const HOTKEY_ListViewCMDK = "alt+c";
31
+ const CONST_cookieListViewLayout = "listViewLayout";
31
32
  const CONST_debounce_INPUT = 300;
32
33
  const gomtmAppConfig = {
33
34
  cookieBackendUrl: "backendUrl",
34
- cookieListViewLayout: "listViewLayout",
35
+ // cookieListViewLayout: "listViewLayout",
35
36
  CookieLayout: "layout",
36
37
  CookieConfigState: "_config"
37
38
  };
@@ -45,6 +46,7 @@ export {
45
46
  ActionEdit,
46
47
  ActionFetchNextPage,
47
48
  ActionRefetch,
49
+ CONST_cookieListViewLayout,
48
50
  CONST_debounce_INPUT,
49
51
  COOKIE_MTM_SITE_ID,
50
52
  Cookie_Site_Host,
@@ -2,15 +2,17 @@
2
2
  import { Fragment, jsx } from "react/jsx-runtime";
3
3
  import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
4
4
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
5
- import { useListView } from "../listview/ListViewProvider";
5
+ import { useListview } from "../listview/list-store";
6
6
  function CurdCreatePanel() {
7
- const listView = useListView();
8
- return /* @__PURE__ */ jsx(Dialog, { open: listView.openCreate, onOpenChange: listView.setOpenCreate, children: /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogTitle, { children: " Create " }) }) });
7
+ const openCreate = useListview((x) => x.openCreate);
8
+ const setOpenCreate = useListview((x) => x.setOpenCreate);
9
+ return /* @__PURE__ */ jsx(Dialog, { open: openCreate, onOpenChange: setOpenCreate, children: /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogTitle, { children: " Create " }) }) });
9
10
  }
10
11
  const CurdCreatePanelTriggerButton = () => {
11
- const listView = useListView();
12
+ const openCreate = useListview((x) => x.openCreate);
13
+ const setOpenCreate = useListview((x) => x.setOpenCreate);
12
14
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtButton, { onClick: () => {
13
- listView.setOpenCreate(true);
15
+ setOpenCreate(true);
14
16
  }, children: "OpenCreatePanel" }) });
15
17
  };
16
18
  export {
@@ -1,16 +1,18 @@
1
1
  "use client";
2
2
  import { Fragment, jsx } from "react/jsx-runtime";
3
- import { MtButton } from "mtxuilib/ui/ui-mt/Button";
4
- import { useListView } from "../listview/ListViewProvider";
5
3
  import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
4
+ import { MtButton } from "mtxuilib/ui/ui-mt/Button";
5
+ import { useListview } from "../listview/list-store";
6
6
  function CurdEditPanel() {
7
- const listView = useListView();
8
- return /* @__PURE__ */ jsx(Dialog, { open: listView.openEdit, onOpenChange: listView.setOpenEdit, children: /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogTitle, { children: " Edit " }) }) });
7
+ const setOpenEdit = useListview((x) => x.setOpenEdit);
8
+ 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 " }) }) });
9
10
  }
10
11
  const CurdEditPanelTriggerButton = () => {
11
- const listView = useListView();
12
+ const setOpenEdit = useListview((x) => x.setOpenEdit);
13
+ const openEdit = useListview((x) => x.openEdit);
12
14
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtButton, { onClick: () => {
13
- listView.setOpenEdit(true);
15
+ setOpenEdit(true);
14
16
  }, children: "Edit" }) });
15
17
  };
16
18
  export {
@@ -7,12 +7,12 @@ import { buttonVariants } from "mtxuilib/ui/button";
7
7
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
8
8
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
9
9
  import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
10
- import { useListView } from "../listview/ListViewProvider";
10
+ import { useListview } from "../listview/list-store";
11
11
  const CommonListItemView = (props) => {
12
12
  const { item } = props;
13
13
  const handleSelect = () => {
14
14
  };
15
- const listView = useListView();
15
+ const slugPath = useListview((x) => x.slugPath);
16
16
  return /* @__PURE__ */ jsxs(
17
17
  "div",
18
18
  {
@@ -25,8 +25,8 @@ const CommonListItemView = (props) => {
25
25
  "flex min-h-16 justify-start border p-4 text-left"
26
26
  ),
27
27
  children: [
28
- /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxs(MtLink, { href: `${listView.slugPath}/${item.id}`, children: [
29
- listView.slugPath,
28
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxs(MtLink, { href: `${slugPath}/${item.id}`, children: [
29
+ slugPath,
30
30
  item.title || item.id,
31
31
  item.description && /* @__PURE__ */ jsx("div", { children: item.description })
32
32
  ] }) }),
@@ -37,7 +37,7 @@ const CommonListItemView = (props) => {
37
37
  };
38
38
  const ListItemViewActions = (props) => {
39
39
  const { id } = props;
40
- const listView = useListView();
40
+ const slugPath = useListview((x) => x.slugPath);
41
41
  return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
42
42
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
43
43
  MtButton,
@@ -51,9 +51,9 @@ const ListItemViewActions = (props) => {
51
51
  }
52
52
  ) }),
53
53
  /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-[160px]", children: [
54
- /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${listView.slugPath}/show`, children: "show" }),
55
- /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${listView.slugPath}/edit`, children: "edit" }),
56
- /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${listView.slugPath}/listdebug`, children: "list debug" }),
54
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${slugPath}/show`, children: "show" }),
55
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${slugPath}/edit`, children: "edit" }),
56
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${slugPath}/listdebug`, children: "list debug" }),
57
57
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
58
58
  /* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
59
59
  "Delete",
@@ -6,35 +6,36 @@ import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle }
6
6
  import { Icons } from "mtxuilib/icons/icons";
7
7
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
8
8
  import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
9
- import { useListView } from "../listview/ListViewProvider";
9
+ import { useListview } from "../listview/list-store";
10
10
  const PostCardListItem = (props) => {
11
- var _a;
12
11
  const { item } = props;
13
- const listView = useListView();
12
+ const slugPath = useListview((x) => x.slugPath);
13
+ const activateItem = useListview((x) => x.activateItem);
14
+ const setActivateItem = useListview((x) => x.setActivateItem);
14
15
  return /* @__PURE__ */ jsxs(
15
16
  Card,
16
17
  {
17
18
  className: cn(
18
19
  "m-2 w-[350px]",
19
- item.id == ((_a = listView.activateItem) == null ? void 0 : _a.id) && " p-2 shadow-md"
20
+ item.id == (activateItem == null ? void 0 : activateItem.id) && " p-2 shadow-md"
20
21
  ),
21
22
  onClick: () => {
22
- listView.setActivateItem(item);
23
+ setActivateItem(item);
23
24
  },
24
25
  children: [
25
26
  /* @__PURE__ */ jsxs(CardHeader, { children: [
26
- /* @__PURE__ */ jsx(CardTitle, { children: /* @__PURE__ */ jsx(MtLink, { href: `${listView.slugPath}/${item.id}`, className: "pb-4 text-3xl font-bold hover:text-gray-700", children: item == null ? void 0 : item.title }) }),
27
+ /* @__PURE__ */ jsx(CardTitle, { children: /* @__PURE__ */ jsx(MtLink, { href: `${slugPath}/${item.id}`, className: "pb-4 text-3xl font-bold hover:text-gray-700", children: item == null ? void 0 : item.title }) }),
27
28
  /* @__PURE__ */ jsx(CardDescription, { children: "Deploy your new project in one-click." })
28
29
  ] }),
29
30
  /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("article", { className: "my-4 flex flex-col", children: [
30
31
  /* @__PURE__ */ jsx(MtLink, {
31
- href: `${listView.slugPath}/${item.id}`,
32
+ href: `${slugPath}/${item.id}`,
32
33
  className: "hover:opacity-75",
33
34
  // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
34
35
  children: item.topImage && /* @__PURE__ */ jsx("img", { src: item.topImage, alt: item.title })
35
36
  }),
36
37
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-start bg-white p-6", children: [
37
- /* @__PURE__ */ jsx(MtLink, { href: `${listView.slugPath}/${item.id}`, className: "pb-4 text-sm font-bold uppercase text-blue-700", children: item.category || "news" }),
38
+ /* @__PURE__ */ jsx(MtLink, { href: `${slugPath}/${item.id}`, className: "pb-4 text-sm font-bold uppercase text-blue-700", children: item.category || "news" }),
38
39
  /* @__PURE__ */ jsxs("p", { className: "pb-3 text-sm", children: [
39
40
  "By ",
40
41
  /* @__PURE__ */ jsx(MtLink, { href: "#", children: item.author }),
@@ -44,7 +45,7 @@ const PostCardListItem = (props) => {
44
45
  ] })
45
46
  ] }) }),
46
47
  /* @__PURE__ */ jsxs(CardFooter, { className: "flex justify-end", children: [
47
- /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `${listView.slugPath}/${item.id}`, children: "Show" }),
48
+ /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `${slugPath}/${item.id}`, children: "Show" }),
48
49
  /* @__PURE__ */ jsx(PostCardItemActions, { id: item.id })
49
50
  ] })
50
51
  ]
@@ -53,12 +54,14 @@ const PostCardListItem = (props) => {
53
54
  };
54
55
  const PostCardItemActions = (props) => {
55
56
  const { id } = props;
56
- const listView = useListView();
57
+ const setOpenCreate = useListview((x) => x.setOpenCreate);
58
+ const setOpenRemove = useListview((x) => x.setOpenRemove);
59
+ const slugPath = useListview((x) => x.slugPath);
57
60
  return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
58
61
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
59
62
  MtLink,
60
63
  {
61
- href: `${listView.slugPath}/${id}`,
64
+ href: `${slugPath}/${id}`,
62
65
  variant: "ghost",
63
66
  className: "data-[state=open]:bg-muted flex size-8 p-0",
64
67
  children: [
@@ -72,18 +75,18 @@ const PostCardItemActions = (props) => {
72
75
  DropdownMenuItem,
73
76
  {
74
77
  onClick: () => {
75
- listView.setOpenCreate(true);
78
+ setOpenCreate(true);
76
79
  },
77
80
  children: "create"
78
81
  }
79
82
  ),
80
- /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${listView.slugPath}/create`, children: "create" }),
81
- /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${listView.slugPath}/edit/${id}`, children: "edit" }),
83
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${slugPath}/create`, children: "create" }),
84
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${slugPath}/edit/${id}`, children: "edit" }),
82
85
  /* @__PURE__ */ jsx(
83
86
  DropdownMenuItem,
84
87
  {
85
88
  onClick: () => {
86
- listView.setOpenRemove(true);
89
+ setOpenRemove(true);
87
90
  },
88
91
  children: "remove"
89
92
  }
@@ -1,71 +1,6 @@
1
+ /// <reference types="react" />
1
2
  import { Message } from "@bufbuild/protobuf";
2
- import { Dispatch, PropsWithChildren, SetStateAction } from "react";
3
3
  export declare const LzListViewLayoutDemo: import("react").LazyExoticComponent<typeof import("./listview-layouts/listviewlayout-demo").default>;
4
4
  export declare const LzListViewLayoutDefault: import("react").LazyExoticComponent<typeof import("./listview-layouts/default").default>;
5
- interface ListViewProps {
6
- svc: string;
7
- methodList: string;
8
- methodDelete: string;
9
- methodCreate?: string;
10
- methodGet?: string;
11
- slugPath?: string;
12
- activateItem?: any;
13
- params?: any;
14
- getParams?: any;
15
- detailData?: any;
16
- layout?: string;
17
- }
18
- export declare function ListViewProvider(props: ListViewProps & PropsWithChildren): import("react").JSX.Element;
19
- export declare function useListView<I extends Message<I>, O extends Message<O>>(): {
20
- svc?: string | undefined;
21
- methodList?: string | undefined;
22
- methodDelete?: string | undefined;
23
- methodCreate?: string | undefined;
24
- methodGet?: string | undefined;
25
- slugPath?: string | undefined;
26
- activateItem?: any;
27
- params?: any;
28
- getParams?: any;
29
- detailData?: any;
30
- layout?: string | undefined;
31
- openRemove?: boolean | undefined;
32
- setOpenRemove?: Dispatch<SetStateAction<boolean>> | undefined;
33
- openCreate?: boolean | undefined;
34
- setOpenCreate?: Dispatch<SetStateAction<boolean>> | undefined;
35
- setActivateItem?: Dispatch<any> | undefined;
36
- openEdit?: boolean | undefined;
37
- setOpenEdit?: Dispatch<SetStateAction<boolean>> | undefined;
38
- openDebug?: boolean | undefined;
39
- setOpenDebug?: Dispatch<SetStateAction<boolean>> | undefined;
40
- setParams?: Dispatch<any> | undefined;
41
- setDetailData?: Dispatch<any> | undefined;
42
- setLayout?: ((arg0: string) => void) | undefined;
43
- };
44
- export declare function useDetail(): {
45
- svc: string;
46
- methodList: string;
47
- methodDelete: string;
48
- methodCreate?: string | undefined;
49
- methodGet?: string | undefined;
50
- slugPath?: string | undefined;
51
- activateItem?: any;
52
- params?: any;
53
- getParams?: any;
54
- detailData?: any;
55
- layout?: string | undefined;
56
- openRemove: boolean;
57
- setOpenRemove: Dispatch<SetStateAction<boolean>>;
58
- openCreate: boolean;
59
- setOpenCreate: Dispatch<SetStateAction<boolean>>;
60
- setActivateItem: Dispatch<any>;
61
- openEdit?: boolean | undefined;
62
- setOpenEdit: Dispatch<SetStateAction<boolean>>;
63
- openDebug?: boolean | undefined;
64
- setOpenDebug: Dispatch<SetStateAction<boolean>>;
65
- setParams: Dispatch<any>;
66
- setDetailData: Dispatch<any>;
67
- setLayout: (arg0: string) => void;
68
- };
69
5
  export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
70
6
  export declare const ListViewActions: () => import("react").JSX.Element;
71
- export {};
@@ -1,23 +1,4 @@
1
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
2
  var __async = (__this, __arguments, generator) => {
22
3
  return new Promise((resolve, reject) => {
23
4
  var fulfilled = (value) => {
@@ -39,102 +20,34 @@ var __async = (__this, __arguments, generator) => {
39
20
  });
40
21
  };
41
22
  import { jsx, jsxs } from "react/jsx-runtime";
42
- import { debounce } from "lodash";
43
23
  import { Icons } from "mtxuilib/icons/icons";
44
24
  import { cn } from "mtxuilib/lib/utils";
45
25
  import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
46
26
  import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
47
27
  import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
48
28
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
49
- import { Suspense, createContext, lazy, useCallback, useContext, useMemo, useState } from "react";
29
+ import { Suspense, lazy, useMemo, useState } from "react";
50
30
  import { useHotkeys } from "react-hotkeys-hook";
51
31
  import { MtmErrorView } from "../../components/MtmErrorView";
52
- import { CONST_debounce_INPUT, HOTKEY_Listview_Switchlayout } from "../../consts";
32
+ import { HOTKEY_Listview_Switchlayout } from "../../consts";
53
33
  import { useGomtmMutation, useGomtmSuspenseInfiniteQuery } from "../../gomtmQuery";
54
- import { useMtmApp } from "../../providers/GomtmProvider";
55
34
  import CurdCreatePanel, { CurdCreatePanelTriggerButton } from "../create/CurdCreatePanel";
56
35
  import CurdEditPanel, { CurdEditPanelTriggerButton } from "../edit/CurdEditPanel";
57
36
  import { ListItemView } from "../list-item/ListItem";
58
37
  import { ListLayout } from "../list-item/ListLayout";
38
+ import { useListview } from "./list-store";
59
39
  const ALL_Layouts = [
60
40
  "default",
61
41
  "demo"
62
42
  ];
63
43
  const LzListViewLayoutDemo = lazy(() => import("./listview-layouts/listviewlayout-demo"));
64
44
  const LzListViewLayoutDefault = lazy(() => import("./listview-layouts/default"));
65
- const commonListViewContext = createContext(void 0);
66
- function ListViewProvider(props) {
67
- var _a;
68
- const { children, svc, methodList, methodDelete, slugPath, methodCreate, methodGet, params, layout } = props;
69
- const mtapp = useMtmApp();
70
- const [_svc, setSvc] = useState(svc);
71
- const [openRemove, setOpenRemove] = useState(false);
72
- const [openCreate, setOpenCreate] = useState(false);
73
- const [activateItem, setActivateItem] = useState(void 0);
74
- const [openEdit, setOpenEdit] = useState(false);
75
- const [openDebug, setOpenDebug] = useState(false);
76
- const [_params, _setParams] = useState(params);
77
- const [detailData, setDetailData] = useState(void 0);
78
- const [_layout, _setLayout] = useState(mtapp.listviewLayout);
79
- const __params = useMemo(() => {
80
- var _a2, _b;
81
- return __spreadProps(__spreadValues({}, params), {
82
- params: __spreadValues(__spreadValues({}, params.params), ((_a2 = mtapp.globalSearchParams) == null ? void 0 : _a2.q) && {
83
- q: (_b = mtapp.globalSearchParams) == null ? void 0 : _b.q
84
- })
85
- });
86
- }, [(_a = mtapp.globalSearchParams) == null ? void 0 : _a.q, params]);
87
- const setParams = useCallback(debounce((values) => {
88
- _setParams(values);
89
- }, CONST_debounce_INPUT), [_setParams]);
90
- const setLayout = useCallback((name) => {
91
- _setLayout(name);
92
- mtapp.setListViewLayout(name);
93
- }, [mtapp]);
94
- return /* @__PURE__ */ jsx(commonListViewContext.Provider, { value: {
95
- svc: _svc,
96
- methodList,
97
- methodGet,
98
- methodDelete,
99
- methodCreate,
100
- slugPath,
101
- openRemove,
102
- setOpenRemove,
103
- openCreate,
104
- setOpenCreate,
105
- activateItem,
106
- setActivateItem,
107
- openEdit,
108
- setOpenEdit,
109
- openDebug,
110
- setOpenDebug,
111
- params: __params,
112
- setParams,
113
- detailData,
114
- setDetailData,
115
- layout: _layout,
116
- setLayout
117
- }, children: /* @__PURE__ */ jsxs(ListViewLayout, { children: [
118
- " ",
119
- children,
120
- " ",
121
- /* @__PURE__ */ jsx(ListViewLayoutSwitch, {})
122
- ] }) });
123
- }
124
- function useListView() {
125
- const ctx = useContext(commonListViewContext);
126
- return __spreadValues({}, ctx);
127
- }
128
- function useDetail() {
129
- const mtappContext = useContext(commonListViewContext);
130
- if (mtappContext === void 0) {
131
- throw new Error("useDetail must be used within a MtAppProvider");
132
- }
133
- return __spreadValues({}, mtappContext);
134
- }
135
45
  function CommonListView() {
136
- const listView = useListView();
137
- const listQuery = useGomtmSuspenseInfiniteQuery(listView.svc, listView.methodList, listView.params);
46
+ const svc = useListview((x) => x.svc);
47
+ const methodList = useListview((x) => x.methodList);
48
+ const paramList = useListview((x) => x.paramsList);
49
+ const backendUrl = useListview((x) => x.backendUrl);
50
+ const listQuery = useGomtmSuspenseInfiniteQuery(svc, methodList, paramList);
138
51
  if (!(listQuery == null ? void 0 : listQuery.data)) {
139
52
  return null;
140
53
  }
@@ -169,25 +82,33 @@ function CommonListView() {
169
82
  ] });
170
83
  }
171
84
  const PanelRemove = () => {
172
- const listView = useListView();
173
- const mutation = useGomtmMutation(listView.svc, listView.methodDelete);
174
- return /* @__PURE__ */ jsx(Dialog, { open: listView.openRemove, onOpenChange: listView.setOpenRemove, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
85
+ const svc = useListview((x) => x.svc);
86
+ const openRemove = useListview((x) => x.openRemove);
87
+ const setOpenRemove = useListview((x) => x.setOpenRemove);
88
+ const methodDelete = useListview((x) => x.methodDelete);
89
+ const mutation = useGomtmMutation(svc, methodDelete);
90
+ const activateItem = useListview((x) => x.activateItem);
91
+ return /* @__PURE__ */ jsx(Dialog, { open: openRemove, onOpenChange: setOpenRemove, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
175
92
  /* @__PURE__ */ jsx(DialogTitle, { children: "remove item" }),
176
93
  /* @__PURE__ */ jsx(MtButton, { onClick: () => __async(void 0, null, function* () {
177
- var _a;
178
94
  yield mutation.mutateAsync({
179
- id: (_a = listView.activateItem) == null ? void 0 : _a.id
95
+ id: activateItem == null ? void 0 : activateItem.id
180
96
  });
181
- listView.setOpenRemove(false);
97
+ setOpenRemove(false);
182
98
  }), children: "ok" })
183
99
  ] }) });
184
100
  };
185
101
  const PanelCreate = () => {
186
- const listView = useListView();
187
- return /* @__PURE__ */ jsx(Dialog, { open: listView.openCreate, onOpenChange: listView.setOpenCreate, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
102
+ const svc = useListview((x) => x.svc);
103
+ const openCreate = useListview((x) => x.openCreate);
104
+ const setOpenCreate = useListview((x) => x.setOpenCreate);
105
+ const methodDelete = useListview((x) => x.methodDelete);
106
+ const mutation = useGomtmMutation(svc, methodDelete);
107
+ const activateItem = useListview((x) => x.activateItem);
108
+ return /* @__PURE__ */ jsx(Dialog, { open: openCreate, onOpenChange: setOpenCreate, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
188
109
  /* @__PURE__ */ jsx(DialogTitle, { children: "TODO create item Dlg" }),
189
110
  /* @__PURE__ */ jsx(MtButton, { onClick: () => __async(void 0, null, function* () {
190
- listView.setOpenCreate(false);
111
+ setOpenCreate(false);
191
112
  }), children: "ok" })
192
113
  ] }) });
193
114
  };
@@ -212,20 +133,21 @@ const ListViewActions = () => {
212
133
  ] });
213
134
  };
214
135
  const ListViewLayout = (props) => {
215
- const listView = useListView();
136
+ const layout = useListview((x) => x.layout);
216
137
  const { children } = props;
217
138
  const Layout = useMemo(() => {
218
- switch (listView.layout) {
139
+ switch (layout) {
219
140
  case "demo":
220
141
  return LzListViewLayoutDemo;
221
142
  default:
222
143
  return LzListViewLayoutDefault;
223
144
  }
224
- }, [listView.layout]);
145
+ }, [layout]);
225
146
  return /* @__PURE__ */ jsx(Layout, { children });
226
147
  };
227
148
  const ListViewLayoutSwitch = () => {
228
- const listview = useListView();
149
+ const layout = useListview((x) => x.layout);
150
+ const setLayout = useListview((x) => x.setLayout);
229
151
  const [open, setOpen] = useState(false);
230
152
  useHotkeys(HOTKEY_Listview_Switchlayout, () => {
231
153
  setOpen((pre) => !pre);
@@ -233,22 +155,19 @@ const ListViewLayoutSwitch = () => {
233
155
  return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
234
156
  /* @__PURE__ */ jsxs(DialogTitle, { children: [
235
157
  "LayoutSwitch,",
236
- listview.layout
158
+ layout
237
159
  ] }),
238
- /* @__PURE__ */ jsx("div", { className: "flex gap-2 bg-red-100 p-2", children: ALL_Layouts.map((layout) => {
160
+ /* @__PURE__ */ jsx("div", { className: "flex gap-2 bg-red-100 p-2", children: ALL_Layouts.map((layout2) => {
239
161
  return /* @__PURE__ */ jsx(MtButton, { onClick: () => {
240
- listview.setLayout(layout);
162
+ setLayout(layout2);
241
163
  setOpen(false);
242
- }, children: layout }, layout);
164
+ }, children: layout2 }, layout2);
243
165
  }) })
244
166
  ] }) });
245
167
  };
246
168
  export {
247
169
  CommonListView,
248
170
  ListViewActions,
249
- ListViewProvider,
250
171
  LzListViewLayoutDefault,
251
- LzListViewLayoutDemo,
252
- useDetail,
253
- useListView
172
+ LzListViewLayoutDemo
254
173
  };
@@ -1,3 +1,3 @@
1
1
  import { ComponentProps, PropsWithChildren } from "react";
2
- import { ListViewProvider } from "./ListViewProvider";
3
- export default function MtListView(props: {} & ComponentProps<typeof ListViewProvider> & PropsWithChildren): import("react").JSX.Element;
2
+ import { ListViewStoreProvider } from "./list-store";
3
+ export default function MtListView(props: {} & ComponentProps<typeof ListViewStoreProvider> & PropsWithChildren): import("react").JSX.Element;
@@ -32,18 +32,27 @@ var __objRest = (source, exclude) => {
32
32
  import { jsx } from "react/jsx-runtime";
33
33
  import { PrefetchConnectInfiniteQuery } from "../../components/SSR";
34
34
  import { siteList } from "../../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
35
- import { ListViewProvider } from "./ListViewProvider";
35
+ import { ListViewStoreProvider } from "./list-store";
36
36
  function MtListView(props) {
37
37
  const _a = props, { children } = _a, etc = __objRest(_a, ["children"]);
38
- return /* @__PURE__ */ jsx(ListViewProvider, __spreadProps(__spreadValues({}, etc), { children: /* @__PURE__ */ jsx(
39
- PrefetchConnectInfiniteQuery,
40
- {
38
+ return /* @__PURE__ */ jsx(
39
+ ListViewStoreProvider,
40
+ __spreadProps(__spreadValues({}, etc), {
41
41
  svc: siteList.service.typeName,
42
- method: siteList.name,
43
- input: etc.params,
44
- children
45
- }
46
- ) }));
42
+ methodList: siteList.name,
43
+ paramsList: etc.paramsList,
44
+ paramsGet: etc.paramsGet,
45
+ children: /* @__PURE__ */ jsx(
46
+ PrefetchConnectInfiniteQuery,
47
+ {
48
+ svc: siteList.service.typeName,
49
+ method: siteList.name,
50
+ input: etc.paramsList,
51
+ children
52
+ }
53
+ )
54
+ })
55
+ );
47
56
  }
48
57
  export {
49
58
  MtListView as default
@@ -0,0 +1,38 @@
1
+ /// <reference types="react" />
2
+ interface ListViewStateProps {
3
+ backendUrl?: string;
4
+ svc: string;
5
+ methodList: string;
6
+ methodGet: string;
7
+ methodDelete: string;
8
+ methodCreate?: string;
9
+ paramsGet?: any;
10
+ paramsList?: any;
11
+ slugPath?: string;
12
+ activateItem?: any;
13
+ detailData?: any;
14
+ layout?: string;
15
+ }
16
+ export interface ListViewState extends ListViewStateProps {
17
+ openRemove: boolean;
18
+ setOpenRemove: (openRemove: boolean) => void;
19
+ openCreate: boolean;
20
+ setOpenCreate: (openCreate: boolean) => void;
21
+ openEdit: boolean;
22
+ setOpenEdit: (openEdit: boolean) => void;
23
+ setLayout: (layout: string) => void;
24
+ setActivateItem: (activateItem: any) => void;
25
+ loading?: boolean;
26
+ success?: boolean;
27
+ error?: boolean;
28
+ data?: any;
29
+ errorData?: any;
30
+ demoListData?: any;
31
+ items?: any[];
32
+ value1?: any;
33
+ }
34
+ export declare const listViewContext: import("react").Context<import("zustand").StoreApi<ListViewState> | null>;
35
+ type BearProviderProps = React.PropsWithChildren<ListViewStateProps>;
36
+ export declare const ListViewStoreProvider: (props: BearProviderProps) => import("react").JSX.Element;
37
+ export declare function useListview<T>(selector: (state: ListViewState) => T): T;
38
+ export {};