From 523c932541f778cf0f44e7f7bb68ca73e17544c6 Mon Sep 17 00:00:00 2001 From: rizrmd Date: Wed, 7 Feb 2024 09:17:38 -0700 Subject: [PATCH] wip fix --- .gitignore | 0 comps/custom/Card.tsx | 24 +++++----- comps/custom/Detail.tsx | 85 +++++++++++++++++++++++---------- comps/custom/Tab.tsx | 32 +++++++++---- comps/form/Field.tsx | 3 +- comps/form/InputMoney/index.tsx | 4 +- comps/form/Slider/types.ts | 0 comps/ui/button.tsx | 2 +- comps/ui/slider.tsx | 0 exports.tsx | 0 utils/date.ts | 0 utils/globals.d.ts | 1 - utils/init.ts | 2 +- 13 files changed, 103 insertions(+), 50 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 comps/form/Slider/types.ts mode change 100644 => 100755 comps/ui/slider.tsx mode change 100644 => 100755 exports.tsx mode change 100644 => 100755 utils/date.ts diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/comps/custom/Card.tsx b/comps/custom/Card.tsx index 8fb15b6..1b4ec61 100755 --- a/comps/custom/Card.tsx +++ b/comps/custom/Card.tsx @@ -71,7 +71,7 @@ export const Card: FC<{ } return ( - +
{!!title && (title.left || title.right) && (
@@ -81,16 +81,18 @@ export const Card: FC<{ )}
)} - - {local.status_value === "ready" ? ( - formatObject(local.value) - ) : ( -
- - -
- )} -
+ {!!value && ( + + {local.status_value === "ready" ? ( + formatObject(local.value) + ) : ( +
+ + +
+ )} +
+ )} {local.status_desc === "ready" ? ( formatObject(local.desc) diff --git a/comps/custom/Detail.tsx b/comps/custom/Detail.tsx index d2286d6..d097822 100755 --- a/comps/custom/Detail.tsx +++ b/comps/custom/Detail.tsx @@ -2,6 +2,8 @@ import { useLocal } from "@/utils/use-local"; import { cx } from "class-variance-authority"; import { FC, useEffect } from "react"; import { Skeleton } from "../ui/skeleton"; +import { ArrowRight, ArrowRightCircle, ChevronRight } from "lucide-react"; +import { IconRight } from "react-day-picker"; export const Detail: FC<{ detail: (item: any) => Record; @@ -70,10 +72,15 @@ export const Detail: FC<{ if (mode === "standard") { return ( -
+
{label}
- +
); @@ -81,13 +88,29 @@ export const Detail: FC<{ return (
{label}
-
- +
+
+ +
); @@ -103,7 +126,12 @@ export const Detail: FC<{ >
{label}
- +
); @@ -116,8 +144,9 @@ export const Detail: FC<{ const Linkable: FC<{ sample?: string; link?: string; + mode: "standard" | "compact" | "inline"; status: "init" | "loading" | "ready"; -}> = ({ sample, link, status }) => { +}> = ({ sample, link, status, mode }) => { const loading = ( { if (!isEditor) { navigate(link); @@ -150,11 +185,11 @@ const Linkable: FC<{ "c-flex-1", css` line-height: 1.1; - padding: 5px 0px; + padding: 3px 0px; ` )} > - {sample || '-'} + {sample || "-"}
) : ( @@ -171,21 +206,23 @@ const Linkable: FC<{ {loading}
)} - - - + + ); }; diff --git a/comps/custom/Tab.tsx b/comps/custom/Tab.tsx index a26ecb7..6462287 100755 --- a/comps/custom/Tab.tsx +++ b/comps/custom/Tab.tsx @@ -18,11 +18,14 @@ export const Tab: FC<{ }> = ({ tabs, active, body, PassProp, on_load }) => { const local = useLocal( { - active, + activeIndex: active, count: [] as (number | string)[], + mode: "number" as "number" | "hash", status: "init" as "init" | "load" | "ready", }, () => { + if (local.mode === "hash") { + } if (local.status === "init") { if (typeof on_load === "function" && !isEditor) { local.status = "load"; @@ -46,14 +49,25 @@ export const Tab: FC<{ const all_tabs = tabs({ count: local.count || [] }); - if (!parseInt(local.active)) { - local.active = "0"; + if (local.activeIndex === "#") { + local.mode = "hash"; + } + + if (!parseInt(local.activeIndex)) { + if (local.mode === "hash") { + local.activeIndex = location.hash.substring(1); + if (!parseInt(local.activeIndex)) { + local.activeIndex = "0"; + } + } else { + local.activeIndex = "0"; + } } return (
{ - local.active = idx.toString(); + local.activeIndex = idx.toString(); local.render(); if (e.navigate) { navigate(e.navigate); @@ -108,7 +122,7 @@ export const Tab: FC<{ "c-p-1 c-h-10 c-flex c-items-center", e.width ? "" : " c-flex-1 ", e.count ? " c-justify-between" : "", - local.active === idx.toString() + local.activeIndex === idx.toString() ? css` border-bottom: 2px solid ${e.color ? e.color : "#3c82f6"}; @@ -116,7 +130,9 @@ export const Tab: FC<{ : "border-b-transparent" )} > -
{e.label}
+
+ {e.label} +
{has_count && (
- {body} + {body}
); diff --git a/comps/form/Field.tsx b/comps/form/Field.tsx index 71a186a..d0f94d4 100755 --- a/comps/form/Field.tsx +++ b/comps/form/Field.tsx @@ -83,6 +83,7 @@ export const Field: FC<{ local.render(); (async () => { const res = await slider_options(); + local.slider.opt = res; local.render(); })(); @@ -144,7 +145,7 @@ export const Field: FC<{ min={local.slider.opt.min.value} max={local.slider.opt.max.value} /> -
+
{local.slider.value}
diff --git a/comps/form/InputMoney/index.tsx b/comps/form/InputMoney/index.tsx index 429321e..98fe564 100755 --- a/comps/form/InputMoney/index.tsx +++ b/comps/form/InputMoney/index.tsx @@ -44,13 +44,11 @@ export const InputMoney: FC<{ }; export const formatMoney = (num: any) => { - // add comma if (!!num) { let str = num; if (typeof num === "number") str = num.toString(); if (typeof str === "string") return str.replace(/\B(?=(\d{3})+(?!\d))/g, "."); - - return ""; } + return "-"; }; diff --git a/comps/form/Slider/types.ts b/comps/form/Slider/types.ts old mode 100644 new mode 100755 diff --git a/comps/ui/button.tsx b/comps/ui/button.tsx index 543aee4..29db581 100755 --- a/comps/ui/button.tsx +++ b/comps/ui/button.tsx @@ -46,7 +46,7 @@ const Button = React.forwardRef(