diff --git a/comps/custom/Detail.tsx b/comps/custom/Detail.tsx index a9b20ea..cc41759 100755 --- a/comps/custom/Detail.tsx +++ b/comps/custom/Detail.tsx @@ -3,6 +3,7 @@ import { cx } from "class-variance-authority"; import { ArrowRight } from "lucide-react"; import { FC, useEffect } from "react"; import { Skeleton } from "../ui/skeleton"; +import { formatName } from "lib/gen/utils"; export const Detail: FC<{ detail: ( @@ -15,7 +16,7 @@ export const Detail: FC<{ bind: (fn: (on_load: any) => void) => void; }) => Promise); mode: "standard" | "compact" | "inline"; -}> = ({ detail, mode, on_load }) => { +}> = ({ detail: _detail, mode, on_load }) => { const local = useLocal({ status: "init" as "init" | "loading" | "ready", detail: null as any, @@ -25,6 +26,20 @@ export const Detail: FC<{ bound: false, }); + let detail: any = _detail; + if (typeof detail !== "function") { + detail = (load: any) => { + const result: any = {}; + if (typeof load === "object" && !!load) { + for (const [k, v] of Object.entries(load)) { + if (k !== "id") + if (typeof v !== "object") result[k] = [formatName(k), v]; + } + } + return result; + }; + } + if (!isEditor) { if ( location.pathname !== local.pathname || @@ -89,7 +104,11 @@ export const Detail: FC<{ if (!isEditor) { values = local.detail || {}; } else { - values = detail(null); + if (typeof on_load === "function") { + values = detail(on_load({} as any)); + } else { + values = detail(on_load); + } local.status = "ready"; } diff --git a/comps/form/field/Field.tsx b/comps/form/field/Field.tsx index 7e02195..52b06d5 100755 --- a/comps/form/field/Field.tsx +++ b/comps/form/field/Field.tsx @@ -13,16 +13,18 @@ const prepForSum = (obj: any): any => { return obj.map((e) => prepForSum(e)); } const new_obj: any = {}; - for (const [k, v] of Object.entries(obj) as any) { - if (typeof v === "object" && v.id) { - new_obj[k] = v.id; - continue; + if (obj) { + for (const [k, v] of Object.entries(obj) as any) { + if (typeof v === "object" && v.id) { + new_obj[k] = v.id; + continue; + } + if (typeof v === "object" && v.connect.id) { + new_obj[k] = v.connect.id; + continue; + } + new_obj[k] = v; } - if (typeof v === "object" && v.connect.id) { - new_obj[k] = v.connect.id; - continue; - } - new_obj[k] = v; } return new_obj; }; diff --git a/comps/form/field/type/KeyValue.tsx b/comps/form/field/type/KeyValue.tsx index 09d35cb..34125f1 100755 --- a/comps/form/field/type/KeyValue.tsx +++ b/comps/form/field/type/KeyValue.tsx @@ -1,4 +1,3 @@ -import { update } from "autosize"; import { useLocal } from "lib/utils/use-local"; import { useEffect, useRef } from "react"; diff --git a/comps/md/parts/MDMaster.tsx b/comps/md/parts/MDMaster.tsx index de19b9f..5f0e39d 100755 --- a/comps/md/parts/MDMaster.tsx +++ b/comps/md/parts/MDMaster.tsx @@ -33,10 +33,10 @@ export const MDRenderMaster: FC<{ size: width, min_size: min_width, }); - if (md.panel) { - md.panel.min_size = min_width; - md.panel.size = width; - } + // if (md.panel) { + // md.panel.min_size = min_width; + // md.panel.size = width; + // } } }, Object.values(md.deps || {}) || []); diff --git a/exports.tsx b/exports.tsx index ebcadf2..f1a5179 100755 --- a/exports.tsx +++ b/exports.tsx @@ -6,7 +6,7 @@ import { lazify, lazifyMany } from "@/utils/lazify"; import __get from "lodash.get"; import { sum } from "./utils/sum"; -export const _sum = sum; +export const _sum = sum; export const _get = __get; export const Accordion = lazify( @@ -19,9 +19,11 @@ export const Popover = lazify( export const Progress = lazify( async () => (await import("@/comps/ui/progress")).Progress ); + export const Dialog = lazify( async () => (await import("@/comps/ui/dialog")).Dialog ); + export const Typeahead = lazify( async () => (await import("@/comps/ui/typeahead")).Typeahead ); diff --git a/utils/format-value.tsx b/utils/format-value.tsx index 517954e..ec60443 100755 --- a/utils/format-value.tsx +++ b/utils/format-value.tsx @@ -171,9 +171,14 @@ export const FormatValue: FC<{ ); } + let _value = value; + if (typeof value === 'string' && value.startsWith('BigInt::')) { + _value = value.substring('BigInt::'.length) + } + return (
-
{value}
+
{_value}
); };