gomtm 0.0.251 → 0.0.252

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,7 +1,6 @@
1
1
  import { Message } from "@bufbuild/protobuf";
2
- import { PropsWithChildren } from "react";
2
+ import { Dispatch, PropsWithChildren, SetStateAction } from "react";
3
3
  import { MethodUnaryDescriptor } from "../connectquery";
4
- export declare const curdSlugPathAtom: import("jotai").Atom<string>;
5
4
  export declare const exampleListItemValueComponent: import("jotai").PrimitiveAtom<any> & {
6
5
  init: any;
7
6
  };
@@ -12,5 +11,21 @@ export declare function CommonListViewProvider<I extends Message<I>, O extends M
12
11
  methodCreate?: MethodUnaryDescriptor<any, any>;
13
12
  slugPath?: string;
14
13
  } & PropsWithChildren): import("react").JSX.Element;
14
+ export declare const useListView: () => {
15
+ methodList?: MethodUnaryDescriptor<any, any> | undefined;
16
+ methodDelete?: MethodUnaryDescriptor<any, any> | undefined;
17
+ methodCreate?: MethodUnaryDescriptor<any, any> | undefined;
18
+ slugPath?: string | undefined;
19
+ activateItem?: any;
20
+ openEdit?: boolean | undefined;
21
+ openDebug?: boolean | undefined;
22
+ openRemove?: boolean | undefined;
23
+ setOpenRemove?: Dispatch<SetStateAction<boolean>> | undefined;
24
+ openCreate?: boolean | undefined;
25
+ setOpenCreate?: Dispatch<SetStateAction<boolean>> | undefined;
26
+ setActivateItem?: Dispatch<any> | undefined;
27
+ setOpenEdit?: Dispatch<SetStateAction<boolean>> | undefined;
28
+ setOpenDebug?: Dispatch<SetStateAction<boolean>> | undefined;
29
+ };
15
30
  export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
16
31
  export declare const ListViewActions: () => import("react").JSX.Element;
@@ -1,4 +1,20 @@
1
1
  "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __spreadValues = (a, b) => {
