Pre-defined controls
The controls api comes with a selection of pre-defined controls that can be used to create interactive examples of your components.
userName: {type: ControlTypes.TEXT,label: 'Name',value: 'Storyteller',}
all properties of ControlType in addition to:
Name | Type | Description |
---|---|---|
escapeValue | boolean | allows to receive escaped string values to help prevent XSS attacks by default - false |
placeholder | string | placeholder for empty properties either undefined initial value or user clears the field |
rows | number | number of rows for a TextArea field for longer text by default, only 1 row = means a Input field > 1 rows = an area field |
some text
Name | Description | Default | Controls |
---|---|---|---|
text | text | some text |
age: {type: ControlTypes.NUMBER,label: 'Age',value: 78,range: true,min: 0,max: 90,step: 5,},
all properties of ControlType in addition to:
Name | Type | Description |
---|---|---|
max | number | maximum allowed value for numeric property |
min | number | minimum allowed value for numeric property |
range | boolean | if true, will display a range type slider editor |
step | number | stepper for numeric editor /i nc/dec value |
7
Name | Description | Default | Controls |
---|---|---|---|
number | ControlTypes.NUMBER | 7 | Invalid Type |
nice: {type: ControlTypes.BOOLEAN,label: 'Nice',value: true,},
all properties of ControlType
TRUE
Name | Description | Default | Controls |
---|---|---|---|
bool | ControlTypes.BOOLEAN | true | Invalid Type |
fruit: {type: ControlTypes.OPTIONS,label: 'Fruit',value: 'apple',options: {Apple: 'apple',Banana: 'banana',Cherry: 'cherry',},},
all properties of ControlType in addition to:
Name | Type | Description |
---|---|---|
options* | Record<string, number | string[] | number[] | { label: string; value: any }> | |
display | 'select' | 'multi-select' | 'radio' | 'inline-radio' | 'check' | 'inline-check' | how to render selecting the options: default is 'select' |
watermelon
Name | Description | Default | Controls |
---|---|---|---|
options | ControlTypes.OPTIONS | [ "watermelon" ] | Invalid Type |
birthday: {type: ControlTypes.DATE,label: 'Birthday',value: new Date(),},
all properties of ControlType in addition to:
Name | Type | Description |
---|---|---|
datePicker | boolean | whether to display a date picker (calendar). default: true |
timePicker | boolean | whether to display a time picker (calendar). default: true |
Invalid Date
Name | Description | Default | Controls |
---|---|---|---|
date | ControlTypes.DATE | new Date('01/01/2020') | Invalid Type |
color: {type: 'color',value: '#000000',},
all properties of ControlType in addition to:
Name | Type | Description |
---|---|---|
kind | 'hex' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | in what format to save the color as a string (default to hex ) |
#555
Name | Description | Default | Controls |
---|---|---|---|
color | ControlTypes.COLOR | #555 | Invalid Type |
button: {type: ControlTypes.BUTTON,onClick: () => {// .. code to modify some variables}},
all properties of ControlType in addition to:
Name | Type | Description |
---|---|---|
onClick | function (prop *: ComponentControlButton): void; | for button type fields, an onClick handler |
Name | Description | Default | Controls |
---|---|---|---|
onClick | ControlTypes.BUTTON | () => console.log('clicked') | Invalid Type |
style: {type: ControlTypes.OBJECT,label: 'Styles',value: {// do not randomize the border styleborder: { type: ControlTypes.TEXT, value: '2px dashed silver', data: null },borderRadius: { type: ControlTypes.NUMBER, value: 10 },padding: { type: ControlTypes.NUMBER, value: 10 },},}
all properties of ControlType in addition to:
Name | Type | Description |
---|---|---|
editLabel | string | the label for the editor button |
Name | Description | Default | Controls |
---|---|---|---|
style | ControlTypes.OBJECT | { "color": { "type": "ControlTypes.COLOR", "value": "red" }, "backgroundColor": { "type": "ControlTypes.COLOR", "value": "lightgrey" }, "padding": { "type": "ControlTypes.NUMBER", "value": 2, "step": 5, "label": "padding (px.)" } } | Invalid Type |
arrayItems: {type: ControlTypes.ARRAY,label: 'Items',rowType: {name: { type: ControlTypes.TEXT },},value: [{ name: 'Laptop' }, { name: 'Book' }, { name: 'Whiskey' }],},
all properties of ControlType in addition to:
Name | Type | Description |
---|---|---|
rowType* | ComponentControls | type of the items in each row of the array |
editLabel | string | the label for the editor button |
Name | Description | Default | Controls |
---|---|---|---|
array | ControlTypes.ARRAY | [ { "label": "Button 1", "color": "red" }, { "label": "Button 2", "color": "grey" } ] | Invalid Type |
images: {type: ControlTypes.FILES,label: 'Happy Picture',accept: 'image/*',value: ['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElNRQfiARwMCyEWcOFPAAAAP0lEQVQoz8WQMQoAIAwDL/7/z3GwghSp4KDZyiUpBMCYUgd8rehtH16/l3XewgU2KAzapjXBbNFaPS6lDMlKB6OiDv3iAH1OAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE4LTAxLTI4VDEyOjExOjMzLTA3OjAwlAHQBgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOC0wMS0yOFQxMjoxMTozMy0wNzowMOVcaLoAAAAASUVORK5CYII=',],},
all properties of ControlType in addition to:
Name | Type | Description |
---|---|---|
accept | string | type of files to accept user to open ex 'image/*', |
Name | Description | Default | Controls |
---|---|---|---|
files | ControlTypes.FILES | [ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElNRQfiARwMCyEWcOFPAAAAP0lEQVQoz8WQMQoAIAwDL/7/z3GwghSp4KDZyiUpBMCYUgd8rehtH16/l3XewgU2KAzapjXBbNFaPS6lDMlKB6OiDv3iAH1OAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE4LTAxLTI4VDEyOjExOjMzLTA3OjAwlAHQBgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOC0wMS0yOFQxMjoxMTozMy0wNzowMOVcaLoAAAAASUVORK5CYII=" ] | Invalid Type |