@opsnow-mcp/opsnow-mcp-common-ui-server 1.0.33 → 1.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1607,6 +1607,57 @@ const handleDownload = useCallback(() => {
|
|
|
1607
1607
|
description: '팝업에서 텍스트 콘텐츠를 표시하고 RTF 파일로 다운로드하는 예제입니다. downloadInsightAsRtf 유틸리티를 사용하면 어떤 텍스트든 RTF 문서로 내보낼 수 있습니다. [검색 키워드: RTF 다운로드, 콘텐츠 내보내기, 문서 저장, 텍스트 내보내기, 리포트 다운로드]'
|
|
1608
1608
|
}
|
|
1609
1609
|
];
|
|
1610
|
+
export const CurrencySwitcherExamples = [
|
|
1611
|
+
{
|
|
1612
|
+
title: 'basic-currency-switcher',
|
|
1613
|
+
code: `const { OpsnowCommonCurrencySwitcher } = useCommonComponents()
|
|
1614
|
+
|
|
1615
|
+
const [currency, setCurrency] = useState('USD')
|
|
1616
|
+
const [appliedRate, setAppliedRate] = useState(1)
|
|
1617
|
+
|
|
1618
|
+
// BE 환율 API 응답을 그대로 주입 (컴포넌트는 API를 호출하지 않음)
|
|
1619
|
+
const rateInfo = {
|
|
1620
|
+
baseDate: '2026-07-08', // 적용 환율 기준일
|
|
1621
|
+
source: '한국수출입은행', // 출처 (선택)
|
|
1622
|
+
rates: { USD: 1, KRW: 1450, JPY: 156.58, VND: 25508, AED: 3.67 }, // 기준 통화(USD) 1단위당 환율
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
// 환율 상세 보기 차트용 월별(또는 일별) 추이 — 과거 → 현재 순, 마지막 값 = 현재 환율
|
|
1626
|
+
const history = [
|
|
1627
|
+
{ label: '25.07', rate: 1495.3 },
|
|
1628
|
+
{ label: '26.06', rate: 1462.1 },
|
|
1629
|
+
{ label: '26.07', rate: 1450 },
|
|
1630
|
+
]
|
|
1631
|
+
|
|
1632
|
+
<OpsnowCommonCurrencySwitcher
|
|
1633
|
+
value={currency}
|
|
1634
|
+
onChange={(code, rate) => {
|
|
1635
|
+
setCurrency(code)
|
|
1636
|
+
setAppliedRate(rate) // 금액 표시 변환은 소비 측에서 rate로 처리
|
|
1637
|
+
}}
|
|
1638
|
+
rateInfo={rateInfo}
|
|
1639
|
+
history={history}
|
|
1640
|
+
/>`,
|
|
1641
|
+
description: '통화 전환 드롭다운 + 환율 팝오버 기본 예제입니다. 환율 데이터는 컴포넌트가 조회하지 않으므로 BE 환율 API 응답을 rateInfo/history props로 주입합니다. [검색 키워드: 통화 전환, 환율, 환율 필터, 통화 필터, 통화 변환, currency, exchange rate]'
|
|
1642
|
+
},
|
|
1643
|
+
{
|
|
1644
|
+
title: 'custom-options-no-detail',
|
|
1645
|
+
code: `<OpsnowCommonCurrencySwitcher
|
|
1646
|
+
value={currency}
|
|
1647
|
+
onChange={handleCurrencyChange}
|
|
1648
|
+
rateInfo={rateInfo}
|
|
1649
|
+
currencyOptions={[
|
|
1650
|
+
{ code: 'USD', symbol: '$' },
|
|
1651
|
+
{ code: 'KRW', symbol: '₩', digits: 0 },
|
|
1652
|
+
{ code: 'JPY', symbol: '¥' },
|
|
1653
|
+
]}
|
|
1654
|
+
baseCurrency="USD"
|
|
1655
|
+
size="small"
|
|
1656
|
+
showDetail={false}
|
|
1657
|
+
/>`,
|
|
1658
|
+
description: '팝오버 통화 목록을 커스텀하고 환율 상세 보기 드릴다운 없이 small 크기 트리거로 사용하는 예제입니다.'
|
|
1659
|
+
}
|
|
1660
|
+
];
|
|
1610
1661
|
export const ToggleButtonExamples = [
|
|
1611
1662
|
{
|
|
1612
1663
|
title: 'large-toggle-group',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ButtonExamples, BadgeExamples, TextareaExamples, SwitchExamples, ChipExamples, TextFieldExamples, AvatarExamples, CheckboxExamples, RadioGroupExamples, CollapseExamples, SliderExamples, LinkExamples, TreeViewExamples, InsightCardExamples, InsightContentExamples, ToggleButtonExamples } from "./examples/opsnow-common-forms-examples-data.js";
|
|
1
|
+
import { ButtonExamples, BadgeExamples, TextareaExamples, SwitchExamples, ChipExamples, TextFieldExamples, AvatarExamples, CheckboxExamples, RadioGroupExamples, CollapseExamples, SliderExamples, LinkExamples, TreeViewExamples, InsightCardExamples, InsightContentExamples, CurrencySwitcherExamples, ToggleButtonExamples } from "./examples/opsnow-common-forms-examples-data.js";
|
|
2
2
|
import { IconExamples, MuiIconExamples } from "./examples/opsnow-common-icons-examples-data.js";
|
|
3
3
|
import { CalendarExamples } from "./examples/opsnow-common-calendar-examples-data.js";
|
|
4
4
|
import { GaugeChartExamples, PieChartExamples, BarChartExamples, LineChartExamples, StackChartExamples, XyMultiChartExamples, HeatmapChartExamples, BubbleChartExamples } from "./examples/opsnow-common-chart-examples-data.js";
|
|
@@ -36,6 +36,7 @@ export const EXAMPLES_MAP = {
|
|
|
36
36
|
TreeView: TreeViewExamples,
|
|
37
37
|
InsightCard: InsightCardExamples,
|
|
38
38
|
InsightContent: InsightContentExamples,
|
|
39
|
+
CurrencySwitcher: CurrencySwitcherExamples,
|
|
39
40
|
ToggleButtonGroup: ToggleButtonExamples,
|
|
40
41
|
Icon: IconExamples,
|
|
41
42
|
MuiIcon: MuiIconExamples,
|
|
@@ -290,6 +290,23 @@ export const InsightContentSchema = z.object({
|
|
|
290
290
|
emptyMessage: z.string().optional().describe("insightText가 없을 때 표시할 빈 메시지"),
|
|
291
291
|
sx: z.string().optional().describe("MUI sx 스타일 객체(JSX/문자열)"),
|
|
292
292
|
});
|
|
293
|
+
// CurrencySwitcher 컴포넌트 관련 스키마 정의 (통화 전환 드롭다운 + 환율 팝오버, opsnow-common-forms >= 1.0.19)
|
|
294
|
+
export const CurrencySwitcherSchema = z.object({
|
|
295
|
+
value: z.string().describe("현재 표시 통화 코드 상태 변수명 (controlled, 예: currency)"),
|
|
296
|
+
onChange: z.string().describe("통화 선택/직접 입력 시 호출되는 핸들러 함수명 — (currency, rate) => void 형태, rate는 기준 통화 1단위당 적용 환율 (예: handleCurrencyChange)"),
|
|
297
|
+
rateInfo: z.string().optional().describe("기준일 환율 정보 객체 변수명 — { baseDate, source?, rates } 형태로 BE 환율 API 응답을 주입 (없으면 목록에 환율이 '-'로 표시, 예: rateInfo)"),
|
|
298
|
+
history: z.string().optional().describe("환율 상세 보기 추이 차트 데이터 배열 변수명 — Array<{ label, rate }>, 과거 → 현재 순이며 마지막 값 = 현재 환율 (예: history)"),
|
|
299
|
+
currencyOptions: z.string().optional().describe("팝오버 통화 목록 배열 변수명 — Array<{ code, symbol, digits? }> (기본: USD/KRW/JPY/VND/AED)"),
|
|
300
|
+
baseCurrency: z.string().optional().describe("변환 기준 통화 코드 (기본값: 'USD')"),
|
|
301
|
+
defaultTargetCurrency: z.string().optional().describe("기준 통화 선택 중일 때 상세 보기가 다룰 초기 비교 통화 코드"),
|
|
302
|
+
customRate: z.string().optional().describe("직접 입력 시뮬레이션 환율 상태 변수명 (number | null, controlled 모드 — 미지정 시 내부 관리)"),
|
|
303
|
+
onCustomRateChange: z.string().optional().describe("직접 입력 환율 변경 핸들러 함수명 — (rate) => void 형태"),
|
|
304
|
+
showDetail: z.boolean().optional().describe("환율 상세 보기 드릴다운 노출 여부 (기본값: true)"),
|
|
305
|
+
renderChart: z.string().optional().describe("추이 차트 교체 슬롯 함수명 — (history, currency) => ReactNode 형태 (기본: 내장 SVG 스파크라인)"),
|
|
306
|
+
labels: z.string().optional().describe("문구 개별 커스텀 객체 변수명 — Partial<CurrencySwitcherLabels>, i18n(ko/en/ja) 번역 위에 항목별로 덮어씀 ({placeholder} 템플릿 치환 지원)"),
|
|
307
|
+
size: z.enum(["small", "medium"]).optional().describe("트리거 크기"),
|
|
308
|
+
disabled: z.boolean().optional().describe("비활성화 여부"),
|
|
309
|
+
});
|
|
293
310
|
// Forms 컴포넌트 함수 - 배열 반환
|
|
294
311
|
export function createFormsComponent() {
|
|
295
312
|
return [
|
|
@@ -1093,6 +1110,72 @@ export function createFormsComponent() {
|
|
|
1093
1110
|
]
|
|
1094
1111
|
};
|
|
1095
1112
|
}
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
name: "createCurrencySwitcher",
|
|
1116
|
+
description: `CurrencySwitcher 컴포넌트 - 통화 전환 드롭다운 + 환율 팝오버, 환율/통화 필터로 사용 (opsnow-common-forms >= 1.0.19)
|
|
1117
|
+
|
|
1118
|
+
트리거에 현재 선택된 통화가 표시되고, 클릭하면 팝오버에서 적용 환율 기준일 안내와
|
|
1119
|
+
통화 목록(클릭 시 즉시 적용)을 제공합니다. "환율 상세 보기" 드릴다운에서 직접 입력
|
|
1120
|
+
시뮬레이션, 현재/최고/최저/변동 스탯, 환율 추이 차트를 확인할 수 있습니다.
|
|
1121
|
+
|
|
1122
|
+
**데이터 주입 규칙 (중요):**
|
|
1123
|
+
- 환율 데이터는 컴포넌트가 조회하지 않습니다 — BE 환율 API 응답을 rateInfo / history props로 주입하세요.
|
|
1124
|
+
- rateInfo: { baseDate: 'YYYY-MM-DD', source?: '출처', rates: { USD: 1, KRW: 1450, ... } } — 기준 통화 1단위당 환율
|
|
1125
|
+
- history: [{ label: '25.07', rate: 1495.3 }, ...] — 과거 → 현재 순, 마지막 값 = 현재 환율
|
|
1126
|
+
- BE API 호출 시 axios 직접 import 금지 — getAxios() 공통 axios 사용
|
|
1127
|
+
|
|
1128
|
+
**동작 규칙:**
|
|
1129
|
+
- 선택/직접 입력 시 onChange(code, rate)가 호출됩니다 — 금액 표시 변환은 소비 프로젝트에서 rate로 처리
|
|
1130
|
+
- 직접 입력 환율은 시뮬레이션 용도이며 저장되지 않습니다
|
|
1131
|
+
- 문구는 i18n 현재 언어(ko/en/ja)를 자동으로 따르고, labels prop으로 항목별 커스텀 가능
|
|
1132
|
+
|
|
1133
|
+
**import:**
|
|
1134
|
+
\`\`\`javascript
|
|
1135
|
+
import { useCommonComponents } from '@opsnow-common/opsnow-finops-common-ui-loader';
|
|
1136
|
+
const { OpsnowCommonCurrencySwitcher } = useCommonComponents();
|
|
1137
|
+
\`\`\``,
|
|
1138
|
+
parameters: CurrencySwitcherSchema,
|
|
1139
|
+
handler: async (args) => {
|
|
1140
|
+
const props = [];
|
|
1141
|
+
if (args.value)
|
|
1142
|
+
props.push(`value={${args.value}}`);
|
|
1143
|
+
if (args.onChange)
|
|
1144
|
+
props.push(`onChange={${args.onChange}}`);
|
|
1145
|
+
if (args.rateInfo)
|
|
1146
|
+
props.push(`rateInfo={${args.rateInfo}}`);
|
|
1147
|
+
if (args.history)
|
|
1148
|
+
props.push(`history={${args.history}}`);
|
|
1149
|
+
if (args.currencyOptions)
|
|
1150
|
+
props.push(`currencyOptions={${args.currencyOptions}}`);
|
|
1151
|
+
if (args.baseCurrency)
|
|
1152
|
+
props.push(`baseCurrency="${args.baseCurrency}"`);
|
|
1153
|
+
if (args.defaultTargetCurrency)
|
|
1154
|
+
props.push(`defaultTargetCurrency="${args.defaultTargetCurrency}"`);
|
|
1155
|
+
if (args.customRate)
|
|
1156
|
+
props.push(`customRate={${args.customRate}}`);
|
|
1157
|
+
if (args.onCustomRateChange)
|
|
1158
|
+
props.push(`onCustomRateChange={${args.onCustomRateChange}}`);
|
|
1159
|
+
if (args.showDetail !== undefined)
|
|
1160
|
+
props.push(`showDetail={${args.showDetail}}`);
|
|
1161
|
+
if (args.renderChart)
|
|
1162
|
+
props.push(`renderChart={${args.renderChart}}`);
|
|
1163
|
+
if (args.labels)
|
|
1164
|
+
props.push(`labels={${args.labels}}`);
|
|
1165
|
+
if (args.size)
|
|
1166
|
+
props.push(`size="${args.size}"`);
|
|
1167
|
+
if (args.disabled)
|
|
1168
|
+
props.push(`disabled`);
|
|
1169
|
+
const code = `<OpsnowCommonCurrencySwitcher\n ${props.join('\n ')}\n/>`;
|
|
1170
|
+
return {
|
|
1171
|
+
content: [
|
|
1172
|
+
{
|
|
1173
|
+
type: "text",
|
|
1174
|
+
text: `\`\`\`jsx\n${code}\n\`\`\``
|
|
1175
|
+
}
|
|
1176
|
+
]
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1096
1179
|
}
|
|
1097
1180
|
];
|
|
1098
1181
|
}
|