8
+ for (var prop in b || (b = {}))
9
+ if (__hasOwnProp.call(b, prop))
10
+ __defNormalProp(a, prop, b[prop]);
11
+ if (__getOwnPropSymbols)
12
+ for (var prop of __getOwnPropSymbols(b)) {
13
+ if (__propIsEnum.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ }
16
+ return a;
17
+ };
2
18
  var __async = (__this, __arguments, generator) => {
3
19
  return new Promise((resolve, reject) => {
4
20
  var fulfilled = (value) => {
@@ -20,33 +36,22 @@ var __async = (__this, __arguments, generator) => {
20
36
  });
21
37
  };
22
38
  import { jsx, jsxs } from "react/jsx-runtime";
23
- import { atom, useAtom } from "jotai";
39
+ import { atom } from "jotai";
24
40
  import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
25
- import { DebugAtomValue } from "mtxuilib/common/devtools/DebugAtomValue";
26
41
  import { Icons } from "mtxuilib/icons/icons";
27
42
  import { cn } from "mtxuilib/lib/utils";
28
43
  import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
29
44
  import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
30
45
  import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
31
46
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
32
- import { Suspense } from "react";
47
+ import { Suspense, createContext, useContext, useState } from "react";
33
48
  import { MtUnaryCallErrorView } from "../components/MtUnaryCallErrorView";
34
49
  import { useMutation, useSuspenseInfiniteQuery } from "../connectquery";
35
50
  import CurdCreatePanel, { CurdCreatePanelTriggerButton, openCurdCreatePanelAtom } from "./create/CurdCreatePanel";
36
- import { activateItemAtom, createMethodSigAtom, openCreatePanelAtom, openRemovePanelAtom, removeMethodSigAtom } from "./curd.atoms";
37
51
  import { DlgCurdDebugInfo, DlgCurdDebugInfoTriggerButton, openDlgCurdDebugInfoAtom } from "./dlg/DlgCurdDebugInfo";
38
- import CurdEditPanel, { CurdEditPanelTriggerButton, openCurdEditPanelAtom } from "./edit/CurdEditPanel";
52
+ import CurdEditPanel, { CurdEditPanelTriggerButton } from "./edit/CurdEditPanel";
39
53
  import { ListItemView } from "./list-item/ListItem";
40
54
  import { ListLayout } from "./list-item/ListLayout";
41
- const listQueryAtom = atom(null);
42
- const curdSlugPathValueAtom = atom("");
43
- const curdSlugPathAtom = atom((get) => {
44
- const value = get(curdSlugPathValueAtom);
45
- if (value == "/") {
46
- return "";
47
- }
48
- return value || "";
49
- });
50
55
  const exampleListItemValueComponent = atom(void 0);
51
56
  const exampleListItemComponent = atom((get) => {
52
57
  const v = get(exampleListItemValueComponent);
@@ -57,34 +62,50 @@ const exampleListItemComponent = atom((get) => {
57
62
  return /* @__PURE__ */ jsx("div", { children: "missing exampleListItemComponent" });
58
63
  };
59
64
  });
65
+ const commonListViewContext = createContext(void 0);
60
66
  function CommonListViewProvider(props) {
61
67
  const { children, methodList, methodDelete, slugPath, methodCreate } = props;
62
- const listquery = useSuspenseInfiniteQuery(methodList, {
63
- //@ts-expect-error
68
+ const [openRemove, setOpenRemove] = useState(false);
69
+ const [openCreate, setOpenCreate] = useState(false);
70
+ const [activateItem, setActivateItem] = useState(void 0);
71
+ const [openEdit, setOpenEdit] = useState(false);
72
+ const [openDebug, setOpenDebug] = useState(false);
73
+ return /* @__PURE__ */ jsx(commonListViewContext.Provider, { value: {
74
+ methodList,
75
+ slugPath,
76
+ openRemove,
77
+ setOpenRemove,
78
+ methodDelete,
79
+ methodCreate,
80
+ openCreate,
81
+ setOpenCreate,
82
+ activateItem,
83
+ setActivateItem,
84
+ openEdit,
85
+ setOpenEdit,
86
+ openDebug,
87
+ setOpenDebug
88
+ }, children: /* @__PURE__ */ jsx(ScopeAtomsHydrator, { atomValues: [
89
+ [openDlgCurdDebugInfoAtom, false],
90
+ [openCurdCreatePanelAtom, false]
91
+ ], children }) });
92
+ }
93
+ const useListView = () => {
94
+ const ctx = useContext(commonListViewContext);
95
+ return __spreadValues({}, ctx);
96
+ };
97
+ function CommonListView() {
98
+ const a = useListView();
99
+ const listQuery = useSuspenseInfiniteQuery(a.methodList, {
64
100
  page: 1
65
101
  }, {
66
102
  pageParamKey: "pagination",
67
103
  getNextPageParam: (res, b, c) => {
68
104
  return {
69
- //@ts-expect-error
70
105
  page: ((c == null ? void 0 : c.page) || 0) + 1
71
106
  };
72
107
  }
73
108
  });
74
- return /* @__PURE__ */ jsx(ScopeAtomsHydrator, { atomValues: [
75
- [listQueryAtom, listquery],
76
- [curdSlugPathValueAtom, slugPath],
77
- [removeMethodSigAtom, methodDelete],
78
- [createMethodSigAtom, methodCreate],
79
- [openRemovePanelAtom, false],
80
- [openCreatePanelAtom, false],
81
- [openDlgCurdDebugInfoAtom, false],
82
- [openCurdEditPanelAtom, false],
83
- [openCurdCreatePanelAtom, false]
84
- ], children });
85
- }
86
- function CommonListView() {
87
- const [listQuery, setListQuery] = useAtom(listQueryAtom);
88
109
  if (!(listQuery == null ? void 0 : listQuery.data)) {
89
110
  return null;
90
111
  }
@@ -119,29 +140,25 @@ function CommonListView() {
119
140
  ] });
120
141
  }
121
142
  const PanelRemove = () => {
122
- const [activateItem] = useAtom(activateItemAtom);
123
- const [removeMeghodSig] = useAtom(removeMethodSigAtom);
124
- const [openRemovePanel, setOpenRemovePanel] = useAtom(openRemovePanelAtom);
125
- const mutation = useMutation(removeMeghodSig);
126
- return /* @__PURE__ */ jsx(Dialog, { open: openRemovePanel, onOpenChange: setOpenRemovePanel, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
143
+ const listView = useListView();
144
+ const mutation = useMutation(listView.methodDelete);
145
+ return /* @__PURE__ */ jsx(Dialog, { open: listView.openRemove, onOpenChange: listView.setOpenRemove, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
127
146
  /* @__PURE__ */ jsx(DialogTitle, { children: "remove item" }),
128
147
  /* @__PURE__ */ jsx(MtButton, { onClick: () => __async(void 0, null, function* () {
148
+ var _a;
129
149
  yield mutation.mutateAsync({
130
- id: activateItem.id
150
+ id: (_a = listView.activateItem) == null ? void 0 : _a.id
131
151
  });
132
- setOpenRemovePanel(false);
133
- }), children: "ok" }),
134
- /* @__PURE__ */ jsx(DebugAtomValue, { title: "removeMeghodSigAtom", atom: removeMethodSigAtom }),
135
- /* @__PURE__ */ jsx(DebugAtomValue, { title: "activateItemAtom", atom: activateItemAtom })
152
+ listView.setOpenRemove(false);
153
+ }), children: "ok" })
136
154
  ] }) });
