@opsnow-mcp/opsnow-mcp-common-ui-server 1.0.44 → 1.0.45
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.
- package/build/components/all-component-tools.js +2 -0
- package/build/components/data/uidemo-routes.js +217 -30
- package/build/components/examples/opsnow-common-chart-examples-data.js +460 -0
- package/build/components/examples/opsnow-common-forms-examples-data.js +420 -0
- package/build/components/examples/opsnow-common-grid-examples-data.js +277 -0
- package/build/components/examples/opsnow-common-select-examples-data.js +123 -1
- package/build/components/examples/opsnow-common-tooltip-examples-data.js +58 -0
- package/build/components/opsnow-common-chart.js +9 -1
- package/build/components/opsnow-common-dropdown.js +3 -1
- package/build/components/opsnow-common-examples.js +49 -6
- package/build/components/opsnow-common-select.js +4 -0
- package/build/components/opsnow-common-selection-group.js +162 -0
- package/build/components/opsnow-common-spec-tools.js +9 -2
- package/build/components/opsnow-common-tooltip.js +50 -0
- package/build/index.js +6 -0
- package/package.json +1 -1
|
@@ -2698,4 +2698,281 @@ export const DataGridExamples = [
|
|
|
2698
2698
|
/>
|
|
2699
2699
|
</Box>`
|
|
2700
2700
|
},
|
|
2701
|
+
{
|
|
2702
|
+
title: '다중 선택 (체크박스 Multi-row Selection)',
|
|
2703
|
+
description: '체크박스로 여러 행을 선택하고 선택된 행을 추적하는 예제입니다. gridOptions.rowSelection 을 { mode: \'multiRow\', checkboxes: true } 로 두고, 선택 변경은 top-level prop onSelectionChanged(인자: 선택된 노드 배열)로 받습니다.',
|
|
2704
|
+
code_props_usage: `
|
|
2705
|
+
import { useCommonComponents, useGlobalContext } from '@opsnow-common/opsnow-finops-common-ui-loader'
|
|
2706
|
+
import i18n from '@opsnow-common/opsnow-finops-common-i18n'
|
|
2707
|
+
import { useState, useCallback } from 'react'
|
|
2708
|
+
|
|
2709
|
+
const columnDefs = [
|
|
2710
|
+
{ headerName: 'Make', field: 'make' },
|
|
2711
|
+
{ headerName: 'Model', field: 'model' },
|
|
2712
|
+
{ headerName: 'Price', field: 'price' },
|
|
2713
|
+
]
|
|
2714
|
+
|
|
2715
|
+
const rowData = [
|
|
2716
|
+
{ make: 'Toyota', model: 'Celica', price: 35000 },
|
|
2717
|
+
{ make: 'Ford', model: 'Mondeo', price: 32000 },
|
|
2718
|
+
{ make: 'Porsche', model: 'Boxter', price: 72000 },
|
|
2719
|
+
]
|
|
2720
|
+
|
|
2721
|
+
const gridOptions = {
|
|
2722
|
+
animateRows: true,
|
|
2723
|
+
rowSelection: {
|
|
2724
|
+
mode: 'multiRow', // 다중 선택
|
|
2725
|
+
checkboxes: true, // 행 체크박스 표시
|
|
2726
|
+
enableClickSelection: false, // 행 클릭으로는 선택하지 않음 (체크박스로만)
|
|
2727
|
+
},
|
|
2728
|
+
domLayout: 'autoHeight',
|
|
2729
|
+
suppressCellFocus: true,
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
const { OpsnowCommonDataGrid, OpsnowCommonButton } = useCommonComponents()
|
|
2733
|
+
const { CommonConst } = useGlobalContext()
|
|
2734
|
+
const [selectedRows, setSelectedRows] = useState([])
|
|
2735
|
+
|
|
2736
|
+
// gridOptions 가 아니라 top-level prop — 인자는 선택된 노드 배열
|
|
2737
|
+
const handleSelectionChanged = useCallback((selectedNodes) => {
|
|
2738
|
+
setSelectedRows(selectedNodes.map(node => node.data))
|
|
2739
|
+
}, [])
|
|
2740
|
+
`,
|
|
2741
|
+
code: `<>
|
|
2742
|
+
<div style={{ marginBottom: '16px' }}>
|
|
2743
|
+
<OpsnowCommonButton
|
|
2744
|
+
label={'선택된 행 확인 (' + selectedRows.length + '개)'}
|
|
2745
|
+
size="large"
|
|
2746
|
+
variant="outlined"
|
|
2747
|
+
color="secondary"
|
|
2748
|
+
onClick={() => console.log('selected rows', selectedRows)}
|
|
2749
|
+
/>
|
|
2750
|
+
</div>
|
|
2751
|
+
<OpsnowCommonDataGrid
|
|
2752
|
+
columnDefs={columnDefs}
|
|
2753
|
+
rowData={rowData}
|
|
2754
|
+
status={CommonConst.GRID_STATUS.DATA_EXISTS}
|
|
2755
|
+
gridOptions={gridOptions}
|
|
2756
|
+
onSelectionChanged={handleSelectionChanged}
|
|
2757
|
+
langCd={i18n.getLocale()}
|
|
2758
|
+
/>
|
|
2759
|
+
</>`
|
|
2760
|
+
},
|
|
2761
|
+
{
|
|
2762
|
+
title: '행 클릭 이벤트 + 클릭 가능한 행 (onCellClick, Pointer Cursor)',
|
|
2763
|
+
description: '행(셀)을 클릭했을 때 그 행 데이터를 받는 예제입니다. onCellClick 의 params.data 가 클릭한 행 데이터이고, 클릭 가능한 행임을 보여주려면 gridOptions.getRowStyle 로 cursor: \'pointer\' 를 줍니다.',
|
|
2764
|
+
code_props_usage: `
|
|
2765
|
+
import { useCommonComponents, useGlobalContext } from '@opsnow-common/opsnow-finops-common-ui-loader'
|
|
2766
|
+
import i18n from '@opsnow-common/opsnow-finops-common-i18n'
|
|
2767
|
+
|
|
2768
|
+
const columnDefs = [
|
|
2769
|
+
{ headerName: 'Make', field: 'make' },
|
|
2770
|
+
{ headerName: 'Model', field: 'model' },
|
|
2771
|
+
{ headerName: 'Price', field: 'price' },
|
|
2772
|
+
]
|
|
2773
|
+
|
|
2774
|
+
const rowData = [
|
|
2775
|
+
{ make: 'Toyota', model: 'Celica', price: 35000 },
|
|
2776
|
+
{ make: 'Ford', model: 'Mondeo', price: 32000 },
|
|
2777
|
+
{ make: 'Porsche', model: 'Boxter', price: 72000 },
|
|
2778
|
+
]
|
|
2779
|
+
|
|
2780
|
+
const gridOptions = {
|
|
2781
|
+
animateRows: true,
|
|
2782
|
+
rowSelection: {
|
|
2783
|
+
mode: 'singleRow',
|
|
2784
|
+
checkboxes: false,
|
|
2785
|
+
enableClickSelection: true,
|
|
2786
|
+
},
|
|
2787
|
+
domLayout: 'autoHeight',
|
|
2788
|
+
suppressCellFocus: true,
|
|
2789
|
+
getRowStyle: () => ({ cursor: 'pointer' }), // 행 위에서 손가락 커서
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
const { OpsnowCommonDataGrid } = useCommonComponents()
|
|
2793
|
+
const { CommonConst } = useGlobalContext()
|
|
2794
|
+
|
|
2795
|
+
const handleCellClick = (params) => {
|
|
2796
|
+
console.log('clicked row data', params.data) // 클릭한 행 데이터
|
|
2797
|
+
}
|
|
2798
|
+
`,
|
|
2799
|
+
code: `<OpsnowCommonDataGrid
|
|
2800
|
+
columnDefs={columnDefs}
|
|
2801
|
+
rowData={rowData}
|
|
2802
|
+
status={CommonConst.GRID_STATUS.DATA_EXISTS}
|
|
2803
|
+
gridOptions={gridOptions}
|
|
2804
|
+
usedRowClass={true}
|
|
2805
|
+
onCellClick={handleCellClick}
|
|
2806
|
+
langCd={i18n.getLocale()}
|
|
2807
|
+
/>`
|
|
2808
|
+
},
|
|
2809
|
+
{
|
|
2810
|
+
title: '컬럼 이동 (헤더 드래그 · 순서 저장/복원)',
|
|
2811
|
+
description: '헤더를 끌어 컬럼 순서를 바꾸고, 순서를 저장했다가 복원하는 예제입니다. 공통 그리드는 기본으로 컬럼 이동이 꺼져 있어 gridOptions.suppressMovableColumns: false 로 켭니다. 컬럼별로 lockPosition(맨 왼쪽 고정)·suppressMovable(이동 불가)을 줄 수 있고, 순서는 ref 의 getColumnState() / applyColumnState() 로 저장·복원합니다.',
|
|
2812
|
+
code_props_usage: `
|
|
2813
|
+
import { useCommonComponents, useGlobalContext } from '@opsnow-common/opsnow-finops-common-ui-loader'
|
|
2814
|
+
import i18n from '@opsnow-common/opsnow-finops-common-i18n'
|
|
2815
|
+
import { useState, useRef } from 'react'
|
|
2816
|
+
|
|
2817
|
+
const columnDefs = [
|
|
2818
|
+
{ headerName: 'Make (lockPosition)', field: 'make', width: 180, lockPosition: 'left' }, // 맨 왼쪽 고정
|
|
2819
|
+
{ headerName: 'Model', field: 'model', width: 140 },
|
|
2820
|
+
{ headerName: 'Price (suppressMovable)', field: 'price', width: 200, suppressMovable: true }, // 이동 불가
|
|
2821
|
+
{ headerName: 'Year', field: 'year', width: 120 },
|
|
2822
|
+
{ headerName: 'Color', field: 'color', width: 120 },
|
|
2823
|
+
]
|
|
2824
|
+
|
|
2825
|
+
const rowData = [
|
|
2826
|
+
{ make: 'Toyota', model: 'Celica', price: 35000, year: 2021, color: 'Red' },
|
|
2827
|
+
{ make: 'Ford', model: 'Mondeo', price: 32000, year: 2019, color: 'Blue' },
|
|
2828
|
+
{ make: 'Porsche', model: 'Boxter', price: 72000, year: 2023, color: 'Black' },
|
|
2829
|
+
]
|
|
2830
|
+
|
|
2831
|
+
const INITIAL_COLUMN_ORDER = columnDefs.map(c => ({ colId: c.field }))
|
|
2832
|
+
|
|
2833
|
+
const { OpsnowCommonDataGrid, OpsnowCommonButton } = useCommonComponents()
|
|
2834
|
+
const { CommonConst } = useGlobalContext()
|
|
2835
|
+
const gridRef = useRef(null)
|
|
2836
|
+
const [savedState, setSavedState] = useState(null)
|
|
2837
|
+
const [currentOrder, setCurrentOrder] = useState(INITIAL_COLUMN_ORDER.map(c => c.colId))
|
|
2838
|
+
|
|
2839
|
+
// gridOptions 는 고정 — 매 렌더마다 새로 만들면 그리드가 다시 그려져 옮긴 순서가 풀린다
|
|
2840
|
+
const [gridOptions] = useState(() => ({
|
|
2841
|
+
domLayout: 'autoHeight',
|
|
2842
|
+
suppressCellFocus: true,
|
|
2843
|
+
suppressMovableColumns: false, // 공통 그리드 기본값 true → 끈다
|
|
2844
|
+
suppressDragLeaveHidesColumns: true, // 그리드 밖으로 끌어도 컬럼이 숨겨지지 않게
|
|
2845
|
+
onColumnMoved: (event) => {
|
|
2846
|
+
if (!event.finished) return // 드래그가 끝났을 때만
|
|
2847
|
+
setCurrentOrder(event.api.getColumnState().map(s => s.colId))
|
|
2848
|
+
},
|
|
2849
|
+
}))
|
|
2850
|
+
|
|
2851
|
+
// applyColumnState 는 onColumnMoved 를 부르지 않으므로 표시 순서를 직접 갱신한다
|
|
2852
|
+
const applyOrder = (state) => {
|
|
2853
|
+
gridRef.current?.applyColumnState({ state, applyOrder: true })
|
|
2854
|
+
setCurrentOrder((gridRef.current?.getColumnState() ?? state).map(s => s.colId))
|
|
2855
|
+
}
|
|
2856
|
+
`,
|
|
2857
|
+
code: `<>
|
|
2858
|
+
<div style={{ marginBottom: '16px', display: 'flex', gap: '8px' }}>
|
|
2859
|
+
<OpsnowCommonButton
|
|
2860
|
+
label={'순서 저장'}
|
|
2861
|
+
size="large"
|
|
2862
|
+
variant="outlined"
|
|
2863
|
+
color="secondary"
|
|
2864
|
+
onClick={() => setSavedState(gridRef.current?.getColumnState())}
|
|
2865
|
+
/>
|
|
2866
|
+
<OpsnowCommonButton
|
|
2867
|
+
label={'저장한 순서 복원'}
|
|
2868
|
+
size="large"
|
|
2869
|
+
variant="outlined"
|
|
2870
|
+
color="secondary"
|
|
2871
|
+
disabled={!savedState}
|
|
2872
|
+
onClick={() => applyOrder(savedState)}
|
|
2873
|
+
/>
|
|
2874
|
+
<OpsnowCommonButton
|
|
2875
|
+
label={'초기화'}
|
|
2876
|
+
size="large"
|
|
2877
|
+
variant="outlined"
|
|
2878
|
+
color="secondary"
|
|
2879
|
+
onClick={() => applyOrder(INITIAL_COLUMN_ORDER)}
|
|
2880
|
+
/>
|
|
2881
|
+
</div>
|
|
2882
|
+
<OpsnowCommonDataGrid
|
|
2883
|
+
ref={gridRef}
|
|
2884
|
+
columnDefs={columnDefs}
|
|
2885
|
+
rowData={rowData}
|
|
2886
|
+
status={CommonConst.GRID_STATUS.DATA_EXISTS}
|
|
2887
|
+
gridOptions={gridOptions}
|
|
2888
|
+
langCd={i18n.getLocale()}
|
|
2889
|
+
/>
|
|
2890
|
+
</>`
|
|
2891
|
+
},
|
|
2892
|
+
{
|
|
2893
|
+
title: '고정 높이 + 세로 스크롤 (gridHeight)',
|
|
2894
|
+
description: '그리드 높이를 고정하고 데이터가 넘치면 세로 스크롤이 생기게 하는 예제입니다. gridHeight 로 높이(px)를 주고 gridOptions.domLayout 은 지정하지 않습니다 (autoHeight 를 주면 고정 높이가 적용되지 않음). 행 수에 맞춰 늘어나다 상한에서 스크롤되게 하려면 "그리드 최대 높이 + 스크롤 (domLayout autoHeight)" 예제를 쓰세요.',
|
|
2895
|
+
code_props_usage: `
|
|
2896
|
+
import { useCommonComponents, useGlobalContext } from '@opsnow-common/opsnow-finops-common-ui-loader'
|
|
2897
|
+
import i18n from '@opsnow-common/opsnow-finops-common-i18n'
|
|
2898
|
+
|
|
2899
|
+
const columnDefs = [
|
|
2900
|
+
{ headerName: 'Make', field: 'make' },
|
|
2901
|
+
{ headerName: 'Model', field: 'model' },
|
|
2902
|
+
{ headerName: 'Price', field: 'price' },
|
|
2903
|
+
]
|
|
2904
|
+
|
|
2905
|
+
// 높이(300px)를 넘도록 충분한 행
|
|
2906
|
+
const rowData = Array.from({ length: 12 }, (_, i) => ({
|
|
2907
|
+
make: 'Brand_' + (i + 1),
|
|
2908
|
+
model: 'Model_' + (i + 1),
|
|
2909
|
+
price: 20000 + i * 3000,
|
|
2910
|
+
}))
|
|
2911
|
+
|
|
2912
|
+
const defaultColDef = {
|
|
2913
|
+
autoHeight: false,
|
|
2914
|
+
wrapText: false,
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2917
|
+
// domLayout 미지정 (기본값 사용) — 고정 높이 안에서 세로 스크롤
|
|
2918
|
+
const gridOptions = {
|
|
2919
|
+
animateRows: true,
|
|
2920
|
+
rowSelection: {
|
|
2921
|
+
mode: 'singleRow',
|
|
2922
|
+
checkboxes: false,
|
|
2923
|
+
enableClickSelection: true,
|
|
2924
|
+
},
|
|
2925
|
+
suppressCellFocus: true,
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
|
+
const { OpsnowCommonDataGrid } = useCommonComponents()
|
|
2929
|
+
const { CommonConst } = useGlobalContext()
|
|
2930
|
+
`,
|
|
2931
|
+
code: `<OpsnowCommonDataGrid
|
|
2932
|
+
columnDefs={columnDefs}
|
|
2933
|
+
rowData={rowData}
|
|
2934
|
+
status={CommonConst.GRID_STATUS.DATA_EXISTS}
|
|
2935
|
+
gridHeight={300}
|
|
2936
|
+
defaultColDef={defaultColDef}
|
|
2937
|
+
gridOptions={gridOptions}
|
|
2938
|
+
langCd={i18n.getLocale()}
|
|
2939
|
+
/>`
|
|
2940
|
+
},
|
|
2941
|
+
{
|
|
2942
|
+
title: 'Search No Data (검색 결과 없음 — usedSearch)',
|
|
2943
|
+
description: '검색창(usedSearch)이 있는 그리드에서 검색어에 맞는 행이 없을 때의 "검색 결과 없음" 상태 예제입니다. 데이터는 있지만(DATA_EXISTS) 검색어로 걸러진 결과가 0건이면 그리드가 검색 결과 없음 화면을 표시합니다. 데이터 자체가 없는 경우는 "No Data" 예제를 참고하세요.',
|
|
2944
|
+
code_props_usage: `
|
|
2945
|
+
import { useCommonComponents, useGlobalContext } from '@opsnow-common/opsnow-finops-common-ui-loader'
|
|
2946
|
+
import i18n from '@opsnow-common/opsnow-finops-common-i18n'
|
|
2947
|
+
|
|
2948
|
+
const columnDefs = [
|
|
2949
|
+
{ headerName: 'Make', field: 'make' },
|
|
2950
|
+
{ headerName: 'Model', field: 'model' },
|
|
2951
|
+
{ headerName: 'Price', field: 'price' },
|
|
2952
|
+
]
|
|
2953
|
+
|
|
2954
|
+
const defaultColDef = {
|
|
2955
|
+
suppressMenu: true,
|
|
2956
|
+
unSortIcon: true,
|
|
2957
|
+
sortable: false,
|
|
2958
|
+
}
|
|
2959
|
+
|
|
2960
|
+
const gridOptions = {
|
|
2961
|
+
animateRows: true,
|
|
2962
|
+
domLayout: 'autoHeight',
|
|
2963
|
+
}
|
|
2964
|
+
|
|
2965
|
+
const { OpsnowCommonDataGrid } = useCommonComponents()
|
|
2966
|
+
const { CommonConst } = useGlobalContext()
|
|
2967
|
+
`,
|
|
2968
|
+
code: `<OpsnowCommonDataGrid
|
|
2969
|
+
columnDefs={columnDefs}
|
|
2970
|
+
rowData={[{ make: 'Toyota', model: 'Celica', price: 35000 }]}
|
|
2971
|
+
gridOptions={gridOptions}
|
|
2972
|
+
status={CommonConst.GRID_STATUS.DATA_EXISTS}
|
|
2973
|
+
defaultColDef={defaultColDef}
|
|
2974
|
+
usedSearch={true}
|
|
2975
|
+
langCd={i18n.getLocale()}
|
|
2976
|
+
/>`
|
|
2977
|
+
},
|
|
2701
2978
|
];
|
|
@@ -122,7 +122,7 @@ export const AutocompleteExamples = [
|
|
|
122
122
|
{
|
|
123
123
|
title: 'Autocomplete - 체크박스/전체선택',
|
|
124
124
|
code: `<OpsnowCommonAutocomplete items={[{ value: '1', label: 'Option 1', group: 'A' }, { value: '2', label: 'Option 2', group: 'A' }, { value: '3', label: 'Option 3', group: 'B' }]} multiple value={value} onChange={setValue} label="Select with checkbox" useCheckboxOption useSelectAll />`,
|
|
125
|
-
description: '체크박스와 전체선택이 있는 오토컴플리트 예제입니다.'
|
|
125
|
+
description: '체크박스와 전체선택이 있는 오토컴플리트 예제입니다. 드롭다운을 열어 체크박스로 여러 개 고르는 필터(계정 필터 등)의 기본 형태이며, 입력창에 타이핑하면 옵션이 검색됩니다. value 와 onChange 값은 items 원소(객체) 배열입니다.'
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
title: 'Autocomplete - 아이콘 옵션',
|
|
@@ -200,3 +200,125 @@ export const AutocompleteExamples = [
|
|
|
200
200
|
description: '한 화면에 필터를 여러 개 배치할 때의 간격 규칙 예제입니다. 색상 토큰(theme.palette.commonPalette)과 동일하게 간격도 theme.commonSpacing 토큰을 참조합니다. 필터 행 컨테이너 gap은 theme.commonSpacing.filterGap(24px), 라벨이 있는 필터는 라벨+필터를 theme.commonSpacing.filterLabelGap(8px) Stack으로 감싸며, 그 묶음과 앞 필터 사이는 동일하게 filterGap입니다. px 하드코딩 대신 토큰으로 지정하고, Autocomplete는 Box(minWidth)로 최소 폭을 확보합니다. Select와 Autocomplete를 섞어 배치할 때도 같은 규칙이 적용됩니다.'
|
|
201
201
|
}
|
|
202
202
|
];
|
|
203
|
+
// SelectMenu 예제
|
|
204
|
+
export const SelectMenuExamples = [
|
|
205
|
+
{
|
|
206
|
+
title: 'SelectMenu - 아이콘 버튼으로 여는 기본 메뉴 (buttonIconName + menuItems)',
|
|
207
|
+
code: `const { OpsnowCommonSelectMenu } = useCommonComponents();
|
|
208
|
+
|
|
209
|
+
const menuItems = [
|
|
210
|
+
{ label: '홈으로 이동', muiIconName: 'home', link: 'https://www.example.com/home', disabled: true },
|
|
211
|
+
{ label: '설정', iconName: 'Setting', onClick: () => navigate('/settings'), selected: true },
|
|
212
|
+
{ label: '로그아웃', iconName: 'Logout', onClick: handleLogout },
|
|
213
|
+
];
|
|
214
|
+
|
|
215
|
+
<OpsnowCommonSelectMenu buttonIconName="MenuHamburger" menuItems={menuItems} />`,
|
|
216
|
+
description: '아이콘 버튼을 누르면 펼쳐지는 액션 메뉴 예제입니다. 항목은 label이 필수이고, 아이콘은 iconName(OpsNow) 또는 muiIconName(Material) 중 하나만 줍니다. onClick이 있으면 그 함수를 실행하고, onClick 없이 link만 있으면 새 탭으로 엽니다. 항목을 누르면 메뉴가 닫힙니다(keepOpenOnClick: true로 유지).'
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
title: 'SelectMenu - 구분선이 있는 메뉴 (hasDivider)',
|
|
220
|
+
code: `const { OpsnowCommonSelectMenu } = useCommonComponents();
|
|
221
|
+
|
|
222
|
+
const menuItems = [
|
|
223
|
+
{ label: '대시보드', iconName: 'ModuleDashboard1', onClick: () => navigate('/dashboard') },
|
|
224
|
+
{ label: '프로젝트', iconName: 'FolderDocument', onClick: () => navigate('/project') },
|
|
225
|
+
{ label: '설정', iconName: 'Setting', onClick: () => navigate('/settings'), hasDivider: true },
|
|
226
|
+
{ label: '로그아웃', iconName: 'Logout', onClick: handleLogout },
|
|
227
|
+
];
|
|
228
|
+
|
|
229
|
+
<OpsnowCommonSelectMenu buttonIconName="MenuHamburger" menuItems={menuItems} />`,
|
|
230
|
+
description: 'hasDivider: true인 항목 아래에 구분선이 그려집니다.'
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
title: 'SelectMenu - 커스텀 트리거 + 헤더/푸터 (button · listHeader · listFooter, 프로필 메뉴)',
|
|
234
|
+
code: `const { OpsnowCommonSelectMenu, OpsnowCommonAvatar } = useCommonComponents();
|
|
235
|
+
|
|
236
|
+
const listHeader = (
|
|
237
|
+
<Box sx={{ display: 'flex', alignItems: 'center', p: 1 }}>
|
|
238
|
+
<OpsnowCommonAvatar src={profileImage} size="small" />
|
|
239
|
+
<Box sx={{ ml: 1 }}>
|
|
240
|
+
<OpsnowCommonTypography variant="e-m10">홍길동</OpsnowCommonTypography>
|
|
241
|
+
</Box>
|
|
242
|
+
</Box>
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
const listFooter = (
|
|
246
|
+
<Box sx={{ p: 1 }}>
|
|
247
|
+
<OpsnowCommonTypography variant="e-r12" theme="description">Version 1.0.0</OpsnowCommonTypography>
|
|
248
|
+
</Box>
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
<OpsnowCommonSelectMenu
|
|
252
|
+
button={<OpsnowCommonAvatar src={profileImage} alt="홍길동" size="medium" />}
|
|
253
|
+
menuItems={menuItems}
|
|
254
|
+
listHeader={listHeader}
|
|
255
|
+
listFooter={listFooter}
|
|
256
|
+
/>`,
|
|
257
|
+
description: 'button에 JSX를 주면 그 요소가 메뉴를 여는 트리거가 됩니다(아바타 · 텍스트 등). listHeader · listFooter는 메뉴 목록 위아래에 붙는 영역입니다.'
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
title: 'SelectMenu - 항목에 칩 · 액션 버튼 붙이기 (labelPreComponent · actionComponent)',
|
|
261
|
+
code: `const { OpsnowCommonSelectMenu, OpsnowCommonChip, OpsnowCommonButton } = useCommonComponents();
|
|
262
|
+
|
|
263
|
+
const menuItems = [
|
|
264
|
+
{
|
|
265
|
+
label: '프로필',
|
|
266
|
+
iconName: 'User',
|
|
267
|
+
labelPreComponent: <OpsnowCommonChip color="primary" label="Good" size="small" />,
|
|
268
|
+
actionComponent: (
|
|
269
|
+
<OpsnowCommonButton variant="contained" size="small" label="수정" onClick={handleEditProfile} />
|
|
270
|
+
),
|
|
271
|
+
onClick: () => navigate('/profile'),
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
label: '시스템 설정',
|
|
275
|
+
iconName: 'Setting',
|
|
276
|
+
labelPreComponent: <OpsnowCommonChip label="New" color="success" size="small" />,
|
|
277
|
+
onClick: () => navigate('/settings'),
|
|
278
|
+
},
|
|
279
|
+
];
|
|
280
|
+
|
|
281
|
+
<OpsnowCommonSelectMenu buttonIconName="MenuHamburger" menuItems={menuItems} />`,
|
|
282
|
+
description: 'labelPreComponent는 라벨 앞(아이콘 뒤)에, actionComponent는 항목 오른쪽 끝에 붙는 JSX입니다.'
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
title: 'SelectMenu - 메뉴 위치 맞추기 (anchorOrigin · transformOrigin)',
|
|
286
|
+
code: `const { OpsnowCommonSelectMenu } = useCommonComponents();
|
|
287
|
+
|
|
288
|
+
{/* 메뉴의 오른쪽 위를 버튼의 오른쪽 아래에 맞춤 (화면 오른쪽 끝의 더보기 버튼) */}
|
|
289
|
+
<OpsnowCommonSelectMenu
|
|
290
|
+
buttonIconName="MenuHamburger"
|
|
291
|
+
menuItems={menuItems}
|
|
292
|
+
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
|
|
293
|
+
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
|
|
294
|
+
/>`,
|
|
295
|
+
description: 'anchorOrigin은 트리거 버튼의 기준점, transformOrigin은 메뉴 자신의 기준점입니다. 화면 오른쪽 끝에 있는 버튼은 horizontal을 둘 다 right로 맞춰 메뉴가 화면 밖으로 나가지 않게 합니다.'
|
|
296
|
+
},
|
|
297
|
+
];
|
|
298
|
+
// CompanySelect 예제
|
|
299
|
+
export const CompanySelectExamples = [
|
|
300
|
+
{
|
|
301
|
+
title: 'CompanySelect - 회사 선택 (4개 prop 모두 필수)',
|
|
302
|
+
code: `const { OpsnowCommonCompanySelect } = useCommonComponents();
|
|
303
|
+
|
|
304
|
+
const companyOptions = [
|
|
305
|
+
{ label: 'Company A', value: 'companyA' },
|
|
306
|
+
{ label: 'Company B', value: 'companyB' },
|
|
307
|
+
{ label: 'Company C', value: 'companyC' },
|
|
308
|
+
];
|
|
309
|
+
|
|
310
|
+
const [currentCompanyName, setCurrentCompanyName] = useState('Select Company');
|
|
311
|
+
|
|
312
|
+
const handleSelect = (selected) => {
|
|
313
|
+
setCurrentCompanyName(selected?.label || 'Select Company');
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
<OpsnowCommonCompanySelect
|
|
317
|
+
currentCompanyName={currentCompanyName}
|
|
318
|
+
isExtended={isGnbExtended}
|
|
319
|
+
autocompleteOptions={companyOptions}
|
|
320
|
+
onSelect={handleSelect}
|
|
321
|
+
/>`,
|
|
322
|
+
description: 'GNB · 사이드바에서 회사(테넌트)를 바꾸는 선택기 예제입니다. currentCompanyName · isExtended · autocompleteOptions · onSelect 4개가 모두 필수입니다. isExtended는 사이드바가 펼쳐져 있는지 여부이고, onSelect는 선택한 항목 객체({ label, value })를 받습니다. 일반 페이지의 값 선택에는 Autocomplete를 쓰세요.'
|
|
323
|
+
},
|
|
324
|
+
];
|
|
@@ -58,3 +58,61 @@ export const TooltipExamples = [
|
|
|
58
58
|
description: "툴팁 닫힘 지연 시간 예제입니다.",
|
|
59
59
|
}
|
|
60
60
|
];
|
|
61
|
+
// IconTooltip 예제
|
|
62
|
+
export const IconTooltipExamples = [
|
|
63
|
+
{
|
|
64
|
+
title: "IconTooltip - OpsNow 아이콘 (useIcon + iconName, 라벨 옆 도움말)",
|
|
65
|
+
code: `const { OpsnowCommonIconTooltip } = useCommonComponents();
|
|
66
|
+
|
|
67
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
|
|
68
|
+
<OpsnowCommonTypography variant="e-m10">커버리지</OpsnowCommonTypography>
|
|
69
|
+
<OpsnowCommonIconTooltip
|
|
70
|
+
title="커버리지는 클라우드 사용량 중 약정으로 처리된 비율입니다."
|
|
71
|
+
useIcon
|
|
72
|
+
iconName="InfoCircleOutline"
|
|
73
|
+
/>
|
|
74
|
+
</Box>`,
|
|
75
|
+
description: "라벨 옆에 도움말 아이콘을 두는 가장 흔한 형태입니다. children 없이 단독으로 쓰며 아이콘을 직접 그립니다. useIcon을 주면 OpsNow 아이콘(iconName, 기본 InfoCircleOutline)이 표시됩니다. 옆 요소와의 정렬은 바깥 Box로 맞춥니다 (alignItems · justifyContent prop은 무시됨).",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
title: "IconTooltip - 아이콘 색 · 크기 · 넓은 툴팁 (commonColor · size · tooltipFullWidth · placement)",
|
|
79
|
+
code: `const { OpsnowCommonIconTooltip } = useCommonComponents();
|
|
80
|
+
const theme = useTheme();
|
|
81
|
+
|
|
82
|
+
<OpsnowCommonIconTooltip
|
|
83
|
+
title="Coverage represents the portion of your cloud usage that is covered by commitments."
|
|
84
|
+
useIcon
|
|
85
|
+
iconName="InfoCircleFiller"
|
|
86
|
+
commonColor={theme.palette.commonPalette.darkblue[500]}
|
|
87
|
+
size={20}
|
|
88
|
+
placement="right"
|
|
89
|
+
tooltipFullWidth
|
|
90
|
+
/>`,
|
|
91
|
+
description: "commonColor는 아이콘 색(CSS color 값, 기본 commonPalette.gray[600])이고 size는 OpsNow 아이콘 크기(px, 기본 16)입니다. tooltipFullWidth를 주면 툴팁 최대 너비(256px) 제한이 풀려 긴 문구가 한 줄로 나옵니다.",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
title: "IconTooltip - Material 아이콘 (useMuiIcon + label + muiColor)",
|
|
95
|
+
code: `const { OpsnowCommonIconTooltip } = useCommonComponents();
|
|
96
|
+
|
|
97
|
+
<OpsnowCommonIconTooltip
|
|
98
|
+
title="닫으면 다시 표시되지 않습니다."
|
|
99
|
+
useMuiIcon
|
|
100
|
+
label="info"
|
|
101
|
+
muiColor="primary"
|
|
102
|
+
/>`,
|
|
103
|
+
description: "Material 아이콘을 쓰는 예제입니다. label은 툴팁 문구가 아니라 Material 아이콘 이름입니다 (문구는 title). useIcon·useMuiIcon을 둘 다 생략하면 Material 아이콘으로 표시되므로 label을 꼭 지정하세요.",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
title: "IconTooltip - 이미지 미리보기 툴팁 (title에 JSX + tooltipPreview)",
|
|
107
|
+
code: `const { OpsnowCommonIconTooltip } = useCommonComponents();
|
|
108
|
+
|
|
109
|
+
<OpsnowCommonIconTooltip
|
|
110
|
+
title={<img src={previewImage} alt="화면 미리보기" style={{ width: '100%' }} />}
|
|
111
|
+
useIcon
|
|
112
|
+
placement="right"
|
|
113
|
+
tooltipPreview
|
|
114
|
+
tooltipFullWidth
|
|
115
|
+
/>`,
|
|
116
|
+
description: "title에 JSX(이미지)를 넣는 예제입니다. tooltipPreview를 주면 흰 배경 · 그림자 스타일의 미리보기 툴팁이 됩니다.",
|
|
117
|
+
},
|
|
118
|
+
];
|
|
@@ -181,6 +181,9 @@ export const XyMultiChartSchema = z.object({
|
|
|
181
181
|
// 증감률·화살표를 직접 넣지 말 것 — 컴포넌트가 포맷된 글자에서 숫자만 뽑아 증감률을 계산하므로 다른 숫자가 섞이면 계산이 틀어짐
|
|
182
182
|
// 3) chartData 각 행에 조회 기간 X값(valueXField)과 비교 기간 X값(compare.valueXField) 을 함께 넣음
|
|
183
183
|
// 툴팁 문자열은 색상 마크업([#f00]...[/])·HTML 을 해석하지 않으므로, 증감 색상은 이 타입으로만 표현 가능
|
|
184
|
+
// 증감률은 포맷된 글자의 숫자·소수점만 뽑아 계산 (고정 동작, 소수 2자리): 음수 부호는 무시되고, 비교 값이 없거나 0 이면 "100.00 %" 로 표시,
|
|
185
|
+
// 비율(%) 값은 %p 차이가 아니라 상대 증감률 (10% → 12% = 20.00 %)
|
|
186
|
+
// chartUserDefinedFunc 로 포맷할 때: 비교 그룹 호출에는 행의 모든 키가 들어오므로 해당 그룹의 카테고리 키만 골라서 처리
|
|
184
187
|
"withinArea": true, // 차트 영역 내에서만 툴팁 표시 여부
|
|
185
188
|
"stopActionEnabled": false, // true 면 키를 누르고 있는 동안 툴팁이 고정되어 툴팁 안을 스크롤·클릭할 수 있음 (기본 키: Ctrl)
|
|
186
189
|
"stopActionKey": "alt", // 툴팁 고정 키를 Alt 로 변경 (생략 시 Ctrl)
|
|
@@ -433,7 +436,7 @@ export const XyMultiChartSchema = z.object({
|
|
|
433
436
|
tooltipText: z.string().optional().describe("툴팁 텍스트, 파이 차트에서 사용")
|
|
434
437
|
}).describe('사용자 정의 카테고리 스타일 및 설정'))
|
|
435
438
|
.optional()
|
|
436
|
-
.describe("사용자 정의 카테고리 스타일 및
|
|
439
|
+
.describe("사용자 정의 카테고리 스타일 및 설정. **주의: 카테고리가 10개를 넘을 수 있으면(Top N + others, 전체 보기 등 개수가 데이터에 따라 달라지는 화면) 모든 카테고리에 color 를 지정하세요.** 기본 팔레트는 10색이고 순환하지 않아 11번째 카테고리부터 색이 undefined 가 되며 'Unknown color syntax: undefined' 오류로 차트가 렌더링되지 않습니다. 일부 카테고리만 넘기면 나머지는 기본 팔레트를 쓰므로 같은 오류가 납니다 — 전체 카테고리 수와 같은 개수로 넘겨야 지정한 색이 팔레트로 쓰입니다."),
|
|
437
440
|
chartUserDefinedFunc: z.record(z.string()).optional().describe('툴팁에서 사용하는 사용자 정의 함수(stringified)'),
|
|
438
441
|
langCd: z.string().optional().describe("언어 코드"),
|
|
439
442
|
onChartClick: z.string().optional().describe("차트 클릭 이벤트"),
|
|
@@ -2548,6 +2551,11 @@ export function createChartComponent() {
|
|
|
2548
2551
|
**Grouped Bar Chart(묶음 막대 차트)를 만들려면 이 컴포넌트를 사용하세요.**
|
|
2549
2552
|
series의 type을 'grouped'로 설정하면 각 카테고리에서 여러 시리즈의 막대가 나란히 배치됩니다.
|
|
2550
2553
|
|
|
2554
|
+
**주의: 카테고리(시리즈)가 10개를 넘을 수 있으면 chartCustomCategory 로 모든 카테고리에 color 를 지정하세요.**
|
|
2555
|
+
기본 팔레트는 10색이고 순환하지 않습니다. 11번째 카테고리부터 색이 없어
|
|
2556
|
+
"Unknown color syntax: undefined" 오류로 차트 전체가 렌더링되지 않습니다 (Top 10 + others = 11개가 흔한 사례).
|
|
2557
|
+
색은 팔레트 배열을 인덱스 % 길이로 순환시켜 만들면 됩니다.
|
|
2558
|
+
|
|
2551
2559
|
**import:**
|
|
2552
2560
|
\`\`\`javascript
|
|
2553
2561
|
import { useCommonComponents } from '@opsnow-common/opsnow-finops-common-ui-loader';
|
|
@@ -11,6 +11,8 @@ const SelectMenuItemSchema = z.object({
|
|
|
11
11
|
hasDivider: z.boolean().optional().describe("항목 아래 구분선 표시"),
|
|
12
12
|
selected: z.boolean().optional().describe("선택 상태 표시"),
|
|
13
13
|
disabled: z.boolean().optional().describe("비활성화"),
|
|
14
|
+
labelPreComponent: z.string().optional().describe("라벨 앞(아이콘 뒤)에 붙일 JSX (예: 상태 칩 <OpsnowCommonChip label=\"New\" color=\"success\" size=\"small\" />)"),
|
|
15
|
+
actionComponent: z.string().optional().describe("항목 오른쪽 끝에 붙일 JSX (예: 작은 액션 버튼)"),
|
|
14
16
|
keepOpenOnClick: z.boolean().optional().describe("클릭 후에도 메뉴를 닫지 않음 (기본 false — 토글 항목 등에만 true)"),
|
|
15
17
|
});
|
|
16
18
|
export const SelectMenuSchema = z.object({
|
|
@@ -52,7 +54,7 @@ export function createDropdownComponent() {
|
|
|
52
54
|
const items = args.menuItems.map(item => {
|
|
53
55
|
const fields = Object.entries(item)
|
|
54
56
|
.filter(([, v]) => v !== undefined)
|
|
55
|
-
.map(([k, v]) => (
|
|
57
|
+
.map(([k, v]) => (["onClick", "labelPreComponent", "actionComponent"].includes(k) ? `${k}: ${v}` : `${k}: ${JSON.stringify(v)}`));
|
|
56
58
|
return `{ ${fields.join(", ")} }`;
|
|
57
59
|
});
|
|
58
60
|
const { menuItems: _menuItems, ...rest } = args;
|
|
@@ -1,8 +1,8 @@
|
|
|
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";
|
|
1
|
+
import { ButtonExamples, BadgeExamples, TextareaExamples, SwitchExamples, ChipExamples, TextFieldExamples, AvatarExamples, CheckboxExamples, RadioGroupExamples, CollapseExamples, SliderExamples, LinkExamples, TreeViewExamples, InsightCardExamples, InsightContentExamples, CurrencySwitcherExamples, ToggleButtonExamples, CardExamples, CardGroupExamples, ChipGroupExamples, CheckboxGroupExamples } from "./examples/opsnow-common-forms-examples-data.js";
|
|
2
2
|
import { IconExamples, MuiIconExamples, MarkersExamples } 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";
|
|
5
|
-
import { TooltipExamples } from "./examples/opsnow-common-tooltip-examples-data.js";
|
|
5
|
+
import { TooltipExamples, IconTooltipExamples } from "./examples/opsnow-common-tooltip-examples-data.js";
|
|
6
6
|
import { CoachMarkExamples } from "./examples/opsnow-common-coach-mark-examples-data.js";
|
|
7
7
|
import { DataGridExamples } from "./examples/opsnow-common-grid-examples-data.js";
|
|
8
8
|
import { PopupExamples } from "./examples/opsnow-common-popup-examples-data.js";
|
|
@@ -18,8 +18,9 @@ import { ProgressExamples, LoadingExamples } from "./examples/opsnow-common-prog
|
|
|
18
18
|
import { TabExamples } from "./examples/opsnow-common-tab-examples-data.js";
|
|
19
19
|
import { GridLayoutExamples, MegaFilterExamples } from "./examples/opsnow-common-layout-examples-data.js";
|
|
20
20
|
import { TypographyExamples } from "./examples/opsnow-common-typography-examples-data.js";
|
|
21
|
-
import { AutocompleteExamples } from "./examples/opsnow-common-select-examples-data.js";
|
|
21
|
+
import { AutocompleteExamples, SelectMenuExamples, CompanySelectExamples } from "./examples/opsnow-common-select-examples-data.js";
|
|
22
22
|
import { z } from "zod";
|
|
23
|
+
import { UIDEMO_BASE_URL, looksLikeDemoUrl, renderDemoMatch, searchDemosByLabel, renderLabelHits } from "./data/uidemo-routes.js";
|
|
23
24
|
export const EXAMPLES_MAP = {
|
|
24
25
|
Button: ButtonExamples,
|
|
25
26
|
Badge: BadgeExamples,
|
|
@@ -69,6 +70,13 @@ export const EXAMPLES_MAP = {
|
|
|
69
70
|
MegaFilter: MegaFilterExamples,
|
|
70
71
|
Typography: TypographyExamples,
|
|
71
72
|
Autocomplete: AutocompleteExamples,
|
|
73
|
+
SelectMenu: SelectMenuExamples,
|
|
74
|
+
CompanySelect: CompanySelectExamples,
|
|
75
|
+
Card: CardExamples,
|
|
76
|
+
CardGroup: CardGroupExamples,
|
|
77
|
+
ChipGroup: ChipGroupExamples,
|
|
78
|
+
CheckboxGroup: CheckboxGroupExamples,
|
|
79
|
+
IconTooltip: IconTooltipExamples,
|
|
72
80
|
};
|
|
73
81
|
// ============= 토큰 절감: 대형 예제는 목록 모드 =============
|
|
74
82
|
// 예제 전문 합계가 이 바이트를 넘으면 제목 목록을 먼저 반환 (keyword로 필요한 것만 조회)
|
|
@@ -131,23 +139,28 @@ function buildListResponse(resolvedType, examples, header) {
|
|
|
131
139
|
export const UIExamplesSchema = z.object({
|
|
132
140
|
uiType: z
|
|
133
141
|
.string()
|
|
134
|
-
.describe(`UI 컴포넌트 예제명 (예: 'Button', 'Icon') 호출 가능한 예제 항목: ${Object.keys(EXAMPLES_MAP).join(", ")}`),
|
|
142
|
+
.describe(`UI 컴포넌트 예제명 (예: 'Button', 'Icon'), 또는 uidemo 데모 링크(${UIDEMO_BASE_URL}/... URL 전체). 호출 가능한 예제 항목: ${Object.keys(EXAMPLES_MAP).join(", ")}`),
|
|
135
143
|
keyword: z
|
|
136
144
|
.string()
|
|
137
145
|
.optional()
|
|
138
|
-
.describe("예제 제목/설명/코드에서 검색할 키워드 (부분 일치, 대소문자 무시). 예제가 큰 컴포넌트에서 특정 패턴만 조회할 때 사용. '*'를 넣으면 전체 예제 반환"),
|
|
146
|
+
.describe("예제 제목/설명/코드에서 검색할 키워드 (부분 일치, 대소문자 무시). uidemo 데모 화면에 보이는 예제 제목(예: 'Base Interval Month', 'Single Select - do not close on select')도 그대로 넣을 수 있음. 예제가 큰 컴포넌트에서 특정 패턴만 조회할 때 사용. '*'를 넣으면 전체 예제 반환"),
|
|
139
147
|
});
|
|
140
148
|
export function createCommonExamplesComponent() {
|
|
141
149
|
return [
|
|
142
150
|
{
|
|
143
151
|
name: "getUIExamples",
|
|
144
152
|
description: `OpsNow 공통 UI 컴포넌트 예제를 반환합니다.
|
|
145
|
-
uiType: string (예: 'Button', 'Icon') -
|
|
153
|
+
uiType: string (예: 'Button', 'Icon') - 필수. uidemo 데모 링크(${UIDEMO_BASE_URL}/...)를 그대로 넣으면 그 화면의 컴포넌트·예제 호출문을 반환합니다.
|
|
154
|
+
uidemo 데모 화면의 예제 제목으로도 찾습니다 — keyword 에 그 제목을 넣거나, 컴포넌트를 모르면 uiType 에 제목만 넣으면 해당 예제 호출문을 안내합니다.
|
|
146
155
|
keyword: string - 선택. 예제 분량이 큰 컴포넌트는 핵심 예제 전문 + 제목 목록이 먼저 반환되며, 목록에서 고른 키워드로 다시 호출하면 해당 예제 전문을 받습니다. '*'는 전체 반환.
|
|
147
156
|
호출 가능한 예제 항목: ${Object.keys(EXAMPLES_MAP).join(', ')}`,
|
|
148
157
|
parameters: UIExamplesSchema,
|
|
149
158
|
handler: async (args) => {
|
|
150
159
|
const type = args.uiType;
|
|
160
|
+
// uidemo 데모 링크
|
|
161
|
+
if (type && looksLikeDemoUrl(type)) {
|
|
162
|
+
return { content: [{ type: "text", text: renderDemoMatch(type) }] };
|
|
163
|
+
}
|
|
151
164
|
if (!type) {
|
|
152
165
|
return {
|
|
153
166
|
content: [{
|
|
@@ -160,6 +173,11 @@ keyword: string - 선택. 예제 분량이 큰 컴포넌트는 핵심 예제 전
|
|
|
160
173
|
const resolvedType = resolveUiType(type);
|
|
161
174
|
// 2. 매칭 실패 → 빈 응답 대신 복붙 가능한 대안 호출문 반환
|
|
162
175
|
if (!resolvedType) {
|
|
176
|
+
// uiType 자리에 uidemo 데모 화면의 예제 제목이 온 경우
|
|
177
|
+
const labelHits = searchDemosByLabel(args.keyword?.trim() || type);
|
|
178
|
+
if (labelHits.length > 0) {
|
|
179
|
+
return { content: [{ type: "text", text: renderLabelHits(args.keyword?.trim() || type, labelHits) }] };
|
|
180
|
+
}
|
|
163
181
|
const target = normalize(type);
|
|
164
182
|
const candidates = Object.keys(EXAMPLES_MAP).filter(k => normalize(k).includes(target) || target.includes(normalize(k)));
|
|
165
183
|
const listed = (candidates.length > 0 ? candidates : Object.keys(EXAMPLES_MAP))
|
|
@@ -178,8 +196,33 @@ keyword: string - 선택. 예제 분량이 큰 컴포넌트는 핵심 예제 전
|
|
|
178
196
|
return { content: examples.map(exampleToContent) };
|
|
179
197
|
}
|
|
180
198
|
const kw = keyword.toLowerCase();
|
|
199
|
+
// 0차: 제목 완전 일치
|
|
200
|
+
const exact = examples.filter(ex => ex.title.toLowerCase() === kw);
|
|
201
|
+
if (exact.length > 0) {
|
|
202
|
+
return { content: exact.map(exampleToContent) };
|
|
203
|
+
}
|
|
204
|
+
// uidemo 데모 화면의 예제 제목 → 연결된 예제
|
|
205
|
+
const pickByDemo = (exactOnly) => {
|
|
206
|
+
const hits = searchDemosByLabel(keyword, resolvedType).filter(h => h.exact || !exactOnly);
|
|
207
|
+
const out = new Set();
|
|
208
|
+
for (const h of hits) {
|
|
209
|
+
const t = h.demo.title, k = h.demo.keyword?.toLowerCase();
|
|
210
|
+
if (t)
|
|
211
|
+
examples.filter(ex => ex.title === t).forEach(ex => out.add(ex));
|
|
212
|
+
else if (k)
|
|
213
|
+
examples.filter(ex => ex.title.toLowerCase().includes(k) || ex.description.toLowerCase().includes(k)).forEach(ex => out.add(ex));
|
|
214
|
+
}
|
|
215
|
+
return [...out];
|
|
216
|
+
};
|
|
217
|
+
const byDemoExact = pickByDemo(true);
|
|
218
|
+
if (byDemoExact.length > 0) {
|
|
219
|
+
return { content: byDemoExact.map(exampleToContent) };
|
|
220
|
+
}
|
|
181
221
|
// 1차: 제목/설명 매칭, 2차: 코드 내용 매칭 (기술 용어로 찍는 경우 대응)
|
|
182
222
|
let matched = examples.filter(ex => ex.title.toLowerCase().includes(kw) || ex.description.toLowerCase().includes(kw));
|
|
223
|
+
// 3차: 데모 제목 부분 일치
|
|
224
|
+
if (matched.length === 0)
|
|
225
|
+
matched = pickByDemo(false);
|
|
183
226
|
if (matched.length === 0) {
|
|
184
227
|
matched = examples.filter(ex => ex.code.toLowerCase().includes(kw) || (ex.code_props_usage ?? "").toLowerCase().includes(kw));
|
|
185
228
|
}
|
|
@@ -114,6 +114,10 @@ export function createSelectComponent() {
|
|
|
114
114
|
{
|
|
115
115
|
name: "createAutocompleteSelect",
|
|
116
116
|
description: `오토컴플리트 셀렉트 컴포넌트 예제입니다.
|
|
117
|
+
**"체크박스로 고르는 필터 + 전체 선택 + 검색" 요청의 기본 선택입니다** — 드롭다운을 열어 체크박스로 여러 개 고르는 필터(계정·제품·리전 등)는
|
|
118
|
+
multiple + useCheckboxOption + useSelectAll 로 만듭니다. 입력창에 타이핑하면 옵션이 검색되므로 검색창을 따로 붙이지 않습니다.
|
|
119
|
+
다중 선택의 value 는 값 배열이 아니라 **items 원소(객체) 배열**입니다 — onChange 로도 객체 배열이 옵니다.
|
|
120
|
+
(화면에 항상 펼쳐진 체크박스 목록이 필요할 때만 CheckboxGroup)
|
|
117
121
|
- 그룹 옵션 및 전체 선택 옵션 지원
|
|
118
122
|
- items: 옵션 배열 (value, label, group, iconName, disabled 등 지원)
|
|
119
123
|
- multiple, useCheckboxOption, useSelectAll, disableCloseOnSelect, loading 등 다양한 props 지원
|