@lowdefy/docs 4.0.0-alpha.7 → 4.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/operators/client/filter_default_value.js +55 -0
- package/{public/modules/connectDocsearch.js → dist/operatorsClient.js} +1 -19
- package/{templates/blocks/schemaTransformer.js → dist/types.js} +5 -10
- package/package.json +19 -3
- package/404.yaml +0 -26
- package/CHANGELOG.md +0 -697
- package/actions/CallMethod.yaml +0 -57
- package/actions/JsAction.yaml +0 -281
- package/actions/Link.yaml +0 -120
- package/actions/Login.yaml +0 -123
- package/actions/Logout.yaml +0 -44
- package/actions/Message.yaml +0 -68
- package/actions/Notification.yaml +0 -84
- package/actions/Request.yaml +0 -70
- package/actions/Reset.yaml +0 -42
- package/actions/ResetValidation.yaml +0 -102
- package/actions/ScrollTo.yaml +0 -100
- package/actions/SetGlobal.yaml +0 -78
- package/actions/SetState.yaml +0 -85
- package/actions/Throw.yaml +0 -89
- package/actions/Validate.yaml +0 -104
- package/actions/Wait.yaml +0 -40
- package/blocks/all_icons.yaml +0 -803
- package/blocks/container/Affix.yaml +0 -26
- package/blocks/container/Alert.yaml +0 -27
- package/blocks/container/Badge.yaml +0 -27
- package/blocks/container/Box.yaml +0 -27
- package/blocks/container/Card.yaml +0 -29
- package/blocks/container/Collapse.yaml +0 -38
- package/blocks/container/Comment.yaml +0 -43
- package/blocks/container/ConfirmModal.yaml +0 -36
- package/blocks/container/Descriptions.yaml +0 -51
- package/blocks/container/Drawer.yaml +0 -46
- package/blocks/container/Label.yaml +0 -28
- package/blocks/container/Modal.yaml +0 -46
- package/blocks/container/PageHCF.yaml +0 -28
- package/blocks/container/PageHCSF.yaml +0 -29
- package/blocks/container/PageHSCF.yaml +0 -29
- package/blocks/container/PageHeaderMenu.yaml +0 -52
- package/blocks/container/PageSHCF.yaml +0 -29
- package/blocks/container/PageSiderMenu.yaml +0 -53
- package/blocks/container/Result.yaml +0 -34
- package/blocks/container/Span.yaml +0 -27
- package/blocks/container/Spin.yaml +0 -27
- package/blocks/container/Tabs.yaml +0 -41
- package/blocks/container/Tooltip.yaml +0 -38
- package/blocks/display/Anchor.yaml +0 -25
- package/blocks/display/Avatar.yaml +0 -23
- package/blocks/display/Breadcrumb.yaml +0 -28
- package/blocks/display/Button.yaml +0 -43
- package/blocks/display/DangerousHtml.yaml +0 -62
- package/blocks/display/DangerousMarkdown.yaml +0 -46
- package/blocks/display/Divider.yaml +0 -23
- package/blocks/display/EChart.yaml +0 -53
- package/blocks/display/Html.yaml +0 -50
- package/blocks/display/Icon.yaml +0 -23
- package/blocks/display/Img.yaml +0 -40
- package/blocks/display/Markdown.yaml +0 -31
- package/blocks/display/MarkdownWithCode.yaml +0 -46
- package/blocks/display/Menu.yaml +0 -48
- package/blocks/display/Message.yaml +0 -34
- package/blocks/display/MobileMenu.yaml +0 -47
- package/blocks/display/Notification.yaml +0 -34
- package/blocks/display/Paragraph.yaml +0 -30
- package/blocks/display/Progress.yaml +0 -52
- package/blocks/display/Skeleton.yaml +0 -27
- package/blocks/display/Statistic.yaml +0 -35
- package/blocks/display/Title.yaml +0 -32
- package/blocks/input/AutoComplete.yaml +0 -30
- package/blocks/input/ButtonSelector.yaml +0 -36
- package/blocks/input/CheckboxSelector.yaml +0 -36
- package/blocks/input/CheckboxSwitch.yaml +0 -56
- package/blocks/input/ChromeColorSelector.yaml +0 -24
- package/blocks/input/CircleColorSelector.yaml +0 -24
- package/blocks/input/ColorSelector.yaml +0 -24
- package/blocks/input/CompactColorSelector.yaml +0 -24
- package/blocks/input/DateRangeSelector.yaml +0 -26
- package/blocks/input/DateSelector.yaml +0 -26
- package/blocks/input/DateTimeSelector.yaml +0 -28
- package/blocks/input/GithubColorSelector.yaml +0 -24
- package/blocks/input/MonthSelector.yaml +0 -26
- package/blocks/input/MultipleSelector.yaml +0 -117
- package/blocks/input/NumberInput.yaml +0 -24
- package/blocks/input/Pagination.yaml +0 -33
- package/blocks/input/ParagraphInput.yaml +0 -32
- package/blocks/input/PasswordInput.yaml +0 -48
- package/blocks/input/RadioSelector.yaml +0 -36
- package/blocks/input/RatingSlider.yaml +0 -24
- package/blocks/input/S3UploadButton.yaml +0 -28
- package/blocks/input/Selector.yaml +0 -98
- package/blocks/input/SliderColorSelector.yaml +0 -24
- package/blocks/input/SwatchesColorSelector.yaml +0 -24
- package/blocks/input/Switch.yaml +0 -24
- package/blocks/input/TextArea.yaml +0 -27
- package/blocks/input/TextInput.yaml +0 -59
- package/blocks/input/TitleInput.yaml +0 -32
- package/blocks/input/TwitterColorSelector.yaml +0 -24
- package/blocks/input/WeekSelector.yaml +0 -26
- package/blocks/list/ControlledList.yaml +0 -191
- package/blocks/list/List.yaml +0 -157
- package/blocks/list/TimelineList.yaml +0 -136
- package/body.html +0 -1
- package/concepts/blocks.yaml +0 -249
- package/concepts/cli.yaml +0 -173
- package/concepts/connections-and-requests.yaml +0 -114
- package/concepts/context-and-state.yaml +0 -82
- package/concepts/custom-blocks.yaml +0 -190
- package/concepts/custom-code.yaml +0 -197
- package/concepts/events-and-actions.yaml +0 -224
- package/concepts/hosting-files.yaml +0 -50
- package/concepts/layout.yaml +0 -1464
- package/concepts/lists.yaml +0 -162
- package/concepts/lowdefy-schema.yaml +0 -245
- package/concepts/operators.yaml +0 -66
- package/concepts/overview.yaml +0 -48
- package/concepts/secrets.yaml +0 -56
- package/connections/AWSS3.yaml +0 -228
- package/connections/AmazonRedshift.yaml +0 -75
- package/connections/AxiosHttp.yaml +0 -194
- package/connections/Elasticsearch.yaml +0 -378
- package/connections/GoogleSheet.yaml +0 -332
- package/connections/Knex.yaml +0 -181
- package/connections/KnexRequests.md +0 -121
- package/connections/MSSQL.yaml +0 -90
- package/connections/MariaDB.yaml +0 -77
- package/connections/MongoDB.yaml +0 -581
- package/connections/MySQL.yaml +0 -92
- package/connections/OracleDB.yaml +0 -73
- package/connections/PostgreSQL.yaml +0 -99
- package/connections/Redis.yaml +0 -147
- package/connections/SQLite.yaml +0 -94
- package/connections/SendGridMail.yaml +0 -113
- package/connections/Stripe.yaml +0 -139
- package/deployment/aws-lambda.yaml +0 -128
- package/deployment/docker.yaml +0 -118
- package/deployment/netlify.yaml +0 -69
- package/deployment/node-server.yaml +0 -111
- package/head.html +0 -7
- package/howto/generate-csv.yaml.njk +0 -252
- package/howto/generate-pdf.yaml.njk +0 -651
- package/howto/generateCsv/lowdefy.yaml +0 -64
- package/howto/generateCsv/public/csvMake.js +0 -27
- package/howto/generatePdf/inv_template.yaml +0 -200
- package/howto/generatePdf/lowdefy.yaml +0 -117
- package/howto/generatePdf/my_header.html +0 -1
- package/howto/generatePdf/public/logo_example.png +0 -0
- package/howto/generatePdf/public/modules/importUmd.js +0 -7
- package/howto/generatePdf/public/modules/pdfMake.js +0 -7
- package/howto/generatePdf/public/modules/vfs_fonts.js +0 -12
- package/howto/use-refrences.md +0 -5
- package/introduction.yaml +0 -100
- package/lowdefy.yaml +0 -66
- package/menus.yaml +0 -832
- package/operators/_actions.yaml +0 -123
- package/operators/_and.yaml +0 -90
- package/operators/_args.yaml +0 -79
- package/operators/_array.yaml +0 -326
- package/operators/_base64.yaml +0 -56
- package/operators/_change_case.yaml +0 -347
- package/operators/_date.yaml +0 -71
- package/operators/_diff.yaml +0 -75
- package/operators/_divide.yaml +0 -46
- package/operators/_eq.yaml +0 -67
- package/operators/_event.yaml +0 -103
- package/operators/_format.yaml +0 -209
- package/operators/_function.yaml +0 -66
- package/operators/_get.yaml +0 -108
- package/operators/_global.yaml +0 -107
- package/operators/_gt.yaml +0 -65
- package/operators/_gte.yaml +0 -65
- package/operators/_hash.yaml +0 -109
- package/operators/_if.yaml +0 -44
- package/operators/_if_none.yaml +0 -61
- package/operators/_index.yaml +0 -65
- package/operators/_input.yaml +0 -114
- package/operators/_js.yaml +0 -189
- package/operators/_json.yaml +0 -128
- package/operators/_list_contexts.yaml +0 -37
- package/operators/_location.yaml +0 -59
- package/operators/_log.yaml +0 -36
- package/operators/_lt.yaml +0 -65
- package/operators/_lte.yaml +0 -65
- package/operators/_math.yaml +0 -374
- package/operators/_media.yaml +0 -86
- package/operators/_menu.yaml +0 -81
- package/operators/_mql.yaml +0 -101
- package/operators/_ne.yaml +0 -77
- package/operators/_not.yaml +0 -47
- package/operators/_number.yaml +0 -157
- package/operators/_nunjucks.yaml +0 -73
- package/operators/_object.yaml +0 -193
- package/operators/_operator.yaml +0 -47
- package/operators/_or.yaml +0 -81
- package/operators/_product.yaml +0 -59
- package/operators/_random.yaml +0 -104
- package/operators/_ref.yaml +0 -266
- package/operators/_regex.yaml +0 -83
- package/operators/_request.yaml +0 -50
- package/operators/_secret.yaml +0 -74
- package/operators/_state.yaml +0 -114
- package/operators/_string.yaml +0 -283
- package/operators/_subtract.yaml +0 -38
- package/operators/_sum.yaml +0 -59
- package/operators/_switch.yaml +0 -51
- package/operators/_type.yaml +0 -92
- package/operators/_uri.yaml +0 -56
- package/operators/_url_query.yaml +0 -120
- package/operators/_user.yaml +0 -107
- package/operators/_uuid.yaml +0 -114
- package/operators/_var.yaml +0 -105
- package/operators/_yaml.yaml +0 -107
- package/pages.yaml +0 -227
- package/public/images/authors/gervwyk.jpeg +0 -0
- package/public/images/authors/sandile.jpeg +0 -0
- package/public/images/howto/header_generate_csv.jpg +0 -0
- package/public/images/howto/header_generate_pdf.jpg +0 -0
- package/public/logo_example.png +0 -0
- package/public/lowdefy_app_schema.png +0 -0
- package/public/modules/csvMake.js +0 -27
- package/public/modules/filterDefaultValue.js +0 -48
- package/public/modules/importUmd.js +0 -7
- package/public/modules/index.js +0 -5
- package/public/modules/pdfMake.js +0 -7
- package/public/modules/test/filterDefaultValue.test.js +0 -91
- package/public/modules/vfs_fonts.js +0 -12
- package/public/sitemap.xml +0 -1024
- package/templates/actions.yaml.njk +0 -68
- package/templates/blocks/defaultValueTransformer.js +0 -53
- package/templates/blocks/exampleTransformer.js +0 -81
- package/templates/blocks/layout.yaml +0 -114
- package/templates/blocks/propertiesFormTransformer.js +0 -419
- package/templates/blocks/propertiesGetterTransformer.js +0 -132
- package/templates/blocks/schema.yaml.njk +0 -42
- package/templates/blocks/style.yaml +0 -26
- package/templates/blocks/template.yaml.njk +0 -495
- package/templates/blog.yaml.njk +0 -221
- package/templates/cli_command.yaml.njk +0 -37
- package/templates/footer.yaml.njk +0 -604
- package/templates/general.yaml.njk +0 -124
- package/templates/generateSitemap.js +0 -41
- package/templates/header.yaml +0 -138
- package/templates/navigation_buttons.yaml +0 -68
- package/templates/operators.yaml.njk +0 -82
- package/templates/operatorsMethodTransformer.js +0 -119
- package/templates/test/array.test.js +0 -1335
- package/templates/test/boolean.test.js +0 -98
- package/templates/test/button.test.js +0 -166
- package/templates/test/color.test.js +0 -126
- package/templates/test/enum.test.js +0 -105
- package/templates/test/icon.test.js +0 -109
- package/templates/test/integer.test.js +0 -99
- package/templates/test/manual.test.js +0 -238
- package/templates/test/number.test.js +0 -99
- package/templates/test/object.test.js +0 -434
- package/templates/test/oneOf.test.js +0 -794
- package/templates/test/string.test.js +0 -98
- package/templates/test/yaml.test.js +0 -605
- package/tutorial/next-steps.yaml +0 -83
- package/tutorial/tutorial-actions-operators-config.yaml +0 -142
- package/tutorial/tutorial-actions-operators.yaml +0 -436
- package/tutorial/tutorial-add-blocks-config.yaml +0 -109
- package/tutorial/tutorial-add-blocks.yaml +0 -195
- package/tutorial/tutorial-create-page-config.yaml +0 -77
- package/tutorial/tutorial-create-page.yaml +0 -196
- package/tutorial/tutorial-deploy.yaml +0 -146
- package/tutorial/tutorial-requests-config.yaml +0 -186
- package/tutorial/tutorial-requests.yaml +0 -338
- package/tutorial/tutorial-start.yaml +0 -282
- package/users/login-and-logout.yaml +0 -164
- package/users/openid-connect.yaml +0 -84
- package/users/protected-pages.yaml +0 -67
- package/users/roles.yaml +0 -70
- package/users/user-object.yaml +0 -73
- package/users/users-introduction.yaml +0 -80
- package/version.yaml +0 -1
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
# Copyright 2020-2021 Lowdefy, Inc
|
|
2
|
-
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
_ref:
|
|
16
|
-
path: templates/general.yaml.njk
|
|
17
|
-
vars:
|
|
18
|
-
pageId: custom-blocks
|
|
19
|
-
pageTitle: Custom Blocks
|
|
20
|
-
section: Concepts
|
|
21
|
-
filePath: concepts/custom-blocks.yaml
|
|
22
|
-
content:
|
|
23
|
-
- id: warning
|
|
24
|
-
type: Alert
|
|
25
|
-
properties:
|
|
26
|
-
message: |
|
|
27
|
-
SECURITY WARNING: Blocks execute JavaScript inside your Lowdefy app. Insecure code can expose your app or data. Make sure that you only load blocks from a trusted source.
|
|
28
|
-
type: warning
|
|
29
|
-
- id: md1
|
|
30
|
-
type: MarkdownWithCode
|
|
31
|
-
properties:
|
|
32
|
-
content: |
|
|
33
|
-
Blocks in Lowdefy are simple, most often state-less, [React components](https://reactjs.org/docs/components-and-props.html). Lowdefy uses [webpack module federation](https://webpack.js.org/concepts/module-federation/) to implement a micro front-end strategy. This means blocks are imported at load time, and not part of the Lowdefy app build.
|
|
34
|
-
|
|
35
|
-
The decoupling of blocks provides the considerable advantages:
|
|
36
|
-
- Block developers can extend the UI capabilities of Lowdefy by building blocks for the community to utilize.
|
|
37
|
-
- Lowdefy app developers can use community blocks to experiment and extend their apps.
|
|
38
|
-
- Lowdefy blocks are simple, most often stateless React components, thus blocks can be developed quickly and can be used inside Lowdefy apps with ease.
|
|
39
|
-
- The build process is simple and fast since you only build the code for your block, and not the entire application.
|
|
40
|
-
- The Lowdefy engine takes care off the application state, the the block only has to concern itself with a easy application interface.
|
|
41
|
-
|
|
42
|
-
## Using Custom Blocks
|
|
43
|
-
|
|
44
|
-
To use a custom block type inside a Lowdefy app, configure the `types` object in the root of the Lowdefy config. For example to use a AmCharts block we can add a `AmChartsXY` type to the `types`.
|
|
45
|
-
|
|
46
|
-
```yaml
|
|
47
|
-
name: dashboard-app
|
|
48
|
-
lowdefy: 3.23.2
|
|
49
|
-
types:
|
|
50
|
-
AmChartsXY:
|
|
51
|
-
url: https://blocks-cdn.lowdefy.com/v3.10.1/blocks-amcharts/meta/AmChartsXY.json
|
|
52
|
-
# ...
|
|
53
|
-
pages:
|
|
54
|
-
- id: dashboard
|
|
55
|
-
type: PageHeaderMenu
|
|
56
|
-
blocks:
|
|
57
|
-
- id: my_chart
|
|
58
|
-
type: AmChartsXY
|
|
59
|
-
properties:
|
|
60
|
-
#...
|
|
61
|
-
#...
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
By default Lowdefy build apps with a set of pre-configured, default block types to make it easier to build apps, for example using [`Button`](/Button), [`TextInput`](/TextInput), [`Box`](/Box), etc. All the blocks documented in the Lowdefy docs are default types. We will continue to build out this list of default blocks to make it as easy as possible to build excellent feature rich apps.
|
|
65
|
-
|
|
66
|
-
It is possible to overwrite the default a block type by simply defining a url for the default type in the `types` object. This is especially useful when you need to use a older version of a block, or would like to do something unique.
|
|
67
|
-
|
|
68
|
-
#### Examples of Custom Blocks
|
|
69
|
-
|
|
70
|
-
##### AmCharts:
|
|
71
|
-
|
|
72
|
-
[AmCharts](https://www.amcharts.com/) enables you to render powerful javascript charts. We have created the [AmCharts Lowdefy blocks](https://github.com/lowdefy/blocks-amcharts) making it easy to use highly customizable charts in your apps.
|
|
73
|
-
|
|
74
|
-
##### Ag-Grid:
|
|
75
|
-
|
|
76
|
-
[Ag-Grid](https://www.ag-grid.com/) enables you to render feature rich tables. We have created the [AgGrid Lowdefy blocks](https://github.com/lowdefy/blocks-aggrid) making it easy to use advanced tables in your apps.
|
|
77
|
-
|
|
78
|
-
## Steps to develop a custom block
|
|
79
|
-
|
|
80
|
-
#### 1. Clone the blocks template repository
|
|
81
|
-
|
|
82
|
-
To develop a custom block, first clone the [Lowdefy blocks template repository](https://github.com/lowdefy/blocks-template). This template provides a project structure for building a custom block. This structure can be modified to your preferences with the following exceptions:
|
|
83
|
-
- Keep the webpack configuration to ensure your custom block works with Lowdefy block module federation.
|
|
84
|
-
- Blocks need meta data in the block schema format which Lowdefy uses to interpret how to render your block.
|
|
85
|
-
|
|
86
|
-
#### 2. Start your local block server
|
|
87
|
-
|
|
88
|
-
Once the repository is cloned, `yarn install` the block dependencies. Then start the local block server by running `yarn start`. The default is to start you block server on `http://localhost:3002`. Open `http://localhost:3002/meta/DisplayBlock.json` in your browser and confirm the the block meta data is served.
|
|
89
|
-
|
|
90
|
-
You can create multiple blocks in the same repository, or run multiple block servers from different block repositories. Use `yarn start --port {{ port_number }}` when you need to run multiple block servers.
|
|
91
|
-
|
|
92
|
-
#### 3. Configure your block types
|
|
93
|
-
|
|
94
|
-
In your `lowdefy.yaml` file, add your custom block type to the `types` object with the local path.
|
|
95
|
-
|
|
96
|
-
```yaml
|
|
97
|
-
name: dashboard-app
|
|
98
|
-
lowdefy: 3.23.2
|
|
99
|
-
types:
|
|
100
|
-
MyCustomBlock:
|
|
101
|
-
url: http://localhost:3002/meta/MyCustomBlock.json
|
|
102
|
-
# ...
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
You can then test your block locally by running `npx lowdefy@latest dev` to develop your Lowdefy app together with your custom block.
|
|
106
|
-
|
|
107
|
-
#### 4. Code your Lowdefy block
|
|
108
|
-
|
|
109
|
-
A Lowdefy block consist of two files, your schema file and your React component. With Lowdefy we try to keep blocks stateless and let the Lowdefy engine mange application state.
|
|
110
|
-
|
|
111
|
-
For most applications this is fine and it simplifies the block logic, the result is "smaller" blocks and more flexibility to the Lowdefy app builder. It is up to the block developer to decide how to balance the trade off between configurability and complexity of the block. For example, it might be better for a UI elements like a Calender to be state-full and packaged as one piece, rather than to break the Calender up into various smaller blocks, that Lowdefy app developers need to piece together. With that said, it is worth mentioning that every time the block properties changes, Lowdefy will rerender the entire block, this can have a performance impact when blocks become large and complex.
|
|
112
|
-
|
|
113
|
-
### Block schema definition
|
|
114
|
-
|
|
115
|
-
- `category: enum`: How this block should be rendered in the Lowdefy app. Can be either `display`, `input`, `container`, `context` or `list`.
|
|
116
|
-
- `valueType: enum`: For blocks of the `input` block category, Lowdefy enforces a value type in `state`. This can be either a `boolean`, `number`, `string`, `object` or `array`. Lowdefy provides a default value for the block. This is usually `null`, but is `false` for boolean blocks, and the empty array, `[]`, for array blocks.
|
|
117
|
-
- `loading: boolean | object`: Settings for the default loading skeleton to render while the block is in a loading status. `false` will render an empty div element while `true` will render the default block skeleton based on the block category. Else an `object` can be provided for more refined settings, see the [loading placeholder types](/blocks) for more details A Lowdefy app developer can over write these defaults by defining the `loading` settings when configuring a block.
|
|
118
|
-
- `schema: object`: Provide a valid [JSON-Schema](https://json-schema.org/) definition for the block `properties` and `events`.
|
|
119
|
-
|
|
120
|
-
### Block React Component Props
|
|
121
|
-
|
|
122
|
-
The React component will receive the following props:
|
|
123
|
-
|
|
124
|
-
- `basePath: string`: The base path setting for the application. This variable is used to prefix route paths for example `${basePath}/public/logo-square-light-theme.png`. The default base path is ''.
|
|
125
|
-
- `blockId: string`: The block's id within the Lowdefy app, this is useful for setting a unique `id` on DOM elements.
|
|
126
|
-
- `components: object`: Helper React components that are exposed to blocks to use internally.
|
|
127
|
-
- `Icon`: component`: Lowdefy standard Icon React component to render build in icons.
|
|
128
|
-
- `Link`: component`: Lowdefy standard Link React component used as links to pages or external urls. The following props apply:
|
|
129
|
-
- `ariaLabel: string`: Arial-label to apply to link tag.
|
|
130
|
-
- `back: boolean`: When the link is clicked, trigger the browser back.
|
|
131
|
-
- `home: boolean`: When the link is clicked, route to the home page.
|
|
132
|
-
- `input: object`: When the link is clicked, pass data as the input object to the next Lowdefy page. Can only be used with pageId link and newTab false. See [Input]( TODO: Link to input page? ).
|
|
133
|
-
- `newTab: boolean`: When the link is clicked, open the page in a new browser tab.
|
|
134
|
-
- `pageId: string`: When the link is clicked, route to the provided Lowdefy page.
|
|
135
|
-
- `rel: string`: The relationship of the linked URL as space-separated link types.
|
|
136
|
-
- `replace: boolean`: Prevent adding a new entry into browser history by replacing the url instead of pushing into history. Can only be used with pageId link and newTab false.
|
|
137
|
-
- `scroll: boolean`: Disable scrolling to the top of the page after page transition. Can only be used with pageId link and newTab false.
|
|
138
|
-
- `url: string`: When the link is clicked, route to an external url.
|
|
139
|
-
- `urlQuery: object`: When the link is clicked, pass data as a url query to the next page. See [url query]( TODO: Link to url query page? ).
|
|
140
|
-
- `content: object`: Passed to `container` and `context` block categories. The `content` object with methods to render sub blocks into content areas. The method name is the same as the area key, for example, 'content.content()` renders a blocks default `content` area.
|
|
141
|
-
- `events: object`: All events defined on the block in the Lowdefy app config.
|
|
142
|
-
- `[event_key]: object`: Event keys gives a handle name to the event details.
|
|
143
|
-
- `loading: boolean`: True while the list of actions are being executed.
|
|
144
|
-
- `actions: actionObjects[]`: The list of [Lowdefy action objects](https://docs.lowdefy.com/events-and-actions) which will be evaluated by the Lowdefy engine.
|
|
145
|
-
- `history: object[]`: A list of objects logging the event calls and responses.
|
|
146
|
-
- `blockId: string`: The block id from which the event was called.
|
|
147
|
-
- `endTimestamp: datetime`: Timestamp for when the event was completed.
|
|
148
|
-
- `event: object`: The event object passed to the event.
|
|
149
|
-
- `eventName: string`: The event name which which triggerEvent was called.
|
|
150
|
-
- `success: boolean`: True if all actions for the event executed without throwing any errors.
|
|
151
|
-
- `startTimestamp: datetime`: Timestamp for when the event was started.
|
|
152
|
-
- `responses: object`: The list of action responses, where the object key is equal to the action id.
|
|
153
|
-
- `{{ key }}: string`:
|
|
154
|
-
- `type: string`: The type of action called.
|
|
155
|
-
- `error: Error`: If the action throw an error.
|
|
156
|
-
- `index: number`: Index of the action in the event array.
|
|
157
|
-
- `response: any`: The returned result of the action.
|
|
158
|
-
- `skipped: boolean`: True if the action was skipped.
|
|
159
|
-
- `methods: object`: All application methods built into Lowdefy, available for the block.
|
|
160
|
-
- `makeCssClass(cssObject | cssObject[]): string`: This methods creates a css class for the block to apply to DOM elements. Css classes are created using [Emotion](https://emotion.sh/docs/introduction). If a list of cssObject are given the cssObjects are shallow merged with the preceding objects properties being overwritten by the latter. Any valid css style object can be passed, including media queries. Default media queries are built in:
|
|
161
|
-
- `xs?: object`: Css object applied for screen media with max width of 576px.
|
|
162
|
-
- `sm?: object`: Css object applied for screen media with min width of 576px.
|
|
163
|
-
- `md?: object`: Css object applied for screen media with min width of 768px.
|
|
164
|
-
- `lg?: object`: Css object applied for screen media with min width of 992px.
|
|
165
|
-
- `xl?: object`: Css object applied for screen media with min width of 1200px.
|
|
166
|
-
- `xxl?: object`: Css object applied for screen media with min width of 1600px.
|
|
167
|
-
- `registerEvent(event: { name: string, actions: actionObjects[] })`: This method can be used to register internal actions for the block to trigger, and overwrites the user config if user defined actions are provided for the same event name.
|
|
168
|
-
- `registerMethod(methodName: string, fn(any))`: This method allows the block developed to expose a method to the Lowdefy app developer via the [`CallMethod`](https://docs.lowdefy.com/CallMethod) action. When the method name for the block id is triggered via a `CallMethod` action, `fn` is evaluated.
|
|
169
|
-
- `triggerEvent({name: string, event?: any })`: This methods triggers a event when called, like `onClick` for when a button is clicked. Optionally, event data can be passed which will be available inside the event actions through the [`_event`](https://docs.lowdefy.com/_event) operator.
|
|
170
|
-
- `properties: object`: The properties object provides all the block settings defined in the Lowdefy config, operators can be used when defining block properties and evaluated operators are passed to the block. When the evaluated result of these properties change, the block rerenders to display the updated block.
|
|
171
|
-
- `required: boolean`: For blocks of the `input` category, whether or not a input value is required. Required can be defined by operators and the evaluated result is passed to the block. The [`Validate`](https://docs.lowdefy.com/Validate) action will check if the required values are present else raise `validation` errors and suspend further block actions in the event queue.
|
|
172
|
-
- `validation: object`: For blocks of the `input` category, the validation property provides result of `Validate` relevant relevant to the specific block. See [block validation](/blocks) for more details.
|
|
173
|
-
- `status: enum`: The validation status result. Can be `error`, `success` or `warning`. Only validation which results in an `error` status will suspend further block actions in the event queue.
|
|
174
|
-
- `errors: string[]`: The list of error messaged raised whiled block validation was evaluated, for this block.
|
|
175
|
-
- `warnings: string[]`: The list of warnings messaged raised whiled block validation was evaluated, for this block.
|
|
176
|
-
|
|
177
|
-
## Deploying Custom Blocks
|
|
178
|
-
|
|
179
|
-
Both the block metadata and block React component need to be built by webpack and hosted on a publicly accessible static file server. Any Lowdefy app can then load and use the block. You also need to set the `remoteEntryUrl` in `webpack.prod.js` in order to build the correct block meta data, make sure the URL is pointing to where your block is hosted.
|
|
180
|
-
|
|
181
|
-
The easiest way to host your custom block is the deploy the custom block to [npm](https://www.npmjs.com/) and [Unpkg](https://unpkg.com/) will automatically host your block for you on their CDN. Although this option is easy, the cache settings for Unpkg can result in longer load times in some cases which can result in a unreliable user experience. It is thus best to deploy you blocks to your own static file servers.
|
|
182
|
-
|
|
183
|
-
We are working on a Lowdefy blocks CDN to improve this developer experience in the future.
|
|
184
|
-
- _ref:
|
|
185
|
-
path: templates/navigation_buttons.yaml
|
|
186
|
-
vars:
|
|
187
|
-
previous_page_title: Custom Code
|
|
188
|
-
previous_page_id: custom-code
|
|
189
|
-
next_page_title: User authentication
|
|
190
|
-
next_page_id: users-introduction
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
# Copyright 2020-2021 Lowdefy, Inc
|
|
2
|
-
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
_ref:
|
|
16
|
-
path: templates/general.yaml.njk
|
|
17
|
-
vars:
|
|
18
|
-
pageId: custom-code
|
|
19
|
-
pageTitle: Custom Code
|
|
20
|
-
section: Concepts
|
|
21
|
-
filePath: concepts/custom-code.yaml
|
|
22
|
-
content:
|
|
23
|
-
- id: warning
|
|
24
|
-
type: Alert
|
|
25
|
-
properties:
|
|
26
|
-
message: |
|
|
27
|
-
SECURITY WARNING: Custom code executes JavaScript inside your Lowdefy app. Insecure code can expose your app or data. Since Lowdefy doesn't validate your custom code, make sure that you only load trusted code.
|
|
28
|
-
type: warning
|
|
29
|
-
- id: md1
|
|
30
|
-
type: MarkdownWithCode
|
|
31
|
-
properties:
|
|
32
|
-
# TODO: Remove JsAction reference.
|
|
33
|
-
content: |
|
|
34
|
-
Lowdefy runs as a single page web app (SPA). It is possible to extend the functionality of a Lowdefy app by loading custom code (HTML, CSS and JavaScript) into the HTML `head` and `body` to of the default `index.html` page.
|
|
35
|
-
|
|
36
|
-
The content loaded into the `head` and `body` tag can be any valid HTML, most often `script` tags are loaded to register a new [`JsAction`](/JsAction) or [`_js`](/_js) operator. However, third party code can also be imported, for example Google Analytics, Intercom, etc. Be sure to only load trusted code into your app, as this code will be able to execute JavaScript on all pages of your Lowdefy app, which could expose you app or data to security vulnerabilities. Your own code can easily be hosted from the [Lowdefy public folder](/hosting-files).
|
|
37
|
-
|
|
38
|
-
> __Warning__: Lowdefy implements the [Ant design](https://ant.design/) UI component framework for app layout and most blocks, thus the default Ant Design CSS is loaded for all Lowdefy apps. Take caution not to unintentionally overwrite existing style settings and classes which can result in a degraded user experience.
|
|
39
|
-
|
|
40
|
-
## Schema to load custom code
|
|
41
|
-
|
|
42
|
-
- `app.html.appendHead: string`: Any valid HTML content can be loaded just before the `</head>` tag of the Lowdefy app `index.html` file.
|
|
43
|
-
- `app.html.appendBody: string`: Any valid HTML content can be loaded just before the `</body>` tag of the Lowdefy app `index.html` file.
|
|
44
|
-
|
|
45
|
-
Most often it is convenient to abstract this HTML out to a separate file using the [`_ref`](/_ref) operator.
|
|
46
|
-
|
|
47
|
-
> __Warning__: Code imported using `appendHead` or `appendBody` will be loaded, and can execute JavaScript on every page of your Lowdefy app.
|
|
48
|
-
|
|
49
|
-
#### Examples
|
|
50
|
-
|
|
51
|
-
###### Loading third party code snippet like Google Analytics:
|
|
52
|
-
|
|
53
|
-
To add [Google Analytics](/https://developers.google.com/analytics/devguides/collection/analyticsjs) to a Lowdefy app, the `lowdefy.yaml` can be setup with:
|
|
54
|
-
|
|
55
|
-
```yaml
|
|
56
|
-
name: google-analytics-example
|
|
57
|
-
lowdefy: 3.23.2
|
|
58
|
-
# ...
|
|
59
|
-
app:
|
|
60
|
-
html:
|
|
61
|
-
appendHead: |
|
|
62
|
-
<!-- Google Analytics -->
|
|
63
|
-
<script>
|
|
64
|
-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
65
|
-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
66
|
-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
67
|
-
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
|
68
|
-
|
|
69
|
-
ga('create', 'UA-XXXXX-Y', 'auto');
|
|
70
|
-
ga('send', 'pageview');
|
|
71
|
-
</script>
|
|
72
|
-
<!-- End Google Analytics -->
|
|
73
|
-
# ...
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
###### Load, register and trigger a custom `JsAction` from code in the app `public` folder:
|
|
77
|
-
|
|
78
|
-
This example fetches a list of Todos from [{JSON}placeholder](https://jsonplaceholder.typicode.com/), and updates [state](/context-and-state).
|
|
79
|
-
|
|
80
|
-
1) First, add the JavaScript code to the `public` folder and resister the `JsAction`:
|
|
81
|
-
```js
|
|
82
|
-
// /public/fetchTodos.js
|
|
83
|
-
function async fetchTodos(context, numItems, skip) {
|
|
84
|
-
const data = await fetch('https://jsonplaceholder.typicode.com/todos');
|
|
85
|
-
const todos = await data.json();
|
|
86
|
-
return todos.slice(skip, skip + numItems);
|
|
87
|
-
}
|
|
88
|
-
// Register the JsAction for the Lowdefy app to use.
|
|
89
|
-
window.lowdefy.registerJsAction('fetchTodos', fetchTodos);
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
2) Import the JavaScript as a module into the page:
|
|
93
|
-
```html
|
|
94
|
-
<!-- /header_modules.html -->
|
|
95
|
-
<script type="module" src="/public/fetchTodos.js"></script>
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
3) Set load the custom code into the app header and trigger the action on page load:
|
|
99
|
-
```yaml
|
|
100
|
-
# /lowdefy.yaml
|
|
101
|
-
name: json-todos
|
|
102
|
-
lowdefy: 3.23.2
|
|
103
|
-
app:
|
|
104
|
-
html:
|
|
105
|
-
appendHead:
|
|
106
|
-
_ref: header_modules.html # Load the custom HTML into the header.
|
|
107
|
-
pages:
|
|
108
|
-
- id: todos
|
|
109
|
-
type: PageHeaderMenu
|
|
110
|
-
events:
|
|
111
|
-
onEnter:
|
|
112
|
-
- id: get_todos
|
|
113
|
-
type: JsAction # TODO:
|
|
114
|
-
params:
|
|
115
|
-
name: fetchTodos # Trigger the custom JavaScript action.
|
|
116
|
-
args:
|
|
117
|
-
- 10 # numItems
|
|
118
|
-
- 0 # skip
|
|
119
|
-
- id: set_todos
|
|
120
|
-
type: SetState
|
|
121
|
-
params:
|
|
122
|
-
todos:
|
|
123
|
-
# Set the response of the get_todos action to state.
|
|
124
|
-
_actions: get_todos.response
|
|
125
|
-
# ...
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Loading and registering a [`_js`](/_js) operator
|
|
129
|
-
|
|
130
|
-
Similar to the loading custom JavaScript actions, custom JavaScript operators can also be loaded. In order for the Lowdefy app engine to execute a custom JavaScript [operator](/operators), the JavaScript code for the operator must be loaded onto the page and registered using the `registerJsOperator` method available on the browser [`window`](https://developer.mozilla.org/en-US/docs/Web/API/window) object by calling `window.lowdefy.registerJsOperator(name: string, action: function)`.
|
|
131
|
-
|
|
132
|
-
All `_js` functions must be synchronous.
|
|
133
|
-
|
|
134
|
-
#### Examples
|
|
135
|
-
|
|
136
|
-
###### Load, register and use a custom `_js` operator from code in the app `public` folder:
|
|
137
|
-
|
|
138
|
-
This example uses a `_js` operator to remove all duplicates from a list of names.
|
|
139
|
-
|
|
140
|
-
1) First, add the JavaScript code to the `public` folder and resister the `_js` operator:
|
|
141
|
-
```js
|
|
142
|
-
// /public/foo_operators.js
|
|
143
|
-
function removeDuplicates(items) {
|
|
144
|
-
return [ ...new Set(items) ];
|
|
145
|
-
}
|
|
146
|
-
// Register the removeDuplicates function as a _js.deduplicate operator.
|
|
147
|
-
window.lowdefy.registerJsOperator('deduplicate', removeDuplicates);
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
2) Import the JavaScript as a module into the page:
|
|
151
|
-
```html
|
|
152
|
-
<!-- /header.html -->
|
|
153
|
-
<script type="module" src="/public/foo_operators.js"></script>
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
3) Set load the custom code into the app header and use the new operator on the page:
|
|
157
|
-
```yaml
|
|
158
|
-
# /lowdefy.yaml
|
|
159
|
-
name: operator-example
|
|
160
|
-
lowdefy: 3.23.2
|
|
161
|
-
app:
|
|
162
|
-
html:
|
|
163
|
-
appendHead:
|
|
164
|
-
_ref: header.html # Load the custom HTML into the header.
|
|
165
|
-
pages:
|
|
166
|
-
- id: some_names
|
|
167
|
-
type: PageHeaderMenu
|
|
168
|
-
blocks:
|
|
169
|
-
- id: names
|
|
170
|
-
type: ButtonSelector
|
|
171
|
-
properties:
|
|
172
|
-
title: Select your new friend
|
|
173
|
-
options:
|
|
174
|
-
# use the removeDuplicates function and pass a list of names as a function argument
|
|
175
|
-
_js.deduplicate:
|
|
176
|
-
- - Anne
|
|
177
|
-
- Sam
|
|
178
|
-
- Joe
|
|
179
|
-
- Micheal
|
|
180
|
-
- Sam
|
|
181
|
-
- Steven
|
|
182
|
-
- Anne
|
|
183
|
-
- Pepper
|
|
184
|
-
# ...
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
------
|
|
188
|
-
|
|
189
|
-
Custom code provides an easy way to extent the logic functionality of Lowdefy apps. However, to extend the UI capabilities beyond the existing features provided by the default Lowdefy blocks, custom blocks can be loaded onto apps.
|
|
190
|
-
|
|
191
|
-
- _ref:
|
|
192
|
-
path: templates/navigation_buttons.yaml
|
|
193
|
-
vars:
|
|
194
|
-
previous_page_title: Lists
|
|
195
|
-
previous_page_id: lists
|
|
196
|
-
next_page_title: Custom Blocks
|
|
197
|
-
next_page_id: custom-blocks
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
# Copyright 2020-2021 Lowdefy, Inc
|
|
2
|
-
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
_ref:
|
|
16
|
-
path: templates/general.yaml.njk
|
|
17
|
-
vars:
|
|
18
|
-
pageId: events-and-actions
|
|
19
|
-
pageTitle: Events and Actions
|
|
20
|
-
section: Concepts
|
|
21
|
-
filePath: concepts/events-and-actions.yaml
|
|
22
|
-
content:
|
|
23
|
-
- id: md1
|
|
24
|
-
type: MarkdownWithCode
|
|
25
|
-
properties:
|
|
26
|
-
content: |
|
|
27
|
-
### TLDR
|
|
28
|
-
- Events are triggered when something happens on a page, like clicking a button or loading a page.
|
|
29
|
-
- A list of actions are executed sequentially by a triggered event.
|
|
30
|
-
- If an action errors, the actions that follow are skipped.
|
|
31
|
-
- Actions that are `async: true` will not executed sequentially nor stop the event if they error.
|
|
32
|
-
- Action errors can be handled by providing a list of `try` and `catch` actions to the event.
|
|
33
|
-
- Operators used in action `params` are evaluated right before the action is executed.
|
|
34
|
-
- The [`_actions`](/_actions)) operator is available for sequential actions to use the values returned from preceding actions in the chain.
|
|
35
|
-
- Actions have a `skip` field that can be used to skip action execution.
|
|
36
|
-
- The `onInit` event is triggered the first time a context is mounted and keeps the page in loading until all actions have finished.
|
|
37
|
-
- The `onEnter` event is triggered the every time a context is mounted and keeps the page in loading until all actions have finished.
|
|
38
|
-
- The `onInitAsync` event is triggered the first time a context is mounted and does not keep the page in loading.
|
|
39
|
-
- The `onEnterAsync` event is triggered the every time a context is mounted and does not keep the page in loading.
|
|
40
|
-
|
|
41
|
-
-----------
|
|
42
|
-
|
|
43
|
-
Blocks can define _events_ which the block can trigger when something happens on the page, like a button being clicked, an input's value being modified or a page being loaded. Some examples are `onClick` on a [`Button`](/Button) or `onEnter` on a [`PageHeaderMenu`](/PageHeaderMenu) block.
|
|
44
|
-
|
|
45
|
-
All blocks implements `onMount` and `onMountAsync` events. These are useful for triggering actions when a block is mounted. For the `onMount` event, the block only mounts when the event action chain is completed, however, for the `onMountAsync` event, the block will mount as soon as possible while the event actions completes execution.
|
|
46
|
-
|
|
47
|
-
_Actions_ are tasks that can be executed, like calling a request, linking to a new page or changing a value in state. An array of actions can be defined for a event on a block. If that event gets triggered, those actions will execute sequentially. If any actions error while executing, the actions that follow it won't be executed, however, `catch` actions chain can be defined on a event to trigger when an error in a chain of actions occurs.
|
|
48
|
-
|
|
49
|
-
Actions which are `async: true` are an exception to the sequential rule of the actions chain. These actions will be executed asynchronously and the next actions in the chain will not wait for them to finish. If any `async: true` action throws an error, the chain will not be stopped and the event will still be completed successfully.
|
|
50
|
-
|
|
51
|
-
Each action has an `id`, unique to that action chain, and a `type` field which are required.
|
|
52
|
-
|
|
53
|
-
Actions can have a `params` field for specifying input parameters when executing the action. Operators used in action `params` will be evaluated right before the action is executed. Some events might have data relating to that event, like what the new value of an input is, or the row that was clicked in a table. The `event` object can be used in the action using the [`_event`](/_event) operator. Some actions also return values which can be passed to preceding actions in the same action chain using the [`_actions`](/_actions) operator.
|
|
54
|
-
|
|
55
|
-
Actions can also have a `skip` field. Operators in the `skip` field will be evaluated before an action is executed, and if the evaluated result is `true`, that action is skipped and the next action is executed.
|
|
56
|
-
|
|
57
|
-
# Action Schema
|
|
58
|
-
|
|
59
|
-
The schema for a Lowdefy action is:
|
|
60
|
-
|
|
61
|
-
- `id: string`: __Required__ - A identifier for the action. It must be unique within the action chain it is defined in.
|
|
62
|
-
- `type: string`: __Required__ - The action type to be used. It must be a valid action type.
|
|
63
|
-
- `skip: boolean`: The test that determines whether the action will be skipped or not. This is usually written as operators which evaluates to a `true` or `false`. __Operators are evaluated__.
|
|
64
|
-
- `async: boolean`: This determines whether the action will be evaluated asynchronously. Operators are __not__ evaluated on `async`.
|
|
65
|
-
- `messages: object`: __Operators are evaluated__.
|
|
66
|
-
- `error: boolean | string`: If `boolean`, whether an error message should be displayed if the action throws an error. Error messages are shown by default. If a `string`, the error message to show to the user.
|
|
67
|
-
- `loading: boolean | string`: If `boolean`, whether a loading message should be displayed while the action is executing. Loading messages are not shown by default. If a `string`, the loading message to show to the user.
|
|
68
|
-
- `success: boolean | string`: If `boolean`, whether a success message should be displayed if the action completes successfully. Success messages are not shown by default. If a `string`, the success message to show to the user.
|
|
69
|
-
- `params: object`: The input passed to the action. __Operators are evaluated__.
|
|
70
|
-
|
|
71
|
-
###### Events and actions definition example:
|
|
72
|
-
```yaml
|
|
73
|
-
- id: block_with_actions
|
|
74
|
-
type: Block
|
|
75
|
-
properties:
|
|
76
|
-
# ...
|
|
77
|
-
events:
|
|
78
|
-
onEvent1:
|
|
79
|
-
- id: action1
|
|
80
|
-
type: ActionType1
|
|
81
|
-
skip:
|
|
82
|
-
# Operator expression that returns true if action should be skipped.
|
|
83
|
-
params:
|
|
84
|
-
# ...
|
|
85
|
-
- id: action2
|
|
86
|
-
type: ActionType2
|
|
87
|
-
onEvent2:
|
|
88
|
-
- id: action3
|
|
89
|
-
type: ActionType3
|
|
90
|
-
params:
|
|
91
|
-
# ...
|
|
92
|
-
```
|
|
93
|
-
# The actions object
|
|
94
|
-
|
|
95
|
-
When events are triggered, each completed action writes its response to the actions object under the action id object key. Thus all following actions in a event action list have access to the responses of all preceding actions in the same event list through the [`_actions`](/_actions) operator.
|
|
96
|
-
|
|
97
|
-
# The event object
|
|
98
|
-
|
|
99
|
-
When events are triggered, the can provide a data object describing the event (e.g. a description of the clicked item or uploaded file). This data object can be accessed using the [`_event`](/_event) operator in an action definition.
|
|
100
|
-
|
|
101
|
-
The schema for passing actions to Lowdefy events is:
|
|
102
|
-
```
|
|
103
|
-
(eventName: action[])
|
|
104
|
-
(eventName: {
|
|
105
|
-
debounce?: {
|
|
106
|
-
ms?: number,
|
|
107
|
-
immediate?: boolean,
|
|
108
|
-
},
|
|
109
|
-
try: action[],
|
|
110
|
-
catch?: action[],
|
|
111
|
-
})
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
# Catching action errors
|
|
115
|
-
|
|
116
|
-
If one action in the chain of event actions fails by throwing an error, the actions in the list following the failed action will not be executed. To handle any errors thrown by an action, Lowdefy event actions can be provided as lists of `try` and `catch` actions.
|
|
117
|
-
|
|
118
|
-
###### Event try catch actions example for dealing with action errors:
|
|
119
|
-
```yaml
|
|
120
|
-
- id: block_with_actions
|
|
121
|
-
type: Block
|
|
122
|
-
properties:
|
|
123
|
-
# ...
|
|
124
|
-
events:
|
|
125
|
-
onEvent1:
|
|
126
|
-
try:
|
|
127
|
-
- id: action1
|
|
128
|
-
type: ActionType1
|
|
129
|
-
params:
|
|
130
|
-
# ...
|
|
131
|
-
- id: action2
|
|
132
|
-
type: ActionType2
|
|
133
|
-
catch:
|
|
134
|
-
- id: unsuccessful
|
|
135
|
-
type: ActionType1
|
|
136
|
-
params:
|
|
137
|
-
# ...
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
# Debouncing events
|
|
141
|
-
|
|
142
|
-
Event debouncing can be turned on by setting the `debounce` field on event objects. If `debounce.immediate` is `true`, leading edge debouncing or throttling will apply, else it will be debounced as trailing edge.
|
|
143
|
-
|
|
144
|
-
To control the debounce delay, set `debounce.ms` to the number of milliseconds to delay. The default delay is 300 milliseconds. If an event is triggered within that time, the event will not be triggered again. See [debounce vs throttling](https://redd.one/blog/debounce-vs-throttle) for a more detailed explanation.
|
|
145
|
-
|
|
146
|
-
###### Event trailing edge debouncing example:
|
|
147
|
-
```yaml
|
|
148
|
-
- id: block_with_actions
|
|
149
|
-
type: Block
|
|
150
|
-
properties:
|
|
151
|
-
# ...
|
|
152
|
-
events:
|
|
153
|
-
onEvent1:
|
|
154
|
-
debounce:
|
|
155
|
-
ms: 1000
|
|
156
|
-
try:
|
|
157
|
-
- id: action1
|
|
158
|
-
type: ActionType1
|
|
159
|
-
params:
|
|
160
|
-
# ...
|
|
161
|
-
- id: action2
|
|
162
|
-
type: ActionType2
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
###### Event throttling or leading edge debouncing example:
|
|
166
|
-
```yaml
|
|
167
|
-
- id: block_with_actions
|
|
168
|
-
type: Block
|
|
169
|
-
properties:
|
|
170
|
-
# ...
|
|
171
|
-
events:
|
|
172
|
-
onEvent1:
|
|
173
|
-
debounce:
|
|
174
|
-
ms: 1000
|
|
175
|
-
immediate: true
|
|
176
|
-
try:
|
|
177
|
-
- id: action1
|
|
178
|
-
type: ActionType1
|
|
179
|
-
params:
|
|
180
|
-
# ...
|
|
181
|
-
- id: action2
|
|
182
|
-
type: ActionType2
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
# Context initialisation events
|
|
186
|
-
|
|
187
|
-
Four events are always defined for [`context`](/context) type blocks, called in the following order:
|
|
188
|
-
- `onInit`
|
|
189
|
-
- `onEnter`
|
|
190
|
-
- `onInitAsync`
|
|
191
|
-
- `onEnterAsync`
|
|
192
|
-
|
|
193
|
-
These events can be used to initialize the context or page.
|
|
194
|
-
|
|
195
|
-
The `onInit` event is triggered the first time a context is mounted, for example if a page is loaded for the first time. This event blocks page render, in other words, the page __will__ remain in a loading state until all the actions have completed execution. It can be used to set up a context. Actions that take a long time to execute, like `Request`, should be used sparingly here.
|
|
196
|
-
|
|
197
|
-
The `onEnter` event is triggered every time a context is mounted to a page, for example if a user left a page, and returns to it. This event also blocks page render. It can be used to execute actions that should be run each time a page is loaded, like checking if an id is present in the [url query parameters](/_url_query), and initializing the [`state`](/context-and-state).
|
|
198
|
-
|
|
199
|
-
The `onInitAsync` event is triggered the first time a context is mounted, but does not block page render. In other words, the page __will not__ remain in a loading state until all the actions have completed execution. This is a good place to execute non-blocking tasks or requests that might take longer to execute.
|
|
200
|
-
|
|
201
|
-
The `onEnterAsync` event is triggered every time a context is mounted, but does not block page render.
|
|
202
|
-
|
|
203
|
-
# Action types
|
|
204
|
-
|
|
205
|
-
The following actions can be used:
|
|
206
|
-
|
|
207
|
-
- [`CallMethod`](/CallMethod) - Call a method defined by another block.
|
|
208
|
-
- [`JsAction`](/JsAction) - Call a custom JavaScript function as an action.
|
|
209
|
-
- [`Link`](/Link) - Link to another page.
|
|
210
|
-
- [`Message`](/Message) - Show a message to the user.
|
|
211
|
-
- [`Notification`](/Notification) - Show a notification to the user.
|
|
212
|
-
- [`Request`](/Request) - Call a request.
|
|
213
|
-
- [`Reset`](/Reset) - Reset the page validation and `state`.
|
|
214
|
-
- [`ScrollTo`](/ScrollTo) - Scroll to a point on the page.
|
|
215
|
-
- [`SetGlobal`](/SetGlobal) - Set a value to the `global` variable object.
|
|
216
|
-
- [`SetState`](/SetState) - Set a value to the page `state`.
|
|
217
|
-
- [`Validate`](/Validate) - Validate the inputs on the page.
|
|
218
|
-
- _ref:
|
|
219
|
-
path: templates/navigation_buttons.yaml
|
|
220
|
-
vars:
|
|
221
|
-
previous_page_title: Connections and Requests
|
|
222
|
-
previous_page_id: connections-and-requests
|
|
223
|
-
next_page_title: Operators
|
|
224
|
-
next_page_id: operators
|