137
155
  };
138
156
  const PanelCreate = () => {
139
- const [removeMeghodSig] = useAtom(removeMethodSigAtom);
140
- const [openCreatePanel, setOpenCreatePanel] = useAtom(openCreatePanelAtom);
141
- return /* @__PURE__ */ jsx(Dialog, { open: openCreatePanel, onOpenChange: setOpenCreatePanel, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
157
+ const listView = useListView();
158
+ return /* @__PURE__ */ jsx(Dialog, { open: listView.openCreate, onOpenChange: listView.setOpenCreate, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
142
159
  /* @__PURE__ */ jsx(DialogTitle, { children: "TODO create item Dlg" }),
143
160
  /* @__PURE__ */ jsx(MtButton, { onClick: () => __async(void 0, null, function* () {
144
- setOpenCreatePanel(false);
161
+ listView.setOpenCreate(false);
145
162
  }), children: "ok" })
146
163
  ] }) });
147
164
  };
@@ -171,7 +188,7 @@ export {
171
188
  CommonListView,
172
189
  CommonListViewProvider,
173
190
  ListViewActions,
174
- curdSlugPathAtom,
175
191
  exampleListItemComponent,
176
- exampleListItemValueComponent
192
+ exampleListItemValueComponent,
193
+ useListView
177
194
  };
@@ -1,24 +1,8 @@
1
1
  import { AnyMessage, PlainMessage } from "@bufbuild/protobuf";
2
2
  import { CommontListRes } from "../gomtmpb/mtm/sppb/mtm_pb";
3
- export declare const curdActivateIdAtom: import("jotai").PrimitiveAtom<string> & {
4
- init: string;
5
- };
6
3
  export declare const curd3ListParamsAtom: import("jotai").PrimitiveAtom<PlainMessage<AnyMessage>> & {
7
4
  init: PlainMessage<AnyMessage>;
8
5
  };
9
- export declare const activateItemValueAtom: import("jotai").PrimitiveAtom<any> & {
10
- init: any;
11
- };
12
- export declare const activateItemAtom: import("jotai").WritableAtom<any, [value: any], void>;
13
- export declare const paramsAtom: import("jotai").Atom<any>;
14
- export declare const removeMethodSigAtom: import("jotai").PrimitiveAtom<any> & {
15
- init: any;
16
- };
17
- export declare const openRemovePanelAtom: import("jotai").WritableAtom<boolean, [value: boolean], void>;
18
- export declare const createMethodSigAtom: import("jotai").PrimitiveAtom<any> & {
19
- init: any;
20
- };
21
- export declare const openCreatePanelAtom: import("jotai").WritableAtom<boolean, [value: boolean], void>;
22
6
  export declare const curdPathAtom: import("jotai").PrimitiveAtom<string> & {
23
7
  init: string;
24
8
  };
