@opsnow-mcp/opsnow-mcp-common-ui-server 1.0.26 → 1.0.27

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.
@@ -2325,6 +2325,96 @@ export const DataGridExamples = [
2325
2325
  langCd={i18n.getLocale()}
2326
2326
  />`
2327
2327
  },
2328
+ {
2329
+ title: 'Auto Row Height (행 수 분기 + 스크롤)',
2330
+ description: 'autoHeight는 모든 행을 펼쳐 그리드가 무한정 길어집니다. 행 수가 가변적이거나 많아질 수 있는 경우(목록/검색 결과 등) 행 수 기준으로 분기해야 합니다: 10행 이하면 autoHeight로 콘텐츠에 맞게 확장하고, 10행 초과면 고정 높이 + 내부 스크롤로 전환합니다. autoHeight 셀은 행마다 높이가 달라 정확한 "10행 높이"를 픽셀로 맞출 수 없으므로 고정 픽셀값(예: 600)을 사용합니다.',
2331
+ code_props_usage: `
2332
+ import { useCommonComponents, useGlobalContext } from '@opsnow-common/opsnow-finops-common-ui-loader'
2333
+ import i18n from '@opsnow-common/opsnow-finops-common-i18n'
2334
+
2335
+ const ROW_LIMIT = 10 // 이 행 수를 넘으면 고정 높이 + 스크롤
2336
+ const SCROLL_HEIGHT = 600 // 초과 시 고정 높이(px)
2337
+
2338
+ const columnDefs = [
2339
+ { headerName: 'ID', field: 'id', flex: 1, minWidth: 80 },
2340
+ {
2341
+ headerName: 'Description',
2342
+ field: 'description',
2343
+ flex: 3,
2344
+ minWidth: 300,
2345
+ wrapText: true, // 텍스트 줄바꿈 - 필수
2346
+ autoHeight: true, // 행 높이 자동 조절 - 필수
2347
+ suppressSizeToFit: true,
2348
+ cellStyle: { alignItems: 'center' } // autoHeight 작동을 위해 필수
2349
+ },
2350
+ { headerName: 'Status', field: 'status', flex: 1, minWidth: 120 },
2351
+ ]
2352
+
2353
+ const defaultColDef = {
2354
+ wrapText: true, // 텍스트 줄바꿈 활성화
2355
+ autoHeight: true, // 셀 높이 자동 조절
2356
+ }
2357
+
2358
+ const { OpsnowCommonDataGrid } = useCommonComponents()
2359
+ const { CommonConst } = useGlobalContext()
2360
+
2361
+ // 4행 데이터 (10행 이하 → autoHeight, 스크롤 없음)
2362
+ const fewRowData = [
2363
+ { id: 1, description: 'This is a very long description text that will wrap to multiple lines when the column width is not sufficient to display all content in a single line.', status: 'Active' },
2364
+ { id: 2, description: 'Short text', status: 'Inactive' },
2365
+ { id: 3, description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', status: 'Pending' },
2366
+ { id: 4, description: 'Another example of long text content that needs multiple lines', status: 'Active' },
2367
+ ]
2368
+
2369
+ // 12행 데이터 (10행 초과 → 고정 높이 600px + 내부 스크롤)
2370
+ const manyRowData = Array.from({ length: 12 }, (_, i) => ({
2371
+ id: i + 1,
2372
+ description: 'Row ' + (i + 1) + ': long description text that wraps to multiple lines when the column is narrow, demonstrating autoHeight with scroll.',
2373
+ status: i % 2 === 0 ? 'Active' : 'Inactive',
2374
+ }))
2375
+
2376
+ const [rowData, setRowData] = useState([])
2377
+ const [status, setStatus] = useState(CommonConst.GRID_STATUS.LOADING)
2378
+
2379
+ useEffect(() => {
2380
+ const fetchData = async () => {
2381
+ try {
2382
+ await new Promise(resolve => setTimeout(resolve, 500))
2383
+ setRowData(fewRowData) // 실제로는 API 응답 데이터
2384
+ setStatus(CommonConst.GRID_STATUS.DATA_EXISTS)
2385
+ } catch (error) {
2386
+ setStatus(CommonConst.GRID_STATUS.ERROR)
2387
+ }
2388
+ }
2389
+ fetchData()
2390
+ }, [])
2391
+
2392
+ // 행 수 기준 분기 - 핵심
2393
+ const isScroll = rowData.length > ROW_LIMIT
2394
+ const gridOptions = {
2395
+ animateRows: true,
2396
+ rowSelection: { mode: 'singleRow', checkboxes: false, enableClickSelection: true },
2397
+ tooltipShowDelay: 100,
2398
+ domLayout: isScroll ? 'normal' : 'autoHeight', // 10행 이하: 콘텐츠 맞춤 / 초과: 고정+스크롤
2399
+ suppressCellFocus: true,
2400
+ }
2401
+ `,
2402
+ code: `<>
2403
+ <div style={{ marginBottom: '8px', display: 'flex', gap: '8px' }}>
2404
+ <OpsnowCommonButton label="4행 (스크롤 X)" size="large" variant="outlined" color="secondary" onClick={() => setRowData(fewRowData)} />
2405
+ <OpsnowCommonButton label="12행 (스크롤 O)" size="large" variant="outlined" color="secondary" onClick={() => setRowData(manyRowData)} />
2406
+ </div>
2407
+ <OpsnowCommonDataGrid
2408
+ columnDefs={columnDefs}
2409
+ defaultColDef={defaultColDef}
2410
+ rowData={rowData}
2411
+ status={status}
2412
+ gridOptions={gridOptions}
2413
+ gridHeight={isScroll ? SCROLL_HEIGHT : undefined}
2414
+ langCd={i18n.getLocale()}
2415
+ />
2416
+ </>`
2417
+ },
2328
2418
  {
2329
2419
  title: 'API 데이터 로딩 (getAxios 사용)',
2330
2420
  description: 'API에서 데이터를 가져와 그리드에 표시하는 예제입니다. axios 직접 사용 대신 반드시 getAxios를 사용해야 합니다.',
@@ -239,6 +239,19 @@ export function createDataGridComponent() {
239
239
 
240
240
  ⚠️ defaultColDef에 wrapText, autoHeight가 없으면 텍스트가 넘칩니다!
241
241
 
242
+ **CRITICAL: 행 수가 많을 수 있으면 - 높이 분기 필수**
243
+ autoHeight(domLayout:'autoHeight')는 모든 행을 펼쳐서 그리드가 무한정 길어짐.
244
+ 행 수가 가변적이거나 많아질 수 있으면 행 수 기준으로 분기:
245
+
246
+ const ROW_LIMIT = 10;
247
+ const isScroll = rowData.length > ROW_LIMIT;
248
+ const gridOptions = {
249
+ // ... 다른 설정들
250
+ domLayout: isScroll ? 'normal' : 'autoHeight', // 10행 이하: 콘텐츠 맞춤 / 초과: 고정+스크롤
251
+ };
252
+ // 10행 초과 시에만 고정 높이 부여 (autoHeight 셀은 가변이라 픽셀 고정값 사용)
253
+ <OpsnowCommonDataGrid gridOptions={gridOptions} gridHeight={isScroll ? 600 : undefined} />
254
+
242
255
  **import:**
243
256
  \`\`\`javascript
244
257
  import { useCommonComponents, useGlobalContext } from '@opsnow-common/opsnow-finops-common-ui-loader';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opsnow-mcp/opsnow-mcp-common-ui-server",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "bin": {