0.13.0 • Published 5 years ago

@pndr/single-select-field v0.13.0

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

SingleSelectField SingleSelectField

npm package

Used for selecting a single option from a list.

Getting started

npm install @cmds/single-select-field --save
<SingleSelectField
    id={'fld1'}
    contextId={'recordGalleryCard'}
    roleId={'readOnly'}
    optionId={'opt5'}
    options={{
        options: ['opt1', 'opt2', 'opt3', 'opt4', 'opt5', 'opt6'],
        optionsById: {
            'opt1': {
                id: 'opt1',
                colorId: 'blue.base',
                name: 'Blue'
            },
            'opt2': {
                id: 'opt2',
                colorId: 'green.base',
                name: 'Green'
            },
            'opt3': {
                id: 'opt3',
                colorId: 'red.base',
                name: 'Red'
            },
            'opt4': {
                id: 'opt4',
                colorId: 'yellow.base',
                name: 'Yellow'
            },
            'opt5': {
                id: 'opt5',
                colorId: 'indigo.base',
                name: 'Indigo'
            },
            'opt6': {
                id: 'opt6',
                colorId: 'purple.base',
                name: 'Purple'
            }
        }
    }}
    onChange={({id, optionId}) => {
       // do something 
    }}
/>

Prop Types

PropertyTypeRequired?Description
idStringUnique id for the instance of this field
contextIdContextThe appearance will change depending on context in which the field is displayed. Valid options include: recordDetail or recordGridRow or recordGalleryCard or recordListItem
roleIdRoleThe behaviour changes based on the role. Valid options include editor or readOnly
optionsObjectObject that holds each option by it's id. Each option should have an id, name, colorId (optional)
optionOrderArrayShould reference all options in the preferred order
coloredOptionsBooleanEnables coloring for options
optionIdStringSelected option
onChangeFunctionCallback invoked whenever an option get's selected: ({id: string, optionId: string}): void

More information

This component is designed and developed as part of Cosmos Design System.

0.13.0

5 years ago

0.12.0

5 years ago

0.11.0

5 years ago

0.9.0

5 years ago

0.8.0

5 years ago