Checkboxes

Definition

<cst-checkbox>
<sub-theme/>
<sub-font/>
<sub-style/>
<sub-access/>
<sub-label/>
<sub-item />
<sub-item />
<sub-options />
<sub-help-icon/>
<sub-feature-flag/>
</cst-checkbox>

OR

<cst-element name="" schema="" schema-prop="" value=""/>
name = checkbox or checkbox-group

Example

<cst-checkbox id="" value="">
<sub-theme name="" clr-var1="" clr-var2=""/>
<sub-font name="" font-var1="" font-var2=""/>
<sub-style name="" width="" height=""/>
<sub-access can-view="" can-modify=""/>
<sub-label text="" position=""/>
<sub-item id="" text="" />
<sub-item id="" text="" />
<sub-options items-prop="" item-text-prop="" item-id-prop=""/>
<sub-help-icon name="" position="" title="" link="">
<sub-feature-flag disable-ripple="" indeterminate="">
</cst-checkbox>

Attributes

AttributeValueDescription
idstring typeIdentifier for component.
valuearray/boolean typeSpecifies the selected item(s) for component(two way bind attribute). Boolean for checkbox and id array for checkbox group
requiredboolean typeSpecifies if field must be filled.
disabledboolean typeSpecifies if component should be disabled.(aurelia ext attribute)
autofocusboolean typeSpecifies if component should be focused when loaded.
checkedboolean typeSpecifies if checkbox is checked.
classcst-mat-unchecked
cst-mat-indeterminate
cst-mat-checked
Specifies class to be applied(Multiple classes can be given with space).

sub-theme

object typeSpecifies theme to be used for component.

sub-font

object typeSpecifies fonts to be used for component.

sub-style

object typeSpecifies style to be applied to component.

sub-label

object typeSpecifies label to be displayed.

sub-options

object typeSpecifies the options for the component.

sub-help-icon

object typeSpecifies help icon to be displayed.

sub-feature-flag

objectSpecifies what features to enable/disable.
otherany typeAny other info.
schemaobject type Specifies JSON schema.
schema-propstring typeSpecifies property to be used to pick schema.

Sub element attributes

sub-theme

PropertyValueDescription
nameprimary(default)/secondary/customName of the theme.
clr-labelstring typeIf custom then specific/ named color variables

sub-font

PropertyValueDescription
nameroboto (default)/customName of the font
font-textstring typeIf custom then specific/ named font variables.
font-labelstring type
font-errorstring type

sub-style

PropertyValueDescription
namematerial/skeuomorphicName of design to be used.
widthpercentage/pixels/string(x-small,small,medium,large,x-large)Gives width/any other prop value

sub-label(For single checkbox)

PropertyValueDescription
textstring typeLabel text.
positionleft/top/center(default)Position of the label.

sub-options(For checkbox group)

PropertyValueDescription
items-propstring typeProperty of item array
item-id-propstring typeProperty of item's id
item-text-propstring typeProperty of item's display text.

sub-help-icon

PropertyValueDescription
namestring typeIcon name.
positionleft/rightPosition of the icon.
titlestring typeIcon tooltip
linkstring typeLink to be opened on click.

sub-feature-flag

PropertyValueDescription
disable-rippleboolean typeDisables ripple effec when given true.
indeterminate(For checkbox group)boolean typeDisplay to select all, unselect all or partially select checkboxes from checkbox group

Schema Examples

Full schema

Fetch appropriate based on schemaProp

let schema = {
type: "object",
required: ["languageId"], //= required
properties: {
regionId: {
type: "number",
title:"Select Language",//= label for checkbox group
cstAttr: {
raw:{ //loop & add to element
disabled : false,
autofocus : false,
class:'cst-class1',
checked: '',
required: '',
},
subStyle:{ //loop & add to element style
name: '',
width:'',
height:'',
fontSize:''
},
subLabel:{
position:'',
text:''
},
subOptions:{
itemsProp: '',
itemTextProp: '',
itemIdProp: ''
},
subHelpIcon: {
name: '',
position: '',
title:'',
link:''
},
subFeatureFlag: {
disableRipple: ''
},
subTheme:{
name:'',
clrLabel:''
},
subFont:{
name:'',
fontText:'',
fontLabel:'',
fontError:''
}
}
}
}
}
let schemaProp = 'languageId';
let value = [200,300];
let finalSchema = schemaProp ? schema.properties[schemaProp] : schema;
let data = [ // For checkbox group
{
id: '',
text: '',
checked: '',
disabled: ''
}
]

Exact schema

let schema = {
type: "number",
title: "Select Language", //= label
cstAttr: {
}
}
let schemaProp = '';
let value = [200,300];
let finalSchema = schemaProp ? schema.properties[schemaProp] : schema;

Nested object

Nested object schemaProp

let schema = {};
let schemaProp = 'EMDDetails.languageId';
let value = [200,300];
var finalSchema = schema;
let schemaPropSplits = schemaProp.split('.');
for(let prop of schemaPropSplits){
finalSchema = finalSchema.properties[schemaProp];
}

Material Measurement Guidelines

  • min-height = 24px
  • min-width = 24px

SPEC MIN

Events

AttributeDescription
onclickFires when the item clicked.
oninvalidScript to be run when an element is invalid.
onresetFires when reset button is clicked.
onvalidateCustom validate hook, must return error message else considered valid; will be called onchange.

Event Method signature

method(parentRefObj, evtObj, elm, others)

Parameters description

ParameterValueDescription
parentRefObj
parentRefObj = {
parentContext,
loopParentContext,
doubleLoopParentContext
}
Parent Context references
evtObjobjectEvent object
elmobjectElement value
othersanyOther value

OverRidable Classes

  • cst-ovr-checkbox-elm
  • cst-ovr-checkbox
  • cst-ovr-checkbox-label
  • cst-ovr-checkbox-helper-text
  • cst-ovr-checkbox-error-text

Unit Test Screenshots

Responsiveness Test Screenshots

Design Images

Demo link

Features

  • Display checkbox or checkbox group

  • Checkbox text position will be next to checkbox

  • Item Selection

    • Single selection
      • Value should be true or false
    • Multi selection
      • Value should be an array of selected items
      • Use checkbox indeterminate state for nested item partial selection
  • Every items must have id prop (add in check list)

Points

  • The maximum height of a checkbox group should be at least one row less than the height of the app’s UI.