@@ -24,37 +24,7 @@ import { usePathname } from "next/navigation";
24
24
  import { useMemo } from "react";
25
25
  import { CommontListRes } from "../gomtmpb/mtm/sppb/mtm_pb";
26
26
  import { gomtmBaseUrlAtom } from "../providers/GomtmProvider";
27
- const curdActivateIdAtom = atom("");
28
27
  const curd3ListParamsAtom = atom({});
29
- const activateItemValueAtom = atom(void 0);
30
- const activateItemAtom = atom((get) => {
31
- const v = get(activateItemValueAtom);
32
- return v;
33
- }, (_, set, value) => {
34
- if (value == null ? void 0 : value.id) {
35
- set(curdActivateIdAtom, value.id);
36
- }
37
- set(activateItemValueAtom, value);
38
- });
39
- const paramsValueAtom = atom(void 0);
40
- const paramsAtom = atom((get) => {
41
- const v = get(paramsValueAtom);
42
- return v;
43
- });
44
- const removeMethodSigAtom = atom(void 0);
45
- const openRemovePanelValueAtom = atom(false);
46
- const openRemovePanelAtom = atom((get) => {
47
- return get(openRemovePanelValueAtom);
48
- }, (_, set, value) => {
49
- set(openRemovePanelValueAtom, value);
50
- });
51
- const createMethodSigAtom = atom(void 0);
52
- const openCreatePanelValueAtom = atom(false);
53
- const openCreatePanelAtom = atom((get) => {
54
- return get(openCreatePanelValueAtom);
55
- }, (_, set, value) => {
56
- set(openCreatePanelValueAtom, value);
57
- });
58
28
  const curdPathAtom = atom("");
59
29
  const curd3ItemsV2Atom = atom((get) => __async(void 0, null, function* () {
60
30
  const slugPath = get(curdPathAtom);
@@ -77,16 +47,8 @@ const useCurdSlugName = () => {
77
47
  return nameSlug;
78
48
  };
79
49
  export {
80
- activateItemAtom,
81
- activateItemValueAtom,
82
- createMethodSigAtom,
83
50
  curd3ItemsV2Atom,
84
51
  curd3ListParamsAtom,
85
- curdActivateIdAtom,
86
52
  curdPathAtom,
87
- openCreatePanelAtom,
88
- openRemovePanelAtom,
89
- paramsAtom,
90
- removeMethodSigAtom,
91
53
  useCurdSlugName
92
54
  };
@@ -1,25 +1,18 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { atom, useAtom } from "jotai";
4
- import { DebugAtomValue } from "mtxuilib/common/devtools/DebugAtomValue";
5
4
  import { flexRender } from "mtxuilib/lib/render";
6
5
  import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
7
6
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
8
7
  import { isDebugAtom } from "../../providers/GomtmProvider";
9
8
  import { exampleListItemComponent } from "../CommonListViewV2";
10
- import { createMethodSigAtom, curdActivateIdAtom, removeMethodSigAtom } from "../curd.atoms";
11
9
  const openDlgCurdDebugInfoAtom = atom(false);
12
10
  function DlgCurdDebugInfo() {
13
11
  const [Comp] = useAtom(exampleListItemComponent);
14
12
  const [openDlgCurdDebugInfo, setOpenDlgCurdDebugInfo] = useAtom(openDlgCurdDebugInfoAtom);
15
13
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Dialog, { open: openDlgCurdDebugInfo, onOpenChange: setOpenDlgCurdDebugInfo, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
16
14
  /* @__PURE__ */ jsx(DialogTitle, { children: "list view info" }),
17
- Comp && flexRender(Comp, {}),
18
- /* @__PURE__ */ jsxs("div", { children: [
19
- /* @__PURE__ */ jsx(DebugAtomValue, { title: "curdActivateIdAtom", atom: curdActivateIdAtom }),
20
- /* @__PURE__ */ jsx(DebugAtomValue, { title: "removeMethodSigAtom", atom: removeMethodSigAtom }),
21
- /* @__PURE__ */ jsx(DebugAtomValue, { title: "createMethodSigAtom", atom: createMethodSigAtom })
22
- ] })
15
+ Comp && flexRender(Comp, {})
23
16
  ] }) }) });
24
17
  }
