|
| 1 | +import { Fragment } from 'react'; |
| 2 | +import ReactDOM from 'react-dom/client'; |
| 3 | +import './index.css'; |
| 4 | +import { IgrCombo } from 'igniteui-react'; |
| 5 | +import 'igniteui-webcomponents/themes/light/bootstrap.css'; |
| 6 | + |
| 7 | +interface Country { |
| 8 | + id: string; |
| 9 | + name: string; |
| 10 | + region: string; |
| 11 | +} |
| 12 | + |
| 13 | +const countries: Country[] = [ |
| 14 | + { id: 'BY', name: 'Belarus', region: 'Europe' }, |
| 15 | + { id: 'BE', name: 'Belgium', region: 'Europe' }, |
| 16 | + { id: 'BG', name: 'Bulgaria', region: 'Europe' }, |
| 17 | +]; |
| 18 | + |
| 19 | +const rows = [ |
| 20 | + { label: 'Idle', outlined: true, className: 'border-type', value: [] as string[] }, |
| 21 | + { label: 'Filled', outlined: true, className: 'border-type', value: ['BY'] }, |
| 22 | + { label: 'Idle', outlined: false, className: 'box-type group-start', value: [] as string[] }, |
| 23 | + { label: 'Filled', outlined: false, className: 'box-type', value: ['BY'] }, |
| 24 | +]; |
| 25 | + |
| 26 | +export default function ComboSingleSelectDisabled() { |
| 27 | + const combo = (outlined: boolean, value: string[], disabled: boolean) => ( |
| 28 | + <IgrCombo |
| 29 | + singleSelect |
| 30 | + outlined={outlined} |
| 31 | + disabled={disabled} |
| 32 | + placeholder="Country" |
| 33 | + valueKey="id" |
| 34 | + displayKey="name" |
| 35 | + groupKey="region" |
| 36 | + data={countries} |
| 37 | + value={value} |
| 38 | + /> |
| 39 | + ); |
| 40 | + |
| 41 | + return ( |
| 42 | + <div className="sample"> |
| 43 | + {/* the combos are display-only, so inert blocks pointer and keyboard interaction */} |
| 44 | + <div className="states" inert> |
| 45 | + <span /> |
| 46 | + <span className="state-label state-column">Enabled</span> |
| 47 | + <span className="state-label state-column">Disabled</span> |
| 48 | + {rows.map((row, index) => ( |
| 49 | + <Fragment key={index}> |
| 50 | + <span className={`state-label ${row.className}`}>{row.label}</span> |
| 51 | + <div className={row.className}>{combo(row.outlined, row.value, false)}</div> |
| 52 | + <div className={row.className}>{combo(row.outlined, row.value, true)}</div> |
| 53 | + </Fragment> |
| 54 | + ))} |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + ); |
| 58 | +} |
| 59 | + |
| 60 | +// rendering above component to the React DOM |
| 61 | +const root = ReactDOM.createRoot(document.getElementById('root')!); |
| 62 | +root.render(<ComboSingleSelectDisabled/>); |
0 commit comments