From 051bc65e4ed427ee329788a685cae3fd97062a63 Mon Sep 17 00:00:00 2001 From: rizrmd Date: Fri, 24 May 2024 10:48:11 -0700 Subject: [PATCH] fix lib --- comps/md/gen/md-gen.ts | 2 +- comps/md/mode/full.tsx | 10 +++--- comps/md/mode/h-split.tsx | 8 ++--- comps/md/mode/v-split.tsx | 8 ++--- comps/md/parts/{MDTab.tsx => MDDetail.tsx} | 6 ++-- comps/md/parts/MDMaster.tsx | 40 ++++++++++++---------- data.ts | 33 +++++++++--------- 7 files changed, 54 insertions(+), 53 deletions(-) rename comps/md/parts/{MDTab.tsx => MDDetail.tsx} (93%) diff --git a/comps/md/gen/md-gen.ts b/comps/md/gen/md-gen.ts index 57277a4..c3a9735 100755 --- a/comps/md/gen/md-gen.ts +++ b/comps/md/gen/md-gen.ts @@ -6,7 +6,7 @@ export const generateMasterDetail = async (item: PrasiItem) => { ); if (master) { - master.edit.setProp("on_load", { + master.edit.setProp("on_init", { mode: "raw", value: `async (text: string) => { alert("ASdas"); diff --git a/comps/md/mode/full.tsx b/comps/md/mode/full.tsx index bfe0298..41de5d6 100755 --- a/comps/md/mode/full.tsx +++ b/comps/md/mode/full.tsx @@ -1,17 +1,17 @@ import { FC } from "react"; -import { MDMain } from "../parts/MDMaster"; +import { MDMaster } from "../parts/MDMaster"; import { MDLocal, MDRef } from "../utils/typings"; -import { MDTab, should_show_tab } from "../parts/MDTab"; +import { MDDetail, should_show_tab } from "../parts/MDDetail"; export const ModeFull: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { if (should_show_tab(md)) { - return ; + return ; } return ( <> - {!md.selected && } - {md.selected && } + {!md.selected && } + {md.selected && } ); }; diff --git a/comps/md/mode/h-split.tsx b/comps/md/mode/h-split.tsx index 37164e7..8f0e8ce 100755 --- a/comps/md/mode/h-split.tsx +++ b/comps/md/mode/h-split.tsx @@ -1,7 +1,7 @@ import { FC } from "react"; import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels"; -import { MDMain } from "../parts/MDMaster"; -import { MDTab } from "../parts/MDTab"; +import { MDMaster } from "../parts/MDMaster"; +import { MDDetail } from "../parts/MDDetail"; import { MDLocal, MDRef } from "../utils/typings"; export const ModeHSplit: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { @@ -13,7 +13,7 @@ export const ModeHSplit: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { defaultSize={md.panel.size} minSize={md.panel.min_size} > - + <> @@ -29,7 +29,7 @@ export const ModeHSplit: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { } }} > - + diff --git a/comps/md/mode/v-split.tsx b/comps/md/mode/v-split.tsx index 4fe12dd..d16a484 100755 --- a/comps/md/mode/v-split.tsx +++ b/comps/md/mode/v-split.tsx @@ -1,7 +1,7 @@ import { FC } from "react"; -import { MDMain } from "../parts/MDMaster"; +import { MDMaster } from "../parts/MDMaster"; import { MDLocal, MDRef } from "../utils/typings"; -import { MDTab, should_show_tab } from "../parts/MDTab"; +import { MDDetail, should_show_tab } from "../parts/MDDetail"; import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels"; export const ModeVSplit: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { @@ -13,7 +13,7 @@ export const ModeVSplit: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { defaultSize={md.panel.size} minSize={md.panel.min_size} > - + <> @@ -29,7 +29,7 @@ export const ModeVSplit: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { } }} > - + diff --git a/comps/md/parts/MDTab.tsx b/comps/md/parts/MDDetail.tsx similarity index 93% rename from comps/md/parts/MDTab.tsx rename to comps/md/parts/MDDetail.tsx index a1b2cab..08d4e24 100755 --- a/comps/md/parts/MDTab.tsx +++ b/comps/md/parts/MDDetail.tsx @@ -1,5 +1,5 @@ import { FC } from "react"; -import { MDLocal, MDRef, w } from "../utils/typings"; +import { MDLocal, MDRef } from "../utils/typings"; import { MDHeader } from "./MDHeader"; export const should_show_tab = (md: MDLocal) => { @@ -9,7 +9,7 @@ export const should_show_tab = (md: MDLocal) => { return false; }; -export const MDTab: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { +export const MDDetail: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { const detail = md.childs[md.tab.active]; const PassProp = mdr.PassProp; if (!detail) { @@ -27,7 +27,7 @@ export const MDTab: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { {md.props.tab_mode !== "hidden" && md.tab.list.length > 1 && ( )} - {/* {detail.internal} */} + {mdr.childs[md.tab.active]} ); diff --git a/comps/md/parts/MDMaster.tsx b/comps/md/parts/MDMaster.tsx index 66d6b5b..e62de1b 100755 --- a/comps/md/parts/MDMaster.tsx +++ b/comps/md/parts/MDMaster.tsx @@ -5,36 +5,38 @@ import { MDHeader } from "./MDHeader"; const w = window as unknown as { md_panel_master: any; }; -export const MDMaster: FC<{ +export const MDRenderMaster: FC<{ size: any; min_size: any; - md: MDLocal; child: any; - on_init: () => void; -}> = ({ child, on_init, min_size, size, md }) => { - let result = on_init(); + on_init: () => MDLocal; +}> = ({ child, on_init, min_size, size }) => { + let md = on_init(); - let width = 0; - let min_width = 0; - try { - width = Number(size) || 0; - min_width = Number(min_size) || 0; - } catch (e: any) {} - w.md_panel_master = JSON.stringify({ - size: width, - min_size: min_width, - }); - md.panel.min_size = min_width; - md.panel.size = width; + if (md) { + let width = 0; + let min_width = 0; + try { + width = Number(size) || 0; + min_width = Number(min_size) || 0; + } catch (e: any) {} + w.md_panel_master = JSON.stringify({ + size: width, + min_size: min_width, + }); + md.panel.min_size = min_width; + md.panel.size = width; + } + return <>{child}; }; -export const MDMain: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { +export const MDMaster: FC<{ md: MDLocal; mdr: MDRef }> = ({ md, mdr }) => { const PassProp = mdr.PassProp; return ( <> {md.props.show_head === "only-master" && } - {/* {md.master.internal} */} + {mdr.master} ); }; diff --git a/data.ts b/data.ts index ca7d73d..76b50a6 100755 --- a/data.ts +++ b/data.ts @@ -4,8 +4,9 @@ import { lazify } from "./utils/lazify"; export const MasterDetail = lazify( async () => (await import("@/comps/md/MasterDetail")).MasterDetail ); -export const MDMaster = lazify( - async () => (await import("@/comps/md/parts/MDMaster")).MDMaster + +export const MDRenderMaster = lazify( + async () => (await import("@/comps/md/parts/MDMaster")).MDRenderMaster ); export const MDAction = lazify( async () => (await import("@/comps/md/parts/MDAction")).MDAction @@ -48,6 +49,7 @@ export { GetValue } from "@/utils/get-value"; export { TableListType } from "lib/comps/list/utils/typings"; export { Button, FloatButton } from "@/comps/ui/button"; export { prasi_gen } from "@/gen/prasi_gen"; +export { password } from "@/utils/password"; /** Session */ export { @@ -60,10 +62,8 @@ export { Login } from "@/preset/login/Login"; export { logout } from "@/preset/login/utils/logout"; export { generateLogin } from "@/preset/login/utils/generate"; export { select as generateSelect } from "@/preset/login/utils/select"; - -// export card -export {Card} from "@/comps/custom/Card"; +export { Card } from "@/comps/custom/Card"; /** Layout */ export { Layout } from "@/preset/menu/Layout"; @@ -71,19 +71,18 @@ export { Layout } from "@/preset/menu/Layout"; /* MENU */ export { Menu, MenuIcon } from "@/preset/menu/Menu"; -/* Bcrypt */ -export { password } from "@/utils/password"; - /*Panel Tab*/ -export {PanelTab} from "@/comps/tab/Tab"; -export {PanelBody} from "@/comps/tab/parts/PanelBody"; -export {PanelHeader} from "@/comps/tab/parts/PanelHead"; -export {ShowHidePanel} from "@/comps/custom/ShowHidePanel"; +export { PanelTab } from "@/comps/tab/Tab"; +export { PanelBody } from "@/comps/tab/parts/PanelBody"; +export { PanelHeader } from "@/comps/tab/parts/PanelHead"; +export { ShowHidePanel } from "@/comps/custom/ShowHidePanel"; + /*Popup*/ -export {Popup} from "@/comps/popup/PopUp" +export { Popup } from "@/comps/popup/PopUp"; + // Detail export { Detail } from "@/comps/custom/Detail"; -export {Profile} from "@/preset/profile/Profile" -export {generateProfile} from "@/preset/profile/utils/generate" -export {ButtonUpload} from "@/preset/profile/ButtonUpload" -export {longDate, shortDate, timeAgo, formatTime} from "@/utils/date"; \ No newline at end of file +export { Profile } from "@/preset/profile/Profile"; +export { generateProfile } from "@/preset/profile/utils/generate"; +export { ButtonUpload } from "@/preset/profile/ButtonUpload"; +export { longDate, shortDate, timeAgo, formatTime } from "@/utils/date";