25
18
  const DlgCurdDebugInfoTriggerButton = () => {
@@ -1,6 +1,3 @@
1
1
  /// <reference types="react" />
2
- export declare const openCurdEditPanelAtom: import("jotai").PrimitiveAtom<boolean> & {
3
- init: boolean;
4
- };
5
2
  export default function CurdEditPanel(): import("react").JSX.Element;
6
3
  export declare const CurdEditPanelTriggerButton: () => import("react").JSX.Element;
@@ -1,28 +1,19 @@
1
1
  "use client";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { atom, useAtom } from "jotai";
2
+ import { Fragment, jsx } from "react/jsx-runtime";
4
3
  import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
5
4
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
6
- const openCurdEditPanelAtom = atom(false);
5
+ import { useListView } from "../CommonListViewV2";
7
6
  function CurdEditPanel() {
8
- const [openCurdEditPanel, setOpenCurdEditPanel] = useAtom(openCurdEditPanelAtom);
9
- return /* @__PURE__ */ jsx(Dialog, { open: openCurdEditPanel, onOpenChange: setOpenCurdEditPanel, children: /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsx(DialogTitle, { children: " Edit " }) }) });
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 " }) }) });
10
9
  }
11
10
  const CurdEditPanelTriggerButton = () => {
12
- const [openCurdEditPanel, setOpenCurdEditPanel] = useAtom(openCurdEditPanelAtom);
13
- return /* @__PURE__ */ jsxs(Fragment, { children: [
14
- /* @__PURE__ */ jsx("pre", { children: openCurdEditPanel }),
15
- /* @__PURE__ */ jsxs(MtButton, { onClick: () => {
16
- setOpenCurdEditPanel(true);
17
- }, children: [
18
- "Edit(",
19
- JSON.stringify(openCurdEditPanel, null, 2),
20
- ")"
21
- ] })
22
- ] });
11
+ const listView = useListView();
12
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(MtButton, { onClick: () => {
13
+ listView.setOpenEdit(true);
14
+ }, children: "Edit" }) });
23
15
  };
24
16
  export {
25
17
  CurdEditPanelTriggerButton,
26
- CurdEditPanel as default,
27
- openCurdEditPanelAtom
18
+ CurdEditPanel as default
28
19
  };
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useAtom } from "jotai";
4
3
  import { MtLink } from "mtxuilib/common/mtlink";
5
4
  import { Icons } from "mtxuilib/icons/icons";
6
5
  import { cn } from "mtxuilib/lib/utils";
@@ -8,12 +7,12 @@ import { buttonVariants } from "mtxuilib/ui/button";
8
7
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
9
8
  import { MtButton } from "mtxuilib/ui/ui-mt/Button";
10
9
  import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
