2020-05-20 11:30:53 +00:00
import { generateTypeDef } from "utils/autocomplete/dataTreeTypeDefCreator" ;
import { DataTreeAction } from "entities/DataTree/dataTreeFactory" ;
2020-06-04 13:49:22 +00:00
import _ from "lodash" ;
2020-05-20 11:30:53 +00:00
const isVisible = {
"!type" : "bool" ,
"!doc" : "Boolean value indicating if the widget is in visible state" ,
} ;
export const entityDefinitions = {
2020-06-04 13:49:22 +00:00
ACTION : ( entity : DataTreeAction ) = > {
const dataDef = generateTypeDef ( entity . data ) ;
let data : Record < string , any > = {
"!doc" : "The response of the action" ,
} ;
if ( _ . isString ( dataDef ) ) {
data [ "!type" ] = dataDef ;
} else {
data = { . . . data , . . . dataDef } ;
}
return {
"!doc" :
"Actions allow you to connect your widgets to your backend data in a secure manner." ,
2021-02-03 15:15:16 +00:00
"!url" : "https://docs.appsmith.com/v/v1.2.1/framework-reference/run" ,
2020-06-04 13:49:22 +00:00
isLoading : "bool" ,
data ,
2021-07-20 10:02:56 +00:00
responseMeta : {
"!doc" : "The response meta of the action" ,
"!type" : "?" ,
} ,
2020-06-04 13:49:22 +00:00
run : "fn(onSuccess: fn() -> void, onError: fn() -> void) -> void" ,
} ;
} ,
2020-05-20 11:30:53 +00:00
CONTAINER_WIDGET : {
"!doc" :
"Containers are used to group widgets together to form logical higher order widgets. Containers let you organize your page better and move all the widgets inside them together." ,
2021-02-03 15:15:16 +00:00
"!url" : "https://docs.appsmith.com/widget-reference/container" ,
2020-05-20 11:30:53 +00:00
backgroundColor : {
"!type" : "string" ,
2021-02-03 15:15:16 +00:00
"!url" : "https://docs.appsmith.com/widget-reference/container" ,
2020-05-20 11:30:53 +00:00
} ,
isVisible : isVisible ,
} ,
INPUT_WIDGET : {
"!doc" :
"An input text field is used to capture a users textual input such as their names, numbers, emails etc. Inputs are used in forms and can have custom validations." ,
"!url" : "https://docs.appsmith.com/widget-reference/input" ,
text : {
"!type" : "string" ,
"!doc" : "The text value of the input" ,
"!url" : "https://docs.appsmith.com/widget-reference/input" ,
} ,
isValid : "bool" ,
isVisible : isVisible ,
2020-05-22 12:46:11 +00:00
isDisabled : "bool" ,
2021-07-15 12:50:01 +00:00
currencyCountryCode : {
"!type" : "string" ,
"!doc" : "Selected country code for Currency type input" ,
} ,
2020-05-20 11:30:53 +00:00
} ,
TABLE_WIDGET : ( widget : any ) = > ( {
"!doc" :
"The Table is the hero widget of Appsmith. You can display data from an API in a table, trigger an action when a user selects a row and even work with large paginated data sets" ,
"!url" : "https://docs.appsmith.com/widget-reference/table" ,
selectedRow : generateTypeDef ( widget . selectedRow ) ,
2020-09-08 13:04:51 +00:00
selectedRows : generateTypeDef ( widget . selectedRows ) ,
2020-05-20 11:30:53 +00:00
selectedRowIndex : "number" ,
tableData : generateTypeDef ( widget . tableData ) ,
2020-05-28 06:12:04 +00:00
pageNo : "number" ,
pageSize : "number" ,
2020-05-22 12:46:11 +00:00
isVisible : isVisible ,
2020-07-24 13:58:28 +00:00
searchText : "string" ,
2020-05-20 11:30:53 +00:00
} ) ,
2021-01-12 01:22:31 +00:00
VIDEO_WIDGET : {
2020-09-26 12:59:33 +00:00
"!doc" :
"Video widget can be used for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia, Mixcloud, and DailyMotion." ,
"!url" : "https://docs.appsmith.com/widget-reference/video" ,
playState : "number" ,
autoPlay : "bool" ,
2021-01-12 01:22:31 +00:00
} ,
2020-05-20 11:30:53 +00:00
DROP_DOWN_WIDGET : {
"!doc" :
2021-05-07 05:26:36 +00:00
"Select is used to capture user input/s from a specified list of permitted inputs. A Select can capture a single choice as well as multiple choices" ,
2020-05-20 11:30:53 +00:00
"!url" : "https://docs.appsmith.com/widget-reference/dropdown" ,
2020-05-22 12:46:11 +00:00
isVisible : isVisible ,
selectedOptionValue : {
"!type" : "string" ,
"!doc" : "The value selected in a single select dropdown" ,
"!url" : "https://docs.appsmith.com/widget-reference/dropdown" ,
} ,
2021-02-26 06:24:25 +00:00
selectedOptionLabel : {
"!type" : "string" ,
"!doc" : "The selected option label in a single select dropdown" ,
"!url" : "https://docs.appsmith.com/widget-reference/dropdown" ,
} ,
2020-09-10 07:21:44 +00:00
selectedOptionValues : {
2021-08-03 06:38:01 +00:00
"!type" : "[string]" ,
"!doc" : "The array of values selected in a multi select dropdown" ,
"!url" : "https://docs.appsmith.com/widget-reference/dropdown" ,
} ,
selectedOptionLabels : {
"!type" : "[string]" ,
"!doc" : "The array of selected option labels in a multi select dropdown" ,
"!url" : "https://docs.appsmith.com/widget-reference/dropdown" ,
} ,
isDisabled : "bool" ,
options : "[dropdownOption]" ,
} ,
MULTI_SELECT_WIDGET : {
"!doc" :
"MultiSelect is used to capture user input/s from a specified list of permitted inputs. A MultiSelect captures multiple choices from a list of options" ,
"!url" : "https://docs.appsmith.com/widget-reference/dropdown" ,
isVisible : isVisible ,
selectedOptionValues : {
2020-05-22 12:46:11 +00:00
"!type" : "[string]" ,
"!doc" : "The array of values selected in a multi select dropdown" ,
2021-02-26 06:24:25 +00:00
"!url" : "https://docs.appsmith.com/widget-reference/dropdown" ,
} ,
selectedOptionLabels : {
"!type" : "[string]" ,
"!doc" : "The array of selected option labels in a multi select dropdown" ,
2020-05-22 12:46:11 +00:00
"!url" : "https://docs.appsmith.com/widget-reference/dropdown" ,
} ,
isDisabled : "bool" ,
2020-05-20 11:30:53 +00:00
options : "[dropdownOption]" ,
} ,
IMAGE_WIDGET : {
"!doc" :
"Image widget is used to display images in your app. Images must be either a URL or a valid base64." ,
"!url" : "https://docs.appsmith.com/widget-reference/image" ,
image : "string" ,
isVisible : isVisible ,
} ,
TEXT_WIDGET : {
"!doc" :
" Text widget is used to display textual information. Whether you want to display a paragraph or information or add a heading to a container, a text widget makes it easy to style and display text" ,
"!url" : "https://docs.appsmith.com/widget-reference/text" ,
isVisible : isVisible ,
text : "string" ,
} ,
BUTTON_WIDGET : {
"!doc" :
"Buttons are used to capture user intent and trigger actions based on that intent" ,
"!url" : "https://docs.appsmith.com/widget-reference/button" ,
isVisible : isVisible ,
text : "string" ,
isDisabled : "bool" ,
} ,
DATE_PICKER_WIDGET : {
"!doc" :
"Datepicker is used to capture the date and time from a user. It can be used to filter data base on the input date range as well as to capture personal information such as date of birth" ,
"!url" : "https://docs.appsmith.com/widget-reference/datepicker" ,
isVisible : isVisible ,
selectedDate : "string" ,
isDisabled : "bool" ,
} ,
2021-02-23 12:35:09 +00:00
DATE_PICKER_WIDGET2 : {
"!doc" :
"Datepicker is used to capture the date and time from a user. It can be used to filter data base on the input date range as well as to capture personal information such as date of birth" ,
"!url" : "https://docs.appsmith.com/widget-reference/datepicker" ,
isVisible : isVisible ,
selectedDate : "string" ,
formattedDate : "string" ,
isDisabled : "bool" ,
} ,
2020-05-20 11:30:53 +00:00
CHECKBOX_WIDGET : {
"!doc" :
"Checkbox is a simple UI widget you can use when you want users to make a binary choice" ,
"!url" : "https://docs.appsmith.com/widget-reference/checkbox" ,
isVisible : isVisible ,
isChecked : "bool" ,
isDisabled : "bool" ,
} ,
2021-02-16 12:15:17 +00:00
SWITCH_WIDGET : {
"!doc" :
"Switch is a simple UI widget you can use when you want users to make a binary choice" ,
"!url" : "https://docs.appsmith.com/widget-reference/switch" ,
isVisible : isVisible ,
isSwitchedOn : "bool" ,
isDisabled : "bool" ,
} ,
2020-05-20 11:30:53 +00:00
RADIO_GROUP_WIDGET : {
"!doc" :
"Radio widget lets the user choose only one option from a predefined set of options. It is quite similar to a SingleSelect Dropdown in its functionality" ,
"!url" : "https://docs.appsmith.com/widget-reference/radio" ,
isVisible : isVisible ,
options : "[dropdownOption]" ,
selectedOptionValue : "string" ,
isRequired : "bool" ,
} ,
TABS_WIDGET : {
isVisible : isVisible ,
selectedTab : "string" ,
} ,
MODAL_WIDGET : {
isVisible : isVisible ,
isOpen : "bool" ,
} ,
RICH_TEXT_EDITOR_WIDGET : {
isVisible : isVisible ,
text : "string" ,
isDisabled : "string" ,
} ,
CHART_WIDGET : {
"!doc" :
"Chart widget is used to view the graphical representation of your data. Chart is the go-to widget for your data visualisation needs." ,
"!url" : "https://docs.appsmith.com/widget-reference/chart" ,
isVisible : isVisible ,
chartData : "chartData" ,
xAxisName : "string" ,
yAxisName : "string" ,
2021-02-22 16:31:13 +00:00
selectedDataPoint : "chartDataPoint" ,
2020-05-20 11:30:53 +00:00
} ,
2020-06-09 13:10:42 +00:00
FORM_WIDGET : ( widget : any ) = > ( {
2020-05-20 11:30:53 +00:00
"!doc" :
"Form is used to capture a set of data inputs from a user. Forms are used specifically because they reset the data inputs when a form is submitted and disable submission for invalid data inputs" ,
"!url" : "https://docs.appsmith.com/widget-reference/form" ,
isVisible : isVisible ,
2020-06-09 13:10:42 +00:00
data : generateTypeDef ( widget . data ) ,
} ) ,
2020-05-20 11:30:53 +00:00
FORM_BUTTON_WIDGET : {
"!doc" :
"Form button is provided by default to every form. It is used for form submission and resetting form inputs" ,
"!url" : "https://docs.appsmith.com/widget-reference/form" ,
isVisible : isVisible ,
text : "string" ,
isDisabled : "bool" ,
} ,
MAP_WIDGET : {
isVisible : isVisible ,
center : "latLong" ,
markers : "[mapMarker]" ,
selectedMarker : "mapMarker" ,
} ,
FILE_PICKER_WIDGET : {
"!doc" :
"Filepicker widget is used to allow users to upload files from their local machines to any cloud storage via API. Cloudinary and Amazon S3 have simple APIs for cloud storage uploads" ,
"!url" : "https://docs.appsmith.com/widget-reference/filepicker" ,
isVisible : isVisible ,
2021-03-12 08:14:32 +00:00
files : "[file]" ,
2020-05-22 12:46:11 +00:00
isDisabled : "bool" ,
2020-05-20 11:30:53 +00:00
} ,
2021-04-23 05:43:13 +00:00
LIST_WIDGET : ( widget : any ) = > ( {
"!doc" :
"Containers are used to group widgets together to form logical higher order widgets. Containers let you organize your page better and move all the widgets inside them together." ,
"!url" : "https://docs.appsmith.com/widget-reference/list" ,
backgroundColor : {
"!type" : "string" ,
"!url" : "https://docs.appsmith.com/widget-reference/how-to-use-widgets" ,
} ,
isVisible : isVisible ,
2021-05-03 05:01:47 +00:00
gridGap : "number" ,
2021-04-23 05:43:13 +00:00
selectedItem : generateTypeDef ( widget . selectedItem ) ,
2021-06-18 07:42:57 +00:00
items : generateTypeDef ( widget . items ) ,
listData : generateTypeDef ( widget . listData ) ,
2021-04-23 05:43:13 +00:00
} ) ,
2021-07-02 09:55:50 +00:00
RATE_WIDGET : {
"!doc" : "Rating widget is used to display ratings in your app." ,
"!url" : "https://docs.appsmith.com/widget-reference/rate" ,
isVisible : isVisible ,
value : "number" ,
maxCount : "number" ,
} ,
2021-07-30 06:36:00 +00:00
IFRAME_WIDGET : ( widget : any ) = > ( {
2021-06-12 16:08:10 +00:00
"!doc" : "Iframe widget is used to display iframes in your app." ,
"!url" : "https://docs.appsmith.com/widget-reference/iframe" ,
2021-06-09 09:39:17 +00:00
isVisible : isVisible ,
2021-06-12 16:08:10 +00:00
source : "string" ,
title : "string" ,
2021-07-30 06:36:00 +00:00
message : generateTypeDef ( widget . message ) ,
} ) ,
2021-07-07 09:30:06 +00:00
DIVIDER_WIDGET : {
"!doc" : "Divider is a simple UI widget used as a separator" ,
"!url" : "https://docs.appsmith.com/widget-reference/divider" ,
isVisible : isVisible ,
orientation : "string" ,
capType : "string" ,
capSide : "number" ,
strokeStyle : "string" ,
dividerColor : "string" ,
thickness : "number" ,
} ,
2021-07-13 08:05:09 +00:00
MENU_BUTTON_WIDGET : {
"!doc" :
"Menu button widget is used to represent a set of actions in a group." ,
"!url" : "https://docs.appsmith.com/widget-reference/menu-button" ,
isVisible : isVisible ,
label : "string" ,
} ,
2020-05-20 11:30:53 +00:00
} ;
export const GLOBAL_DEFS = {
dropdownOption : {
label : "string" ,
value : "string" ,
} ,
tabs : {
id : "string" ,
label : "string" ,
} ,
chartDataPoint : {
x : "string" ,
y : "string" ,
} ,
chartData : {
seriesName : "string" ,
data : "[chartDataPoint]" ,
} ,
latLong : {
lat : "number" ,
long : "number" ,
} ,
mapMarker : {
lat : "number" ,
long : "number" ,
title : "string" ,
description : "string" ,
} ,
2021-03-12 08:14:32 +00:00
file : {
data : "string" ,
2021-03-12 09:04:05 +00:00
name : "text" ,
type : "file" ,
2021-03-12 08:14:32 +00:00
} ,
2020-05-20 11:30:53 +00:00
} ;
export const GLOBAL_FUNCTIONS = {
2021-07-20 10:02:56 +00:00
"!name" : "DATA_TREE.APPSMITH.FUNCTIONS" ,
2020-05-20 11:30:53 +00:00
navigateTo : {
"!doc" : "Action to navigate the user to another page or url" ,
2021-01-27 06:28:23 +00:00
"!type" : "fn(pageNameOrUrl: string, params: {}, target?: string) -> void" ,
2020-05-20 11:30:53 +00:00
} ,
showAlert : {
"!doc" : "Show a temporary notification style message to the user" ,
"!type" : "fn(message: string, style: string) -> void" ,
} ,
showModal : {
"!doc" : "Open a modal" ,
"!type" : "fn(modalName: string) -> void" ,
} ,
closeModal : {
"!doc" : "Close a modal" ,
"!type" : "fn(modalName: string) -> void" ,
} ,
2020-08-24 12:09:17 +00:00
storeValue : {
"!doc" : "Store key value data locally" ,
"!type" : "fn(key: string, value: any) -> void" ,
} ,
2020-08-28 12:07:37 +00:00
download : {
"!doc" : "Download anything as a file" ,
"!type" : "fn(data: any, fileName: string, fileType?: string) -> void" ,
} ,
2021-01-07 04:44:30 +00:00
copyToClipboard : {
"!doc" : "Copy text to clipboard" ,
"!type" : "fn(data: string, options: object) -> void" ,
} ,
2021-03-02 12:49:36 +00:00
resetWidget : {
"!doc" : "Reset widget values" ,
"!type" : "fn(widgetName: string, resetChildren: boolean) -> void" ,
} ,
2020-05-20 11:30:53 +00:00
} ;