@opsnow-mcp/opsnow-mcp-common-ui-server 1.0.33 → 1.0.35

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,66 @@ 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
+ const [historySeries, setHistorySeries] = useState([])
1618
+
1619
+ // BE 환율 API 응답을 그대로 주입 (컴포넌트는 API를 호출하지 않음)
1620
+ const rateInfo = {
1621
+ baseDate: '2026-07-08', // 적용 환율 기준일
1622
+ source: '한국수출입은행', // 출처 (선택)
1623
+ rates: { USD: 1, KRW: 1450, JPY: 156.58, VND: 25508, AED: 3.67 }, // 기준 통화(USD) 1단위당 대표 환율
1624
+ details: { // (선택) 통화별 Payer/Invoice 상세 환율
1625
+ KRW: [ // 2건 이상이면 '다중 환율' — 배지 · 현재 적용 환율 목록 · 히스토리 팝업
1626
+ { payer: 'Payer 1234', invoice: 'Invoice 0000', rate: 1450 },
1627
+ { payer: 'Payer 5678', invoice: 'Invoice 9999', rate: 1462 },
1628
+ ],
1629
+ },
1630
+ }
1631
+
1632
+ <OpsnowCommonCurrencySwitcher
1633
+ value={currency}
1634
+ onChange={(code, rate) => {
1635
+ setCurrency(code)
1636
+ setAppliedRate(rate) // 금액 표시 변환은 소비 측에서 rate로 처리
1637
+ }}
1638
+ rateInfo={rateInfo}
1639
+ historySeries={historySeries}
1640
+ onHistoryQueryChange={(code, months) => {
1641
+ // 히스토리 열림/팝업 통화·기간 셀렉트 변경 시 통지 → BE 재조회 후 주입
1642
+ // historySeries: [{ name, label?, current?, points: [{ label, rate }, ...] }, ...]
1643
+ fetchHistory(code, months).then(setHistorySeries)
1644
+ }}
1645
+ onCustomRateChange={(rate, context) => {
1646
+ // what-if 시뮬레이션 값 (저장되지 않음, onChange 미호출)
1647
+ }}
1648
+ />`,
1649
+ description: '통화 전환 드롭다운 + 환율 팝오버 + 환율 히스토리 기본 예제입니다. 환율 데이터는 컴포넌트가 조회하지 않으므로 BE 환율 API 응답을 rateInfo/historySeries props로 주입하고, onHistoryQueryChange(currency, months)로 조회 조건을 통지받아 재조회합니다. rateInfo.details가 2건 이상인 통화는 다중 환율로 취급되어 히스토리가 화면 중앙 팝업(차트/테이블)으로 열리고, 단일 환율·기준 통화는 팝오버 안 인라인 차트로 열립니다. [검색 키워드: 통화 전환, 환율, 환율 필터, 통화 필터, 통화 변환, 환율 히스토리, 다중 환율, currency, exchange rate]'
1650
+ },
1651
+ {
1652
+ title: 'custom-options-no-detail',
1653
+ code: `<OpsnowCommonCurrencySwitcher
1654
+ value={currency}
1655
+ onChange={handleCurrencyChange}
1656
+ rateInfo={rateInfo}
1657
+ currencyOptions={[
1658
+ { code: 'USD', symbol: '$' },
1659
+ { code: 'KRW', symbol: '₩', digits: 0 },
1660
+ { code: 'JPY', symbol: '¥' },
1661
+ ]}
1662
+ baseCurrency="USD"
1663
+ size="small"
1664
+ showDetail={false}
1665
+ showHistory={false}
1666
+ />`,
1667
+ description: '팝오버 통화 목록을 커스텀하고 환율 설정(시뮬레이션)·히스토리 없이 small 크기 트리거로 사용하는 예제입니다.'
1668
+ }
1669
+ ];
1610
1670
  export const ToggleButtonExamples = [
1611
1671
  {
1612
1672
  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,27 @@ 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-dropdown >= 1.0.29)
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, details? } 형태로 BE 환율 API 응답을 주입. details는 통화별 Payer/Invoice 상세 환율(Array<{ payer, invoice?, rate }>)로 2건 이상이면 다중 환율 통화로 취급 (없으면 목록에 환율이 '-'로 표시, 예: rateInfo)"),
298
+ historySeries: z.string().optional().describe("환율 히스토리 시리즈 배열 변수명 (controlled) — Array<{ name, label?, current?, points: Array<{ label, rate }> }>, onHistoryQueryChange로 통지받은 조건 기준으로 BE 재조회 후 주입. 인라인 차트는 첫 번째 시리즈(대표 환율)만 사용 (예: historySeries)"),
299
+ onHistoryQueryChange: z.string().optional().describe("히스토리 조회 조건 통지 핸들러 함수명 — (currency, months) => void 형태, 히스토리 열림/팝업 통화·기간 셀렉트 변경 시 호출 → 소비 측이 BE 재조회 후 historySeries 갱신 (예: handleHistoryQueryChange)"),
300
+ historyPeriodOptions: z.string().optional().describe("히스토리 팝업 기간 옵션 배열 변수명 — number[] (기본값: [6, 12, 24])"),
301
+ defaultHistoryPeriod: z.number().optional().describe("히스토리 기본 조회 기간(개월, 기본값: 24)"),
302
+ currencyOptions: z.string().optional().describe("팝오버 통화 목록 배열 변수명 — Array<{ code, symbol, digits? }> (기본: USD/KRW/JPY/VND/AED)"),
303
+ baseCurrency: z.string().optional().describe("변환 기준 통화 코드 (기본값: 'USD')"),
304
+ defaultTargetCurrency: z.string().optional().describe("기준 통화 선택 중일 때 환율 설정이 다룰 초기 비교 통화 코드"),
305
+ customRate: z.string().optional().describe("직접 입력 시뮬레이션 환율 상태 변수명 (number | null, controlled 모드 — 미지정 시 내부 관리)"),
306
+ onCustomRateChange: z.string().optional().describe("직접 입력 환율 변경 핸들러 함수명 — (rate, context) => void 형태, 저장되지 않는 what-if 값 통지 (onChange는 호출되지 않음)"),
307
+ showDetail: z.boolean().optional().describe("환율 설정(직접 입력 시뮬레이션) 섹션 노출 여부 (기본값: true)"),
308
+ showHistory: z.boolean().optional().describe("월별 환율 히스토리 링크·인라인 차트·팝업 노출 여부 (기본값: true)"),
309
+ renderChart: z.string().optional().describe("히스토리 팝업 차트 교체 슬롯 함수명 — (series, currency) => ReactNode 형태, 체크된(보이는) 시리즈만 전달 (기본: 내장 SVG 멀티라인 차트)"),
310
+ labels: z.string().optional().describe("문구 개별 커스텀 객체 변수명 — Partial<CurrencySwitcherLabels>, i18n(ko/en/ja) 번역 위에 항목별로 덮어씀 ({placeholder} 템플릿 치환 지원)"),
311
+ size: z.enum(["small", "medium"]).optional().describe("트리거 크기"),
312
+ disabled: z.boolean().optional().describe("비활성화 여부"),
313
+ });
293
314
  // Forms 컴포넌트 함수 - 배열 반환
294
315
  export function createFormsComponent() {
295
316
  return [
@@ -1093,6 +1114,85 @@ export function createFormsComponent() {
1093
1114
  ]
1094
1115
  };
1095
1116
  }
1117
+ },
1118
+ {
1119
+ name: "createCurrencySwitcher",
1120
+ description: `CurrencySwitcher 컴포넌트 - 통화 전환 드롭다운 + 환율 팝오버 + 환율 히스토리, 환율/통화 필터로 사용 (opsnow-common-dropdown >= 1.0.29)
1121
+
1122
+ 트리거에 현재 선택된 통화가 표시되고, 클릭하면 팝오버에서 적용 환율 기준일 안내와
1123
+ 통화 목록(클릭 시 즉시 적용)을 제공합니다. Payer/Invoice별 환율이 여러 개인 통화는
1124
+ 'N개 환율' 배지와 '현재 적용 환율' 목록이 표시되고, 환율 설정에서 Payer를 골라
1125
+ what-if 시뮬레이션을 입력할 수 있습니다.
1126
+
1127
+ **데이터 주입 규칙 (중요):**
1128
+ - 환율 데이터는 컴포넌트가 조회하지 않습니다 — BE 환율 API 응답을 rateInfo / historySeries props로 주입하고, 조회 조건이 바뀌면 onHistoryQueryChange(currency, months)로 통지받아 재조회하세요.
1129
+ - rateInfo: { baseDate: 'YYYY-MM-DD', source?: '출처', rates: { USD: 1, KRW: 1450, ... }, details?: { KRW: [{ payer, invoice?, rate }, ...] } } — 기준 통화 1단위당 환율, details의 통화별 배열이 2건 이상이면 다중 환율 통화로 취급
1130
+ - historySeries: [{ name, label?, current?, points: [{ label, rate }, ...] }, ...] — 모든 시리즈는 같은 월 구간으로 정렬, 대표 환율이 첫 번째 시리즈가 되도록 정렬 (인라인 차트는 첫 번째 시리즈만 사용)
1131
+ - BE API 호출 시 axios 직접 import 금지 — getAxios() 공통 axios 사용
1132
+
1133
+ **히스토리 동작 분기 규칙:**
1134
+ - 다중 환율 통화(details 2건 이상): 화면 중앙 팝업(차트/테이블 전환, Payer/Invoice 검색·체크박스) — Payer/Invoice별 전체 시리즈 표시
1135
+ - 단일 환율 통화·기준 통화: 팝오버 안 인라인 차트 펼침/접힘(팝업 없음) — 첫 번째 시리즈(대표 환율)만 표시
1136
+
1137
+ **동작 규칙:**
1138
+ - 통화 선택 시 onChange(currency, rate)가 호출됩니다 — 금액 표시 변환은 소비 프로젝트에서 rate로 처리
1139
+ - 직접 입력 환율은 저장되지 않는 what-if 시뮬레이션 값으로 onCustomRateChange(rate, context)로만 통지되며, onChange(실제 적용)는 호출되지 않습니다
1140
+ - 문구는 i18n 현재 언어(ko/en/ja)를 자동으로 따르고, labels prop으로 항목별 커스텀 가능
1141
+
1142
+ **import:**
1143
+ \`\`\`javascript
1144
+ import { useCommonComponents } from '@opsnow-common/opsnow-finops-common-ui-loader';
1145
+ const { OpsnowCommonCurrencySwitcher } = useCommonComponents();
1146
+ \`\`\``,
1147
+ parameters: CurrencySwitcherSchema,
1148
+ handler: async (args) => {
1149
+ const props = [];
1150
+ if (args.value)
1151
+ props.push(`value={${args.value}}`);
1152
+ if (args.onChange)
1153
+ props.push(`onChange={${args.onChange}}`);
1154
+ if (args.rateInfo)
1155
+ props.push(`rateInfo={${args.rateInfo}}`);
1156
+ if (args.historySeries)
1157
+ props.push(`historySeries={${args.historySeries}}`);
1158
+ if (args.onHistoryQueryChange)
1159
+ props.push(`onHistoryQueryChange={${args.onHistoryQueryChange}}`);
1160
+ if (args.historyPeriodOptions)
1161
+ props.push(`historyPeriodOptions={${args.historyPeriodOptions}}`);
1162
+ if (args.defaultHistoryPeriod !== undefined)
1163
+ props.push(`defaultHistoryPeriod={${args.defaultHistoryPeriod}}`);
1164
+ if (args.currencyOptions)
1165
+ props.push(`currencyOptions={${args.currencyOptions}}`);
1166
+ if (args.baseCurrency)
1167
+ props.push(`baseCurrency="${args.baseCurrency}"`);
1168
+ if (args.defaultTargetCurrency)
1169
+ props.push(`defaultTargetCurrency="${args.defaultTargetCurrency}"`);
1170
+ if (args.customRate)
1171
+ props.push(`customRate={${args.customRate}}`);
1172
+ if (args.onCustomRateChange)
1173
+ props.push(`onCustomRateChange={${args.onCustomRateChange}}`);
1174
+ if (args.showDetail !== undefined)
1175
+ props.push(`showDetail={${args.showDetail}}`);
1176
+ if (args.showHistory !== undefined)
1177
+ props.push(`showHistory={${args.showHistory}}`);
1178
+ if (args.renderChart)
1179
+ props.push(`renderChart={${args.renderChart}}`);
1180
+ if (args.labels)
1181
+ props.push(`labels={${args.labels}}`);
1182
+ if (args.size)
1183
+ props.push(`size="${args.size}"`);
1184
+ if (args.disabled)
1185
+ props.push(`disabled`);
1186
+ const code = `<OpsnowCommonCurrencySwitcher\n ${props.join('\n ')}\n/>`;
1187
+ return {
1188
+ content: [
1189
+ {
1190
+ type: "text",
1191
+ text: `\`\`\`jsx\n${code}\n\`\`\``
1192
+ }
1193
+ ]
1194
+ };
1195
+ }
1096
1196
  }
1097
1197
  ];
1098
1198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opsnow-mcp/opsnow-mcp-common-ui-server",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "bin": {