11
- import { curdSlugPathAtom } from "../CommonListViewV2";
10
+ import { useListView } from "../CommonListViewV2";
12
11
  const CommonListItemView = (props) => {
13
12
  const { item } = props;
14
13
  const handleSelect = () => {
15
14
  };
16
- const [curdSlugPath] = useAtom(curdSlugPathAtom);
15
+ const listView = useListView();
17
16
  return /* @__PURE__ */ jsxs(
18
17
  "div",
19
18
  {
@@ -26,8 +25,8 @@ const CommonListItemView = (props) => {
26
25
  "flex min-h-16 justify-start border p-4 text-left"
27
26
  ),
28
27
  children: [
29
- /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxs(MtLink, { href: `${curdSlugPath}/${item.id}`, children: [
30
- curdSlugPath,
28
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxs(MtLink, { href: `${listView.slugPath}/${item.id}`, children: [
29
+ listView.slugPath,
31
30
  item.title || item.id,
32
31
  item.description && /* @__PURE__ */ jsx("div", { children: item.description })
33
32
  ] }) }),
@@ -38,7 +37,7 @@ const CommonListItemView = (props) => {
38
37
  };
39
38
  const ListItemViewActions = (props) => {
40
39
  const { id } = props;
41
- const [curdSlugPath] = useAtom(curdSlugPathAtom);
40
+ const listView = useListView();
42
41
  return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
43
42
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
44
43
  MtButton,
@@ -52,9 +51,9 @@ const ListItemViewActions = (props) => {
52
51
  }
53
52
  ) }),
54
53
  /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-[160px]", children: [
55
- /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/show`, children: "show" }),
56
- /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/edit`, children: "edit" }),
57
- /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/listdebug`, children: "list debug" }),
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" }),
58
57
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
59
58
  /* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
60
59
  "Delete",
@@ -1,42 +1,40 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useAtom } from "jotai";
4
3
  import { MtLink } from "mtxuilib/common/mtlink";
5
4
  import { cn } from "mtxuilib/lib/utils";
6
5
  import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "mtxuilib/ui/card";
7
6
  import { Icons } from "mtxuilib/icons/icons";
8
7
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
9
8
  import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
10
- import { curdSlugPathAtom } from "../CommonListViewV2";
11
- import { activateItemAtom, openCreatePanelAtom, openRemovePanelAtom, removeMethodSigAtom } from "../curd.atoms";
9
+ import { useListView } from "../CommonListViewV2";
12
10
  const PostCardListItem = (props) => {
11
+ var _a;
13
12
  const { item } = props;
14
- const [activateItem, setActivateItem] = useAtom(activateItemAtom);
15
- const [curdSlugPath] = useAtom(curdSlugPathAtom);
13
+ const listView = useListView();
16
14
  return /* @__PURE__ */ jsxs(
17
15
  Card,
18
16
  {
19
17
  className: cn(
20
18
  "m-2 w-[350px]",
21
- item.id == (activateItem == null ? void 0 : activateItem.id) && " p-2 shadow-md"
19
+ item.id == ((_a = listView.activateItem) == null ? void 0 : _a.id) && " p-2 shadow-md"
22
20
  ),
23
21
  onClick: () => {
24
- setActivateItem(item);
22
+ listView.setActivateItem(item);
25
23
  },
26
24
  children: [
27
25
  /* @__PURE__ */ jsxs(CardHeader, { children: [
28
- /* @__PURE__ */ jsx(CardTitle, { children: /* @__PURE__ */ jsx(MtLink, { href: `${curdSlugPath}/${item.id}`, className: "pb-4 text-3xl font-bold hover:text-gray-700", children: item == null ? void 0 : item.title }) }),
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 }) }),
29
27
  /* @__PURE__ */ jsx(CardDescription, { children: "Deploy your new project in one-click." })
30
28
  ] }),
31
29
  /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs("article", { className: "my-4 flex flex-col", children: [
32
30
  /* @__PURE__ */ jsx(MtLink, {
33
- href: `${curdSlugPath}/${item.id}`,
31
+ href: `${listView.slugPath}/${item.id}`,
34
32
  className: "hover:opacity-75",
35
33
  // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
36
34
  children: item.topImage && /* @__PURE__ */ jsx("img", { src: item.topImage, alt: item.title })
37
35
  }),
38
36
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-start bg-white p-6", children: [
39
- /* @__PURE__ */ jsx(MtLink, { href: `${curdSlugPath}/${item.id}`, className: "pb-4 text-sm font-bold uppercase text-blue-700", children: item.category || "news" }),
37
+ /* @__PURE__ */ jsx(MtLink, { href: `${listView.slugPath}/${item.id}`, className: "pb-4 text-sm font-bold uppercase text-blue-700", children: item.category || "news" }),
40
38
  /* @__PURE__ */ jsxs("p", { className: "pb-3 text-sm", children: [
41
39
  "By ",
42
40
  /* @__PURE__ */ jsx(MtLink, { href: "#", children: item.author }),
@@ -46,7 +44,7 @@ const PostCardListItem = (props) => {
46
44
  ] })
47
45
  ] }) }),
48
46
  /* @__PURE__ */ jsxs(CardFooter, { className: "flex justify-end", children: [
49
- /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `${curdSlugPath}/${item.id}`, children: "Show" }),
47
+ /* @__PURE__ */ jsx(MtLink, { variant: "ghost", href: `${listView.slugPath}/${item.id}`, children: "Show" }),
50
48
  /* @__PURE__ */ jsx(PostCardItemActions, { id: item.id })
51
49
  ] })
52
50
  ]
@@ -55,15 +53,12 @@ const PostCardListItem = (props) => {
55
53
  };
56
54
  const PostCardItemActions = (props) => {
57
55
  const { id } = props;
58
- const [curdSlugPath] = useAtom(curdSlugPathAtom);
59
- const [deleteMethod] = useAtom(removeMethodSigAtom);
60
- const [openRemovePanel, setOpenRemovePanel] = useAtom(openRemovePanelAtom);
61
- const [openCreatePanel, setOpenCreatePanel] = useAtom(openCreatePanelAtom);
56
+ const listView = useListView();
62
57
  return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
63
58
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
64
59
  MtLink,
65
60
  {
66
- href: `${curdSlugPath}/${id}`,
61
+ href: `${listView.slugPath}/${id}`,
67
62
  variant: "ghost",
68
63
  className: "data-[state=open]:bg-muted flex size-8 p-0",
69
64
  children: [
@@ -77,18 +72,18 @@ const PostCardItemActions = (props) => {
77
72
  DropdownMenuItem,
78
73
  {
79
74
  onClick: () => {
80
- setOpenCreatePanel(true);
75
+ listView.setOpenCreate(true);
81
76
  },
82
77
  children: "create"
83
78
  }
84
79
  ),
85
- /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/create`, children: "create" }),
86
- /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/edit/${id}`, children: "edit" }),
80
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${listView.slugPath}/create`, children: "create" }),
81
+ /* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${listView.slugPath}/edit/${id}`, children: "edit" }),
87
82
  /* @__PURE__ */ jsx(
88
83
  DropdownMenuItem,
89
84
  {
90
85
  onClick: () => {
91
- setOpenRemovePanel(true);
86
+ listView.setOpenRemove(true);
92
87
  },
93
88
  children: "remove"
94
89
  }
@@ -11,6 +11,9 @@ export declare const LzDebugLayout: import("react").ComponentType<{
11
11
  export declare const LzFrontLayout: import("react").ComponentType<{
12
12
  children?: import("react").ReactNode;
13
13
  }>;
14
+ export declare const LzHelloLazyLayout: import("react").ComponentType<{
15
+ children?: import("react").ReactNode;
16
+ }>;
14
17
  export declare const layoutNameAtom: import("jotai").WritableAtom<string, [value: string], void>;
15
18
  export declare const LayoutBase: (props: {
16
19
  layoutName?: string;
@@ -2,7 +2,6 @@
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
4
4
  import { atom, useAtom } from "jotai";
5
- import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
6
5
  import { TailwindIndicator } from "mtxuilib/common/tailwind-indicator";
7
6
  import { AppMetaRender } from "mtxuilib/store/AppMetaRender";
8
7
  import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
@@ -13,7 +12,8 @@ import dynamic from "next/dynamic";
13
12
  import { Suspense } from "react";
14
13
  import { useHotkeys } from "react-hotkeys-hook";
15
14
  import { Toaster } from "sonner";
16
- import { DebugLayout } from "./debug-layout";
15
+ import { Demo1Layout } from "./demo-layout";
16
+ import { FrontLayout } from "./front-layout";
17
17
  const ALL_Layouts = [
18
18
  "demo1",
19
19
  "dash5",
@@ -33,6 +33,9 @@ const LzDebugLayout = dynamic(() => import("./debug-layout").then((x) => x.Debug
33
33
  const LzFrontLayout = dynamic(() => import("./front-layout").then((x) => x.FrontLayout), {
34
34
  ssr: true
35
35
  });
36
+ const LzHelloLazyLayout = dynamic(() => import("./Lazy").then((x) => x.HelloLazyLayout), {
37
+ ssr: true
38
+ });
36
39
  const layoutNameValueAtom = atom("");
37
40
  const layoutNameAtom = atom((get) => {
38
41
  return get(layoutNameValueAtom);
@@ -42,36 +45,26 @@ const layoutNameAtom = atom((get) => {
42
45
  const openLayoutSwitchDlgAtom = atom(false);
43
46
  const LayoutBase = (props) => {
44
47
  const { layoutName, children } = props;
45
- return /* @__PURE__ */ jsx(ScopeAtomsHydrator, { atomValues: [
46
- [layoutNameAtom, layoutName],
47
- [openLayoutSwitchDlgAtom, false]
48
- ], children: /* @__PURE__ */ jsx(LayoutRender, { children }) });
49
- };
50
- const LayoutRender = (props) => {
51
- const { children } = props;
52
- const [layoutName, setLayoutName] = useAtom(layoutNameAtom);
53
- return /* @__PURE__ */ jsxs(Fragment, { children: [
54
- /* @__PURE__ */ jsxs(TooltipProvider, { delayDuration: 0, children: [
55
- /* @__PURE__ */ jsx("div", { children: layoutName }),
56
- /* @__PURE__ */ jsx("div", {}),
57
- /* @__PURE__ */ jsx(DebugLayout, {}),
58
- /* @__PURE__ */ jsx(LzDebugLayout, { children }),
59
- /* @__PURE__ */ jsx(
60
- ProgressBar,
61
- {
62
- height: "4px",
63
- color: "#4934eb",
64
- options: { showSpinner: false },
65
- shallowRouting: true
66
- }
67
- ),
68
- /* @__PURE__ */ jsx(ReactQueryDevtools, {}),
69
- /* @__PURE__ */ jsx(Toaster, {}),
70
- /* @__PURE__ */ jsx(TailwindIndicator, {})
71
- ] }),
48
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(TooltipProvider, { delayDuration: 0, children: [
49
+ layoutName == "front" ? /* @__PURE__ */ jsx(FrontLayout, { children }) : layoutName == "dash5" ? /* @__PURE__ */ jsx(LzDash5, { children }) : layoutName == "debug" ? /* @__PURE__ */ jsx(LzDebugLayout, { children }) : (
50
+ // layoutName == "demo1" ? <LzDemo>{children}</LzDemo> :
51
+ layoutName == "demo1" ? /* @__PURE__ */ jsx(Demo1Layout, { children }) : layoutName == "default" ? /* @__PURE__ */ jsx(Fragment, { children }) : children
52
+ ),
53
+ /* @__PURE__ */ jsx(
54
+ ProgressBar,
55
+ {
56
+ height: "4px",
57
+ color: "#4934eb",
58
+ options: { showSpinner: false },
59
+ shallowRouting: true
60
+ }
61
+ ),
62
+ /* @__PURE__ */ jsx(ReactQueryDevtools, {}),
63
+ /* @__PURE__ */ jsx(Toaster, {}),
64
+ /* @__PURE__ */ jsx(TailwindIndicator, {}),
72
65
  /* @__PURE__ */ jsx(AppMetaRender, {}),
73
66
  /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(LayoutSwitchDlg, {}) })
74
- ] });
67
+ ] }) }) });
75
68
  };
76
69
  const LayoutSwitchDlg = () => {
77
70
  const [openLayoutSwitchDlg, setOpenLayoutSwitchDlg] = useAtom(openLayoutSwitchDlgAtom);
@@ -98,5 +91,6 @@ export {
98
91
  LzDebugLayout,
99
92
  LzDemo,
100
93
  LzFrontLayout,
94
+ LzHelloLazyLayout,
101
95
  layoutNameAtom
102
96
  };
@@ -0,0 +1,2 @@
1
+ import { PropsWithChildren } from "react";
2
+ export declare const HelloLazyLayout: (props: PropsWithChildren) => import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ const HelloLazyLayout = (props) => {
4
+ const { children } = props;
5
+ return /* @__PURE__ */ jsxs("div", { children: [
6
+ /* @__PURE__ */ jsx("h1", { children: "HelloLazyLayout" }),
7
+ children
8
+ ] });
9
+ };
10
+ export {
11
+ HelloLazyLayout
12
+ };
@@ -1,8 +1,11 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  const DebugLayout = (props) => {
4
4
  const { children } = props;
5
- return /* @__PURE__ */ jsx("div", { className: "border bg-slate-200 p-2", children });
5
+ return /* @__PURE__ */ jsxs("div", { className: "border bg-slate-200 p-2", children: [
6
+ /* @__PURE__ */ jsx("h1", { children: "debug" }),
7
+ children
8
+ ] });
6
9
  };
7
10
  export {
8
11
  DebugLayout