257 lines
6.0 KiB
Markdown
257 lines
6.0 KiB
Markdown
# KRI UI Registry
|
|
|
|
KRI 공통 shadcn UI Registry 프로젝트입니다. `npm run build`로 생성되는 `dist/r` 정적 JSON 파일을 IIS 또는 Nginx에 배포해서 사용합니다.
|
|
|
|
## 빌드 및 검증
|
|
|
|
```powershell
|
|
npm ci
|
|
npm run build
|
|
npm run verify
|
|
npm run preview
|
|
```
|
|
|
|
배포 Registry 주소:
|
|
|
|
```text
|
|
https://ui-registry.kric.com/r/registry.json
|
|
```
|
|
|
|
로컬 preview 주소 (`npm run preview` 실행 후):
|
|
|
|
```text
|
|
http://localhost:4100/r/registry.json
|
|
```
|
|
|
|
## Registry 항목
|
|
|
|
```text
|
|
kri-chart
|
|
kri-select
|
|
kri-date-range-picker
|
|
kri-date-picker
|
|
kri-date-time-picker
|
|
kri-time-picker
|
|
kri-password
|
|
kri-auto-complete
|
|
kri-data-table
|
|
kri-loading-overlay
|
|
kri-editor
|
|
kri-layout
|
|
kri-dialog
|
|
```
|
|
|
|
`kri-data-table`은 TanStack Table v8 API를 사용하며 `@tanstack/react-table@^8.21.3` 범위를 지원합니다. KriUiRegistry에서 별도의 마이그레이션 버전을 제공하기 전에는 v9으로 올리지 않습니다.
|
|
|
|
개별 설치 예시:
|
|
|
|
```powershell
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-chart.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-select.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-password.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-date-range-picker.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-date-picker.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-date-time-picker.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-time-picker.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-auto-complete.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-data-table.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-loading-overlay.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-editor.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-layout.json
|
|
npx shadcn@latest add https://ui-registry.kric.com/r/kri-dialog.json
|
|
```
|
|
|
|
## KRI Chart
|
|
|
|
`kri-chart`는 `echarts`, `echarts-for-react` 기반 공통 차트 컴포넌트입니다. 내부적으로 `BaseEChart`를 사용하며, 모든 wrapper는 멀티 시리즈를 지원합니다.
|
|
|
|
제공 컴포넌트:
|
|
|
|
```ts
|
|
BaseEChart
|
|
KriLineChart
|
|
KriBarChart
|
|
KriStackedBarChart
|
|
KriPieChart
|
|
KriRadarChart
|
|
KriScatterChart
|
|
```
|
|
|
|
### Line
|
|
|
|
```tsx
|
|
import { KriLineChart } from '@/components/chart'
|
|
|
|
<KriLineChart
|
|
categories={['1월', '2월', '3월']}
|
|
series={[
|
|
{ name: '매출', data: [120, 180, 160] },
|
|
{ name: '영업이익', data: [30, 42, 38] },
|
|
]}
|
|
smooth
|
|
/>
|
|
```
|
|
|
|
### Bar / Horizontal Bar
|
|
|
|
```tsx
|
|
import { KriBarChart } from '@/components/chart'
|
|
|
|
<KriBarChart
|
|
categories={['A', 'B', 'C']}
|
|
series={[
|
|
{ name: '2025', data: [10, 20, 30] },
|
|
{ name: '2026', data: [15, 18, 35] },
|
|
]}
|
|
isHorizontal
|
|
/>
|
|
```
|
|
|
|
### Stacked Bar
|
|
|
|
```tsx
|
|
import { KriStackedBarChart } from '@/components/chart'
|
|
|
|
<KriStackedBarChart
|
|
categories={['A', 'B', 'C']}
|
|
series={[
|
|
{ name: '직접', data: [10, 20, 30] },
|
|
{ name: '간접', data: [5, 12, 18] },
|
|
]}
|
|
/>
|
|
```
|
|
|
|
### Pie
|
|
|
|
```tsx
|
|
import { KriPieChart } from '@/components/chart'
|
|
|
|
<KriPieChart
|
|
series={[
|
|
{
|
|
name: '접속 경로',
|
|
data: [
|
|
{ name: '검색', value: 45 },
|
|
{ name: '광고', value: 25 },
|
|
{ name: '직접', value: 30 },
|
|
],
|
|
},
|
|
]}
|
|
/>
|
|
```
|
|
|
|
### Radar
|
|
|
|
```tsx
|
|
import { KriRadarChart } from '@/components/chart'
|
|
|
|
<KriRadarChart
|
|
indicators={[
|
|
{ name: '품질', max: 100 },
|
|
{ name: '속도', max: 100 },
|
|
{ name: '안정성', max: 100 },
|
|
]}
|
|
series={[
|
|
{ name: '서비스 A', data: [90, 80, 85] },
|
|
{ name: '서비스 B', data: [70, 95, 78] },
|
|
]}
|
|
/>
|
|
```
|
|
|
|
### Scatter
|
|
|
|
```tsx
|
|
import { KriScatterChart } from '@/components/chart'
|
|
|
|
<KriScatterChart
|
|
series={[
|
|
{
|
|
name: '분포',
|
|
data: [
|
|
[10, 20],
|
|
[15, 35],
|
|
[25, 30],
|
|
],
|
|
},
|
|
]}
|
|
/>
|
|
```
|
|
|
|
공통 props:
|
|
|
|
- `height`: 차트 wrapper 높이, 기본값 `CHART_HEIGHTS.DEFAULT`
|
|
- `className`, `contentClassName`, `chartClassName`: wrapper className
|
|
- `notMerge`, `lazyUpdate`, `onEvents`: `echarts-for-react` 전달 옵션
|
|
- `option`: wrapper가 생성한 ECharts option을 덮어쓰는 override 옵션
|
|
- `normalizeValues`, `decimalPlaces`: 숫자 데이터 반올림 정규화 옵션
|
|
|
|
## KriDialog Footer 규칙
|
|
|
|
기본값은 닫기 버튼이 있는 Footer입니다.
|
|
|
|
```tsx
|
|
<KriDialog open={open} onOpenChange={setOpen} title="사용자 등록">
|
|
{/* Body */}
|
|
</KriDialog>
|
|
```
|
|
|
|
기본 Footer를 제거합니다.
|
|
|
|
```tsx
|
|
<KriDialog
|
|
open={open}
|
|
onOpenChange={setOpen}
|
|
title="사용자 등록"
|
|
showDefaultFooter={false}
|
|
>
|
|
{/* Body */}
|
|
</KriDialog>
|
|
```
|
|
|
|
사용자 정의 Footer를 전달합니다. `footer`가 지정되면 기본 Footer보다 우선합니다.
|
|
|
|
```tsx
|
|
<KriDialog
|
|
open={open}
|
|
onOpenChange={setOpen}
|
|
title="사용자 등록"
|
|
footer={
|
|
<>
|
|
<Button variant="outline" onClick={() => setOpen(false)}>취소</Button>
|
|
<Button onClick={handleSave}>저장</Button>
|
|
</>
|
|
}
|
|
>
|
|
{/* Body */}
|
|
</KriDialog>
|
|
```
|
|
|
|
`footer={null}`을 전달해도 Footer가 표시되지 않습니다.
|
|
|
|
## Editor 주요 옵션
|
|
|
|
```tsx
|
|
<KriEditor
|
|
mode="both"
|
|
value={html}
|
|
onChange={setHtml}
|
|
onImageUpload={async (file) => upload(file)}
|
|
enableImageMap
|
|
htmlSanitizer={sanitizeForServerPolicy}
|
|
getWysiwygCompatibility={checkWysiwygCompatibility}
|
|
smsMaxBytes={90}
|
|
lmsMaxBytes={2000}
|
|
smsPreviewSuffix={verificationNotice}
|
|
toolbar={{ image: true, table: false, html: true }}
|
|
/>
|
|
```
|
|
|
|
- 편집 값은 HTML 문자열입니다.
|
|
- 이미지 업로드 함수는 URL 문자열 또는 `{ url }`을 반환할 수 있습니다.
|
|
- `toolbar={false}`로 toolbar 전체를 숨길 수 있습니다.
|
|
- SMS/LMS 기본 제한은 각각 90/2,000바이트입니다.
|
|
- `enableImageMap`은 `map`, `area`, `img.usemap` 보존을 선택적으로 활성화합니다.
|
|
- `htmlSanitizer`로 서비스의 서버 정책에 맞는 정제 함수를 주입할 수 있습니다.
|
|
- `getWysiwygCompatibility`가 `compatible: false`를 반환하면 HTML 원문을 유지하고 WYSIWYG 전환을 비활성화합니다.
|
|
- `smsPreviewSuffix`는 저장 본문에는 포함하지 않고 SMS 미리보기와 바이트 계산에만 반영합니다.
|