From 4a8383da73a7aa33babfc530c11c4caa60f38456 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 Date: Mon, 17 Mar 2025 11:11:30 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=EB=9D=BC=EC=9D=B8=EC=B0=A8=ED=8A=B8=20?= =?UTF-8?q?=EB=9D=BC=EC=9D=B8=EB=8D=B0=EC=9D=B4=ED=84=B0=EA=B0=80=20?= =?UTF-8?q?=EC=97=AC=EB=9F=AC=EA=B0=9C=EC=9D=BC=20=EA=B2=BD=EC=9A=B0?= =?UTF-8?q?=EC=97=90=20=EC=97=AC=EB=9F=AC=EA=B0=9C=EC=9D=98=20=EB=9D=BC?= =?UTF-8?q?=EC=9D=B8=EA=B7=B8=EB=9E=98=ED=94=84=EA=B0=80=20=EA=B7=B8?= =?UTF-8?q?=EB=A0=A4=EC=A7=80=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/chart/LineChart.tsx | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/common/business_components/src/ui/chart/LineChart.tsx b/packages/common/business_components/src/ui/chart/LineChart.tsx index e68459bf0..136034e00 100644 --- a/packages/common/business_components/src/ui/chart/LineChart.tsx +++ b/packages/common/business_components/src/ui/chart/LineChart.tsx @@ -76,7 +76,24 @@ const CustomLegend = (props: any) => { ); }; -export default function Linechart(props: { chartConfig: ChartConfig; chartData: any[] | undefined; chartTitle:string}) { +type DataType = {label : string; val:number}; +type ChartDataType = { + chartData1: DataType[]; + chartData2: DataType[]; +}; + +export default function Linechart(props: { chartConfig: ChartConfig; chartData: ChartDataType; chartTitle:string}) { + const mergedData = Object.values(props.chartData).reduce((acc, dataset) => { + dataset.forEach((entry, index) => { + if (!acc[index]) { + acc[index] = { label: entry.label }; // label 추가 + } + const key = Object.keys(props.chartData).find(k => props.chartData[k] === dataset); + if (key) acc[index][key] = entry.val; + }); + return acc; + }, [] as any[]); + return ( @@ -86,13 +103,15 @@ export default function Linechart(props: { chartConfig: ChartConfig; chartData: ): null}
- - + + } /> - + {Object.keys(props.chartData).map((key, index) => ( + + ))}
From e2c80a95301151fd9d6b58bf619460bd93e36031 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Mon, 17 Mar 2025 14:01:39 +0900 Subject: [PATCH 2/3] =?UTF-8?q?form.md=20=EC=83=9D=EC=84=B1=20=EB=B0=8F=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/business_components/src/form.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 packages/common/business_components/src/form.md diff --git a/packages/common/business_components/src/form.md b/packages/common/business_components/src/form.md new file mode 100644 index 000000000..4e9b786cf --- /dev/null +++ b/packages/common/business_components/src/form.md @@ -0,0 +1,93 @@ +## form 모듈 + +### 공통 모듈 중 chart를 다양한 테마로 적용시킬 수 있도록 해주는 모듈 + +  1. 폼 모듈 사용법 + +    1-1) 패키지 사용법 + +      (1) zod 사용법 +https://zod.dev/?id=introduction + +    1-2) 호출방법 + +      (1) form에 필요한 Form,FormField,useForm useForm,z, zodResolver import + +```js +import { + Form, + FormField, + SelectBox, +} from "@common/business_components/ui"; +import { Input } from "@common/components/ui"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useForm } from "react-hook-form"; +import { z } from "zod"; +import { FormUi } from "@common/business_components"; +``` + +      (2)zod 정의 + +```js +const formSchema = z.object({ + facilityName: z.string().min(2).max(50), + instlCmptnDt:z.string(), // FormField 내 name의 타입및 min max 구성 가능 + +}); + + +const form = useForm>({ + resolver: zodResolver(formSchema), + //초기값 세팅 z.object에 등록한 값은 반드시 세팅해야함. + defaultValues: { + facilityName :'', + instlCmptnDt:'', // + + }, + }); + + function onSubmit(values: z.infer) { + // form submit 함수 + console.log(values);// zod.object에 등록하고 form에 구현한 값이 출력됨. + } + + + +``` + +      (3) form구성 + +```js +
+ +
+ ( + + // zod에 등록된 name 값의 폼 객체 생성 + //select box 삽입시 + + + + )} + /> +
+
+ ( + + // zod에 등록된 name 값의 폼 객체 생성 + //input 삽입시 + + + + )} + /> +
+
+ +``` From 4e869b2c70780fe4d1f1d323c6185f08f0989282 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 Date: Mon, 17 Mar 2025 17:45:57 +0900 Subject: [PATCH 3/3] =?UTF-8?q?TABLE=EC=97=90=EC=84=9C=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=ED=85=9C=20=EC=84=A0=ED=83=9D=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/business_components/src/ui/table/index.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/common/business_components/src/ui/table/index.tsx b/packages/common/business_components/src/ui/table/index.tsx index c96cabe7c..cbb37b273 100644 --- a/packages/common/business_components/src/ui/table/index.tsx +++ b/packages/common/business_components/src/ui/table/index.tsx @@ -1,7 +1,6 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@common/components"; import UiPageNations from "./uiPageNations"; - type UiTableProps = { headName: React.ReactNode | undefined; tableData: { [key: string]: string | number | boolean }[]; @@ -9,14 +8,15 @@ type UiTableProps = { pageSize: number; total: number; children: React.ReactNode | undefined; + cellClick : (index:number)=>void | undefined; } type UiHeadProps = { id: string; title: string; - } -export function UiTable({ tableData, headlist, pageSize, total, children, headName }: UiTableProps) { + +export function UiTable({ tableData, headlist, pageSize, total, children, headName, cellClick }: UiTableProps) { const cur = 1; return ( @@ -35,13 +35,11 @@ export function UiTable({ tableData, headlist, pageSize, total, children, headNa {tableData?.map((el: { [key: string]: string | number | boolean }, index) => ( {headlist.map((head) => ( - {el[head.id]} + cellClick(index)} key={head.id + index}>{el[head.id]} ))} - ))} - {total <= 0 ? <> : }