@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
|
@@ -1880,3 +1880,423 @@ export const ToggleButtonExamples = [
|
|
|
1880
1880
|
description: 'Medium size disabled toggle button group 예제입니다.'
|
|
1881
1881
|
}
|
|
1882
1882
|
];
|
|
1883
|
+
// Card 예제
|
|
1884
|
+
export const CardExamples = [
|
|
1885
|
+
{
|
|
1886
|
+
title: 'Card - 표시만 (기본 outlined · padding · variant="plain")',
|
|
1887
|
+
code: `const { OpsnowCommonCard } = useCommonComponents();
|
|
1888
|
+
|
|
1889
|
+
<Box sx={{ display: 'flex', gap: 2, flexWrap: 'wrap' }}>
|
|
1890
|
+
{/* 기본: 모서리 12 · 테두리 1px gray200 · 여백 16px 20px */}
|
|
1891
|
+
<OpsnowCommonCard sx={{ width: 280 }}>
|
|
1892
|
+
<OpsnowCommonTypography variant="e-r11" theme="description">이번 달 비용</OpsnowCommonTypography>
|
|
1893
|
+
<Box sx={{ mt: 1 }}>
|
|
1894
|
+
<OpsnowCommonTypography variant="e-b6">$128,400</OpsnowCommonTypography>
|
|
1895
|
+
</Box>
|
|
1896
|
+
</OpsnowCommonCard>
|
|
1897
|
+
|
|
1898
|
+
{/* 여백을 넓힐 때 (설정 화면 섹션 상자 등) */}
|
|
1899
|
+
<OpsnowCommonCard padding={24} sx={{ width: 280 }}>
|
|
1900
|
+
<OpsnowCommonTypography variant="e-m7">섹션 제목</OpsnowCommonTypography>
|
|
1901
|
+
</OpsnowCommonCard>
|
|
1902
|
+
|
|
1903
|
+
{/* plain: 상자 없이 영역만 — 모양은 화면이 sx로 그린다 */}
|
|
1904
|
+
<OpsnowCommonCard variant="plain" padding={16} sx={{ width: 280, bgcolor: 'action.hover', borderRadius: '8px' }}>
|
|
1905
|
+
<OpsnowCommonTypography variant="e-m7">상자 없는 영역</OpsnowCommonTypography>
|
|
1906
|
+
</OpsnowCommonCard>
|
|
1907
|
+
</Box>`,
|
|
1908
|
+
description: '내용 상자·지표 카드로 쓰는 기본 Card 예제입니다. 크기(width)는 sx로 화면이 정하고, 안쪽 여백은 padding(숫자=px)으로 바꿉니다. variant="plain"이면 테두리·배경·여백 없이 영역만 둡니다.'
|
|
1909
|
+
},
|
|
1910
|
+
{
|
|
1911
|
+
title: 'Card - 클릭 · 선택 표시 (onClick · selected · disabled)',
|
|
1912
|
+
code: `const { OpsnowCommonCard } = useCommonComponents();
|
|
1913
|
+
const { OpsnowCommonIcon } = useOpsnowCommonIcons();
|
|
1914
|
+
const [pinned, setPinned] = useState(false);
|
|
1915
|
+
|
|
1916
|
+
<Box sx={{ display: 'flex', gap: 2, flexWrap: 'wrap' }}>
|
|
1917
|
+
{/* onClick 을 주면 버튼 카드 (Enter · Space 도 동작) */}
|
|
1918
|
+
<OpsnowCommonCard sx={{ width: 220 }} onClick={() => navigate('/detail')}>
|
|
1919
|
+
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
|
1920
|
+
<OpsnowCommonTypography variant="e-m10">상세 보기</OpsnowCommonTypography>
|
|
1921
|
+
<OpsnowCommonIcon iconName="ChevronRight" size={16} />
|
|
1922
|
+
</Box>
|
|
1923
|
+
</OpsnowCommonCard>
|
|
1924
|
+
|
|
1925
|
+
{/* selected + onClick: 토글 카드 (aria-pressed) */}
|
|
1926
|
+
<OpsnowCommonCard sx={{ width: 220 }} selected={pinned} onClick={() => setPinned((v) => !v)}>
|
|
1927
|
+
<OpsnowCommonTypography variant="e-m10">{pinned ? '고정됨' : '눌러서 고정'}</OpsnowCommonTypography>
|
|
1928
|
+
</OpsnowCommonCard>
|
|
1929
|
+
|
|
1930
|
+
<OpsnowCommonCard sx={{ width: 220 }} disabled onClick={() => {}}>
|
|
1931
|
+
<OpsnowCommonTypography variant="e-m10">비활성</OpsnowCommonTypography>
|
|
1932
|
+
</OpsnowCommonCard>
|
|
1933
|
+
</Box>`,
|
|
1934
|
+
description: 'onClick을 주면 카드가 버튼이 되고, selected를 같이 주면 선택 테두리가 있는 토글 카드가 됩니다. 여러 장 중에서 고르는 UI는 Card를 나열하지 말고 CardGroup(selectionMode)을 쓰세요.'
|
|
1935
|
+
},
|
|
1936
|
+
];
|
|
1937
|
+
// CardGroup 예제
|
|
1938
|
+
export const CardGroupExamples = [
|
|
1939
|
+
{
|
|
1940
|
+
title: 'CardGroup - 표시만 (요약 카드 줄, columns 반응형)',
|
|
1941
|
+
code: `const { OpsnowCommonCardGroup } = useCommonComponents();
|
|
1942
|
+
|
|
1943
|
+
const COST_CARDS = [
|
|
1944
|
+
{ value: 'current', label: '이번 달 비용', amount: '$128,400' },
|
|
1945
|
+
{ value: 'last', label: '지난달 비용', amount: '$123,210' },
|
|
1946
|
+
{ value: 'forecast', label: '예상 비용', amount: '$131,900' },
|
|
1947
|
+
{ value: 'savings', label: '절감 비용', amount: '$9,870' },
|
|
1948
|
+
];
|
|
1949
|
+
|
|
1950
|
+
<OpsnowCommonCardGroup
|
|
1951
|
+
aria-label="비용 요약"
|
|
1952
|
+
items={COST_CARDS}
|
|
1953
|
+
columns={{ xs: 1, sm: 2, md: 4 }}
|
|
1954
|
+
gap={10}
|
|
1955
|
+
renderCard={(item) => (
|
|
1956
|
+
<>
|
|
1957
|
+
<OpsnowCommonTypography variant="e-r11" theme="description">{item.label}</OpsnowCommonTypography>
|
|
1958
|
+
<Box sx={{ mt: 1 }}>
|
|
1959
|
+
<OpsnowCommonTypography variant="e-b6">{item.amount}</OpsnowCommonTypography>
|
|
1960
|
+
</Box>
|
|
1961
|
+
</>
|
|
1962
|
+
)}
|
|
1963
|
+
/>`,
|
|
1964
|
+
description: 'selectionMode를 생략하면(none) 누를 수 없는 요약 카드 줄입니다. 그룹은 배치와 카드 모양만 맞추고, 카드 내용은 renderCard가 그립니다. items에는 value·label 외의 값(amount 등)을 함께 실어 renderCard에서 쓸 수 있습니다. columns는 숫자 또는 브레이크포인트별 열 수입니다.'
|
|
1965
|
+
},
|
|
1966
|
+
{
|
|
1967
|
+
title: 'CardGroup - 클릭 카드 (onCardClick, 이동 · 팝업)',
|
|
1968
|
+
code: `const { OpsnowCommonCardGroup } = useCommonComponents();
|
|
1969
|
+
const { OpsnowCommonIcon } = useOpsnowCommonIcons();
|
|
1970
|
+
|
|
1971
|
+
const STATUS_CARDS = [
|
|
1972
|
+
{ value: 'all', label: '전체', count: 120 },
|
|
1973
|
+
{ value: 'active', label: '활성', count: 84 },
|
|
1974
|
+
{ value: 'expired', label: '만료', count: 21 },
|
|
1975
|
+
{ value: 'deactivated', label: '비활성', count: 15 },
|
|
1976
|
+
];
|
|
1977
|
+
|
|
1978
|
+
<OpsnowCommonCardGroup
|
|
1979
|
+
aria-label="상태별 목록으로 이동"
|
|
1980
|
+
items={STATUS_CARDS}
|
|
1981
|
+
columns={{ xs: 1, sm: 2, md: 4 }}
|
|
1982
|
+
gap={8}
|
|
1983
|
+
onCardClick={(_, item) => navigate('/list?status=' + item.value)}
|
|
1984
|
+
renderCard={(item) => (
|
|
1985
|
+
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
|
1986
|
+
<OpsnowCommonTypography variant="e-m10">{item.label} {item.count.toLocaleString()}</OpsnowCommonTypography>
|
|
1987
|
+
<OpsnowCommonIcon iconName="ChevronRight" size={16} />
|
|
1988
|
+
</Box>
|
|
1989
|
+
)}
|
|
1990
|
+
/>`,
|
|
1991
|
+
description: '선택 표시 없이 카드가 버튼이 되는 예제입니다(Enter · Space도 동작). onCardClick의 둘째 인자가 누른 item입니다.'
|
|
1992
|
+
},
|
|
1993
|
+
{
|
|
1994
|
+
title: 'CardGroup - 단일 선택 (selectionMode="single", value · onChange · cardSx)',
|
|
1995
|
+
code: `const { OpsnowCommonCardGroup } = useCommonComponents();
|
|
1996
|
+
const [costCard, setCostCard] = useState('current');
|
|
1997
|
+
|
|
1998
|
+
const COST_CARDS = [
|
|
1999
|
+
{ value: 'current', label: '이번 달 비용', amount: '$128,400', diff: '+4.2%' },
|
|
2000
|
+
{ value: 'last', label: '지난달 비용', amount: '$123,210', diff: '-1.8%' },
|
|
2001
|
+
{ value: 'forecast', label: '예상 비용', amount: '$131,900', diff: '+2.7%' },
|
|
2002
|
+
{ value: 'savings', label: '절감 비용', amount: '$9,870', diff: '+12.0%' },
|
|
2003
|
+
];
|
|
2004
|
+
|
|
2005
|
+
<OpsnowCommonCardGroup
|
|
2006
|
+
selectionMode="single"
|
|
2007
|
+
aria-label="비용 구분"
|
|
2008
|
+
items={COST_CARDS}
|
|
2009
|
+
value={costCard}
|
|
2010
|
+
onChange={(_, v) => setCostCard(v)}
|
|
2011
|
+
columns={{ xs: 1, sm: 2, md: 4 }}
|
|
2012
|
+
gap={10}
|
|
2013
|
+
cardSx={{ minHeight: 120 }}
|
|
2014
|
+
renderCard={(item, state) => (
|
|
2015
|
+
<>
|
|
2016
|
+
<OpsnowCommonTypography variant="e-r11" theme="description">{item.label}</OpsnowCommonTypography>
|
|
2017
|
+
<Box sx={{ mt: 1 }}>
|
|
2018
|
+
<OpsnowCommonTypography variant="e-b6">{item.amount}</OpsnowCommonTypography>
|
|
2019
|
+
</Box>
|
|
2020
|
+
<OpsnowCommonTypography
|
|
2021
|
+
variant="e-r12"
|
|
2022
|
+
color={item.diff.startsWith('-') ? 'commonPalette.green.500' : 'commonPalette.red.500'}
|
|
2023
|
+
>
|
|
2024
|
+
전월 대비 {item.diff}
|
|
2025
|
+
</OpsnowCommonTypography>
|
|
2026
|
+
</>
|
|
2027
|
+
)}
|
|
2028
|
+
/>`,
|
|
2029
|
+
description: '카드 중 하나를 고르는 예제입니다. onChange의 둘째 인자가 새 값입니다 — (_, v) => setValue(v). 선택 테두리·키보드 이동은 그룹이 처리하고, 고른 카드를 다시 눌러도 풀리지 않습니다(allowEmpty로 변경). renderCard의 state.selected로 선택된 카드 안쪽 모양을 바꿀 수 있습니다.'
|
|
2030
|
+
},
|
|
2031
|
+
{
|
|
2032
|
+
title: 'CardGroup - 고정 크기 타일 (sx gridTemplateColumns · cardSx height · state.selected)',
|
|
2033
|
+
code: `const { OpsnowCommonCardGroup } = useCommonComponents();
|
|
2034
|
+
const [monthTile, setMonthTile] = useState('this_month');
|
|
2035
|
+
|
|
2036
|
+
const MONTH_TILES = [
|
|
2037
|
+
{ value: 'last_month', label: '지난달', score: 82 },
|
|
2038
|
+
{ value: 'this_month', label: '이번달', score: 76 },
|
|
2039
|
+
];
|
|
2040
|
+
|
|
2041
|
+
<OpsnowCommonCardGroup
|
|
2042
|
+
selectionMode="single"
|
|
2043
|
+
aria-label="기준월"
|
|
2044
|
+
items={MONTH_TILES}
|
|
2045
|
+
value={monthTile}
|
|
2046
|
+
onChange={(_, v) => setMonthTile(v)}
|
|
2047
|
+
sx={{ gridTemplateColumns: 'repeat(2, 260px)' }}
|
|
2048
|
+
cardSx={{ height: 160 }}
|
|
2049
|
+
renderCard={(item, state) => (
|
|
2050
|
+
<>
|
|
2051
|
+
<OpsnowCommonTypography variant="e-b8">{item.label}</OpsnowCommonTypography>
|
|
2052
|
+
<Box
|
|
2053
|
+
sx={(theme) => ({
|
|
2054
|
+
mt: 2,
|
|
2055
|
+
p: 2,
|
|
2056
|
+
borderRadius: '8px',
|
|
2057
|
+
backgroundColor: state.selected ? theme.palette.commonPalette.gray[100] : 'transparent',
|
|
2058
|
+
})}
|
|
2059
|
+
>
|
|
2060
|
+
<OpsnowCommonTypography variant="e-m10">KPI 점수 {item.score}</OpsnowCommonTypography>
|
|
2061
|
+
</Box>
|
|
2062
|
+
</>
|
|
2063
|
+
)}
|
|
2064
|
+
/>`,
|
|
2065
|
+
description: '카드 폭을 고정할 때는 그룹 sx의 gridTemplateColumns로, 높이는 cardSx로 정합니다. 선택된 카드 안쪽 모양은 renderCard의 state.selected로 그립니다.'
|
|
2066
|
+
},
|
|
2067
|
+
{
|
|
2068
|
+
title: 'CardGroup - 다중 선택 + 비활성 카드 (selectionMode="multiple", minCardWidth)',
|
|
2069
|
+
code: `const { OpsnowCommonCardGroup, OpsnowCommonCheckbox } = useCommonComponents();
|
|
2070
|
+
const [rightSizing, setRightSizing] = useState(['DOWNSIZE']);
|
|
2071
|
+
|
|
2072
|
+
const RIGHTSIZING_CARDS = [
|
|
2073
|
+
{ value: 'DOWNSIZE', label: '사양 낮추기', count: 18 },
|
|
2074
|
+
{ value: 'UPSIZE', label: '사양 높이기', count: 4 },
|
|
2075
|
+
{ value: 'MODERNIZE', label: '최신 세대로', count: 0, disabled: true },
|
|
2076
|
+
];
|
|
2077
|
+
|
|
2078
|
+
// 카드가 선택 단위라 안쪽 체크박스는 장식 (포커스 · 클릭을 받지 않게)
|
|
2079
|
+
const decorative = { tabIndex: -1, 'aria-hidden': true, sx: { pointerEvents: 'none', p: 0 } };
|
|
2080
|
+
|
|
2081
|
+
<OpsnowCommonCardGroup
|
|
2082
|
+
aria-label="추천 유형"
|
|
2083
|
+
selectionMode="multiple"
|
|
2084
|
+
items={RIGHTSIZING_CARDS}
|
|
2085
|
+
value={rightSizing}
|
|
2086
|
+
onChange={(_, v) => setRightSizing(v)}
|
|
2087
|
+
minCardWidth={200}
|
|
2088
|
+
renderCard={(item, state) => (
|
|
2089
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
2090
|
+
<OpsnowCommonCheckbox {...decorative} checked={state.selected} disabled={state.disabled} size="small" color="primary" />
|
|
2091
|
+
<OpsnowCommonTypography variant="e-m10">{item.label} ({item.count})</OpsnowCommonTypography>
|
|
2092
|
+
</Box>
|
|
2093
|
+
)}
|
|
2094
|
+
/>`,
|
|
2095
|
+
description: '여러 장을 고르는 필터 카드 예제입니다. value는 배열이고 onChange 둘째 인자로 새 배열이 옵니다. 항목에 disabled: true를 주면 흐리게 표시되고 선택할 수 없습니다. columns 대신 minCardWidth를 주면 폭에 맞춰 열 수가 채워집니다.'
|
|
2096
|
+
},
|
|
2097
|
+
];
|
|
2098
|
+
// ChipGroup 예제
|
|
2099
|
+
export const ChipGroupExamples = [
|
|
2100
|
+
{
|
|
2101
|
+
title: 'ChipGroup - 단일 선택 카테고리 필터 (renderLabel로 개수 표시)',
|
|
2102
|
+
code: `const { OpsnowCommonChipGroup } = useCommonComponents();
|
|
2103
|
+
const [category, setCategory] = useState('all');
|
|
2104
|
+
|
|
2105
|
+
const CATEGORIES = [
|
|
2106
|
+
{ value: 'all', label: '전체' },
|
|
2107
|
+
{ value: 'cost', label: '비용' },
|
|
2108
|
+
{ value: 'security', label: '보안' },
|
|
2109
|
+
{ value: 'operation', label: '운영' },
|
|
2110
|
+
];
|
|
2111
|
+
const CATEGORY_COUNTS = { all: 42, cost: 20, security: 12, operation: 10 };
|
|
2112
|
+
|
|
2113
|
+
<OpsnowCommonChipGroup
|
|
2114
|
+
aria-label="카테고리"
|
|
2115
|
+
items={CATEGORIES}
|
|
2116
|
+
value={category}
|
|
2117
|
+
onChange={(_, v) => setCategory(v)}
|
|
2118
|
+
renderLabel={(item) => item.label + ' ' + CATEGORY_COUNTS[item.value]}
|
|
2119
|
+
/>`,
|
|
2120
|
+
description: '칩 하나를 고르는 필터 예제입니다. onChange의 둘째 인자가 새 값입니다. 단일 선택은 고른 칩을 다시 눌러도 풀리지 않으므로 「전체」는 값 없음 대신 항목으로 둡니다. renderLabel로 칩 안 내용을 바꿉니다.'
|
|
2121
|
+
},
|
|
2122
|
+
{
|
|
2123
|
+
title: 'ChipGroup - 고른 칩만 filled (variant="outlined" + selectedVariant="filled")',
|
|
2124
|
+
code: `const { OpsnowCommonChipGroup } = useCommonComponents();
|
|
2125
|
+
const [template, setTemplate] = useState('tpl-basic');
|
|
2126
|
+
|
|
2127
|
+
const TEMPLATES = [
|
|
2128
|
+
{ value: 'tpl-basic', label: '기본 KPI' },
|
|
2129
|
+
{ value: 'tpl-cost', label: '비용 최적화' },
|
|
2130
|
+
{ value: 'tpl-tag', label: '태그 준수율' },
|
|
2131
|
+
];
|
|
2132
|
+
|
|
2133
|
+
<OpsnowCommonChipGroup
|
|
2134
|
+
aria-label="템플릿"
|
|
2135
|
+
items={TEMPLATES}
|
|
2136
|
+
value={template}
|
|
2137
|
+
onChange={(_, v) => setTemplate(v)}
|
|
2138
|
+
variant="outlined"
|
|
2139
|
+
selectedVariant="filled"
|
|
2140
|
+
/>`,
|
|
2141
|
+
description: '고른 칩은 filled, 나머지는 outlined로 표시하는 예제입니다. 색은 selectedColor(기본 primary)·color(기본 default)로 바꿉니다.'
|
|
2142
|
+
},
|
|
2143
|
+
{
|
|
2144
|
+
title: 'ChipGroup - 다중 선택 (multiple, value 배열)',
|
|
2145
|
+
code: `const { OpsnowCommonChipGroup } = useCommonComponents();
|
|
2146
|
+
const [vendors, setVendors] = useState(['aws', 'gcp']);
|
|
2147
|
+
|
|
2148
|
+
const VENDORS = [
|
|
2149
|
+
{ value: 'aws', label: 'AWS' },
|
|
2150
|
+
{ value: 'azure', label: 'Azure' },
|
|
2151
|
+
{ value: 'gcp', label: 'GCP' },
|
|
2152
|
+
];
|
|
2153
|
+
|
|
2154
|
+
<OpsnowCommonChipGroup
|
|
2155
|
+
aria-label="클라우드"
|
|
2156
|
+
multiple
|
|
2157
|
+
items={VENDORS}
|
|
2158
|
+
value={vendors}
|
|
2159
|
+
onChange={(_, v) => setVendors(v)}
|
|
2160
|
+
/>`,
|
|
2161
|
+
description: '여러 칩을 고르는 예제입니다. multiple이면 value는 배열이고, 모두 해제한 빈 배열도 허용됩니다(allowEmpty={false}로 막을 수 있음).'
|
|
2162
|
+
},
|
|
2163
|
+
{
|
|
2164
|
+
title: 'ChipGroup - 칩 모양 직접 그리기 (renderItem + itemProps)',
|
|
2165
|
+
code: `const { OpsnowCommonChipGroup } = useCommonComponents();
|
|
2166
|
+
const { OpsnowCommonIcon } = useOpsnowCommonIcons();
|
|
2167
|
+
const [vendors, setVendors] = useState(['aws', 'gcp']);
|
|
2168
|
+
|
|
2169
|
+
const VENDORS = [
|
|
2170
|
+
{ value: 'aws', label: 'AWS', icon: 'LogoAws', accounts: 35 },
|
|
2171
|
+
{ value: 'azure', label: 'Azure', icon: 'LogoAzure', accounts: 11 },
|
|
2172
|
+
{ value: 'gcp', label: 'GCP', icon: 'LogoGcp', accounts: 8 },
|
|
2173
|
+
];
|
|
2174
|
+
|
|
2175
|
+
<OpsnowCommonChipGroup
|
|
2176
|
+
aria-label="클라우드"
|
|
2177
|
+
multiple
|
|
2178
|
+
items={VENDORS}
|
|
2179
|
+
value={vendors}
|
|
2180
|
+
onChange={(_, v) => setVendors(v)}
|
|
2181
|
+
renderItem={(item, state, itemProps) => (
|
|
2182
|
+
<Box
|
|
2183
|
+
{...itemProps}
|
|
2184
|
+
sx={(theme) => ({
|
|
2185
|
+
display: 'flex',
|
|
2186
|
+
alignItems: 'center',
|
|
2187
|
+
gap: 0.75,
|
|
2188
|
+
height: 40,
|
|
2189
|
+
px: 1.25,
|
|
2190
|
+
borderRadius: '4px',
|
|
2191
|
+
cursor: 'pointer',
|
|
2192
|
+
border: '1px solid',
|
|
2193
|
+
borderColor: state.selected ? theme.palette.commonPalette.blue[300] : theme.palette.commonPalette.gray[300],
|
|
2194
|
+
backgroundColor: state.selected ? theme.palette.commonPalette.blue[50] : 'transparent',
|
|
2195
|
+
opacity: state.selected ? 1 : 0.55,
|
|
2196
|
+
})}
|
|
2197
|
+
>
|
|
2198
|
+
<OpsnowCommonIcon size={16} iconName={item.icon} />
|
|
2199
|
+
<OpsnowCommonTypography variant="e-b10">{item.label}</OpsnowCommonTypography>
|
|
2200
|
+
<OpsnowCommonTypography variant="e-r12" color="commonPalette.gray.500">{item.accounts} accounts</OpsnowCommonTypography>
|
|
2201
|
+
</Box>
|
|
2202
|
+
)}
|
|
2203
|
+
/>`,
|
|
2204
|
+
description: '칩 모양이 기본 Chip과 다를 때 renderItem으로 직접 그리는 예제입니다. 셋째 인자 itemProps를 항목 루트 요소에 반드시 펼쳐 넣어야({...itemProps}) 클릭·키보드·접근성이 동작합니다. 항목 안에 다른 버튼을 넣으면 그 버튼의 onClick에서 e.stopPropagation()을 호출해 칩 선택과 분리합니다.'
|
|
2205
|
+
},
|
|
2206
|
+
{
|
|
2207
|
+
title: 'ChipGroup - 지우기 칩 목록 (removable, 적용된 필터 요약 · collapseAfter)',
|
|
2208
|
+
code: `const { OpsnowCommonChipGroup } = useCommonComponents();
|
|
2209
|
+
const [applied, setApplied] = useState(['acc-1', 'acc-2', 'acc-3', 'acc-4']);
|
|
2210
|
+
|
|
2211
|
+
const ACCOUNTS = [
|
|
2212
|
+
{ value: 'acc-1', label: 'account-01' },
|
|
2213
|
+
{ value: 'acc-2', label: 'account-02' },
|
|
2214
|
+
{ value: 'acc-3', label: 'account-03' },
|
|
2215
|
+
{ value: 'acc-4', label: 'account-04' },
|
|
2216
|
+
];
|
|
2217
|
+
|
|
2218
|
+
<OpsnowCommonChipGroup
|
|
2219
|
+
removable
|
|
2220
|
+
aria-label="적용된 계정 필터"
|
|
2221
|
+
items={ACCOUNTS}
|
|
2222
|
+
value={applied}
|
|
2223
|
+
onChange={(_, v) => setApplied(v)}
|
|
2224
|
+
collapseAfter={3}
|
|
2225
|
+
/>`,
|
|
2226
|
+
description: 'removable이면 칩을 눌러도 선택은 바뀌지 않고 ✕로 값을 뺍니다(적용된 필터 요약). value는 값 배열이고, ✕를 누르면 그 값을 뺀 배열로 onChange가 호출됩니다. collapseAfter를 주면 N개까지만 보이고 나머지는 «+M 기타»로 접힙니다. 묶음 여러 줄이 필요하면 value를 { 묶음 키: 값[] }로, 항목에 group을, 줄 앞 이름은 groupLabels로 줍니다.'
|
|
2227
|
+
},
|
|
2228
|
+
];
|
|
2229
|
+
// CheckboxGroup 예제
|
|
2230
|
+
export const CheckboxGroupExamples = [
|
|
2231
|
+
{
|
|
2232
|
+
title: 'CheckboxGroup - 검색 + 전체 선택 + 목록 스크롤 (selectAll · listMaxHeight · emptyContent)',
|
|
2233
|
+
code: `const { OpsnowCommonCheckboxGroup, OpsnowCommonTextField } = useCommonComponents();
|
|
2234
|
+
const [accounts, setAccounts] = useState(['acc-1', 'acc-4']);
|
|
2235
|
+
const [keyword, setKeyword] = useState('');
|
|
2236
|
+
|
|
2237
|
+
const ACCOUNTS = [
|
|
2238
|
+
{ value: 'acc-1', label: 'account-01 (123456789010)' },
|
|
2239
|
+
{ value: 'acc-2', label: 'account-02 (123456789011)' },
|
|
2240
|
+
{ value: 'acc-3', label: 'account-03 (123456789012)' },
|
|
2241
|
+
{ value: 'acc-4', label: 'account-04 (123456789013)', disabled: true },
|
|
2242
|
+
{ value: 'acc-5', label: 'account-05 (123456789014)' },
|
|
2243
|
+
// ... 계정 목록
|
|
2244
|
+
];
|
|
2245
|
+
|
|
2246
|
+
// 검색은 화면이 items 를 걸러 넘긴다 — 가려진 선택값은 지워지지 않는다
|
|
2247
|
+
const filteredAccounts = useMemo(() => {
|
|
2248
|
+
const word = keyword.trim().toLowerCase();
|
|
2249
|
+
return word ? ACCOUNTS.filter((a) => a.label.toLowerCase().includes(word)) : ACCOUNTS;
|
|
2250
|
+
}, [keyword]);
|
|
2251
|
+
|
|
2252
|
+
<Box sx={{ width: 360 }}>
|
|
2253
|
+
<OpsnowCommonTextField
|
|
2254
|
+
variant="outlined"
|
|
2255
|
+
size="small"
|
|
2256
|
+
value={keyword}
|
|
2257
|
+
placeholder="계정 검색"
|
|
2258
|
+
adornmentIconName="SearchMagnifier"
|
|
2259
|
+
adornmentPosition="start"
|
|
2260
|
+
onChange={(e) => setKeyword(e.target.value)}
|
|
2261
|
+
sx={{ width: '100%', mb: 1 }}
|
|
2262
|
+
/>
|
|
2263
|
+
<OpsnowCommonCheckboxGroup
|
|
2264
|
+
aria-label="계정"
|
|
2265
|
+
selectAll
|
|
2266
|
+
listMaxHeight={200}
|
|
2267
|
+
items={filteredAccounts}
|
|
2268
|
+
value={accounts}
|
|
2269
|
+
onChange={(_, v) => setAccounts(v)}
|
|
2270
|
+
emptyContent={
|
|
2271
|
+
<OpsnowCommonTypography variant="e-r10" theme="description">검색 결과가 없습니다.</OpsnowCommonTypography>
|
|
2272
|
+
}
|
|
2273
|
+
/>
|
|
2274
|
+
</Box>`,
|
|
2275
|
+
description: '화면에 펼쳐진 긴 계정 목록을 고르는 예제입니다 (드롭다운 안에서 체크박스로 고르는 필터라면 Autocomplete의 「체크박스/전체선택」 예제를 쓰세요). onChange의 둘째 인자가 새 값 배열입니다. selectAll은 「전체 선택」 체크박스를 맨 위에 두고(문구는 common i18n 자동), 보이는 활성 항목만 켜고 끕니다. listMaxHeight를 주면 목록만 스크롤되고 「전체 선택」은 위에 고정됩니다. 검색은 컴포넌트 기능이 아니라 화면이 items를 걸러서 넘기며, 이때 가려진 선택값은 유지됩니다.'
|
|
2276
|
+
},
|
|
2277
|
+
{
|
|
2278
|
+
title: 'CheckboxGroup - 가로 배치 · small (요일 선택)',
|
|
2279
|
+
code: `const { OpsnowCommonCheckboxGroup } = useCommonComponents();
|
|
2280
|
+
const [days, setDays] = useState(['MON', 'WED', 'FRI']);
|
|
2281
|
+
|
|
2282
|
+
const DAYS = [
|
|
2283
|
+
{ value: 'MON', label: '월' },
|
|
2284
|
+
{ value: 'TUE', label: '화' },
|
|
2285
|
+
{ value: 'WED', label: '수' },
|
|
2286
|
+
{ value: 'THU', label: '목' },
|
|
2287
|
+
{ value: 'FRI', label: '금' },
|
|
2288
|
+
{ value: 'SAT', label: '토' },
|
|
2289
|
+
{ value: 'SUN', label: '일' },
|
|
2290
|
+
];
|
|
2291
|
+
|
|
2292
|
+
<OpsnowCommonCheckboxGroup
|
|
2293
|
+
aria-label="요일"
|
|
2294
|
+
direction="row"
|
|
2295
|
+
size="small"
|
|
2296
|
+
items={DAYS}
|
|
2297
|
+
value={days}
|
|
2298
|
+
onChange={(_, v) => setDays(v)}
|
|
2299
|
+
/>`,
|
|
2300
|
+
description: 'direction="row"로 가로로 나열하는 예제입니다. 반환되는 값 배열은 누른 순서가 아니라 items 순서로 정렬됩니다.'
|
|
2301
|
+
},
|
|
2302
|
+
];
|