@lowdefy/docs 3.22.0 → 4.0.0-alpha.1

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/actions/JsAction.yaml +2 -2
  3. package/blocks/all_icons.yaml +1 -0
  4. package/blocks/{display → container}/Alert.yaml +3 -2
  5. package/blocks/{display → container}/Descriptions.yaml +3 -1
  6. package/blocks/container/Drawer.yaml +1 -0
  7. package/blocks/{context → container}/PageHCF.yaml +2 -2
  8. package/blocks/{context → container}/PageHCSF.yaml +2 -2
  9. package/blocks/{context → container}/PageHSCF.yaml +2 -2
  10. package/blocks/{context → container}/PageHeaderMenu.yaml +2 -2
  11. package/blocks/{context → container}/PageSHCF.yaml +2 -2
  12. package/blocks/{context → container}/PageSiderMenu.yaml +2 -2
  13. package/blocks/display/DangerousHtml.yaml +11 -12
  14. package/blocks/display/DangerousMarkdown.yaml +8 -8
  15. package/blocks/display/Img.yaml +1 -1
  16. package/blocks/input/MultipleSelector.yaml +80 -0
  17. package/blocks/input/Selector.yaml +62 -0
  18. package/concepts/custom-blocks.yaml +2 -2
  19. package/concepts/custom-code.yaml +3 -3
  20. package/concepts/lowdefy-schema.yaml +16 -0
  21. package/connections/AxiosHttp.yaml +1 -1
  22. package/deployment/aws-lambda.yaml +2 -2
  23. package/deployment/docker.yaml +2 -2
  24. package/head.html +2 -0
  25. package/howto/generate-csv.yaml.njk +251 -0
  26. package/howto/generate-pdf.yaml.njk +651 -0
  27. package/howto/generateCsv/lowdefy.yaml +63 -0
  28. package/howto/generateCsv/public/csvMake.js +27 -0
  29. package/howto/generatePdf/inv_template.yaml +200 -0
  30. package/howto/generatePdf/lowdefy.yaml +116 -0
  31. package/howto/generatePdf/my_header.html +1 -0
  32. package/howto/generatePdf/public/logo_example.png +0 -0
  33. package/howto/generatePdf/public/modules/importUmd.js +7 -0
  34. package/howto/generatePdf/public/modules/pdfMake.js +7 -0
  35. package/howto/generatePdf/public/modules/vfs_fonts.js +12 -0
  36. package/howto/use-refrences.md +5 -0
  37. package/lowdefy.yaml +1 -1
  38. package/menus.yaml +41 -26
  39. package/operators/_actions.yaml +1 -1
  40. package/operators/_change_case.yaml +4 -4
  41. package/operators/_event.yaml +1 -0
  42. package/operators/_global.yaml +1 -0
  43. package/operators/_index.yaml +1 -0
  44. package/operators/_input.yaml +1 -0
  45. package/operators/_js.yaml +2 -2
  46. package/operators/_ref.yaml +16 -8
  47. package/operators/_state.yaml +1 -0
  48. package/operators/_switch.yaml +51 -0
  49. package/operators/_url_query.yaml +1 -0
  50. package/package.json +7 -7
  51. package/pages.yaml +18 -8
  52. package/public/images/authors/gervwyk.jpeg +0 -0
  53. package/public/images/authors/sandile.jpeg +0 -0
  54. package/public/images/howto/header_generate_csv.jpg +0 -0
  55. package/public/images/howto/header_generate_pdf.jpg +0 -0
  56. package/public/logo_example.png +0 -0
  57. package/public/modules/csvMake.js +27 -0
  58. package/public/modules/importUmd.js +7 -0
  59. package/public/modules/pdfMake.js +7 -0
  60. package/public/modules/vfs_fonts.js +12 -0
  61. package/public/sitemap.xml +216 -201
  62. package/templates/blocks/exampleTransformer.js +1 -1
  63. package/templates/blog.yaml.njk +221 -0
  64. package/templates/footer.yaml.njk +2 -2
  65. package/tutorial/tutorial-create-page.yaml +1 -1
  66. package/tutorial/tutorial-start.yaml +1 -1
  67. package/users/login-and-logout.yaml +2 -2
  68. package/users/openid-connect.yaml +1 -0
  69. package/users/protected-pages.yaml +2 -2
  70. package/users/roles.yaml +2 -2
  71. package/users/users-introduction.yaml +1 -1
  72. package/version.yaml +1 -1
  73. package/blocks/context/Context.yaml +0 -27
@@ -0,0 +1,5 @@
1
+ # How to use references
2
+
3
+ When starting a new Lowdefy application, your app is simple, uncomplicated and easy to navigate between pages, blocks, requests and actions. Unfortunately as with any software application, as you add more functionality, your app code start to grow to thousands of lines of code. When writing an app using conventional tools like javascript, you'd deal with this complexity by splitting your app into methods, files and folders. A experienced programmer will make design choices to best abstract portions of the code to make the app more understandable and maintainable.
4
+
5
+ With Lowdefy the built configuration is served in one giant JSON blob. you can do the same by splitting portions of your Lowdefy config into separate files and folders, and stich them together and
package/lowdefy.yaml CHANGED
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  name: '@lowdefy/docs'
16
- lowdefy: 3.22.0
16
+ lowdefy: 3.23.1
17
17
  licence: Apache-2.0
18
18
 
19
19
  cli:
package/menus.yaml CHANGED
@@ -47,6 +47,22 @@
47
47
  pageId: next-steps
48
48
  properties:
49
49
  title: Next steps
50
+ - id: howto
51
+ type: MenuGroup
52
+ properties:
53
+ title: How To
54
+ icon: QuestionOutlined
55
+ links:
56
+ - id: generate-csv
57
+ type: MenuLink
58
+ pageId: generate-csv-files-from-data
59
+ properties:
60
+ title: Generate CSVs
61
+ - id: generate-pdf
62
+ type: MenuLink
63
+ pageId: generate-pdf-document-from-data
64
+ properties:
65
+ title: Generate PDFs
50
66
  - id: concepts
51
67
  type: MenuGroup
52
68
  properties:
@@ -397,31 +413,6 @@
397
413
  - id: Modal
398
414
  type: MenuLink
399
415
  pageId: Modal
400
- - id: Result
401
- type: MenuLink
402
- pageId: Result
403
- - id: Span
404
- type: MenuLink
405
- pageId: Span
406
- - id: Spin
407
- type: MenuLink
408
- pageId: Spin
409
- - id: Tabs
410
- type: MenuLink
411
- pageId: Tabs
412
- - id: Tooltip
413
- type: MenuLink
414
- pageId: Tooltip
415
-
416
- - id: blocks_context
417
- type: MenuGroup
418
- properties:
419
- title: Context Blocks
420
- icon: GroupOutlined
421
- links:
422
- - id: Context
423
- type: MenuLink
424
- pageId: Context
425
416
  - id: PageHCF
426
417
  type: MenuLink
427
418
  pageId: PageHCF
@@ -440,6 +431,22 @@
440
431
  - id: PageSiderMenu
441
432
  type: MenuLink
442
433
  pageId: PageSiderMenu
434
+ - id: Result
435
+ type: MenuLink
436
+ pageId: Result
437
+ - id: Span
438
+ type: MenuLink
439
+ pageId: Span
440
+ - id: Spin
441
+ type: MenuLink
442
+ pageId: Spin
443
+ - id: Tabs
444
+ type: MenuLink
445
+ pageId: Tabs
446
+ - id: Tooltip
447
+ type: MenuLink
448
+ pageId: Tooltip
449
+
443
450
  - id: blocks_list
444
451
  type: MenuGroup
445
452
  properties:
@@ -733,6 +740,9 @@
733
740
  - id: _sum
734
741
  type: MenuLink
735
742
  pageId: _sum
743
+ - id: _switch
744
+ type: MenuLink
745
+ pageId: _switch
736
746
  - id: _type
737
747
  type: MenuLink
738
748
  pageId: _type
@@ -760,9 +770,14 @@
760
770
  title: Lowdefy Versions
761
771
  icon: BranchesOutlined
762
772
  links:
763
- - id: v3.22.0
773
+ - id: v3.23.1
764
774
  type: MenuLink
765
775
  url: https://docs.lowdefy.com
776
+ properties:
777
+ title: v3.23.1
778
+ - id: v3.22.0
779
+ type: MenuLink
780
+ url: https://61519bcb8b8ed4412aae3057--lowdefy-docs.netlify.app
766
781
  properties:
767
782
  title: v3.22.0
768
783
  - id: v3.21.2
@@ -77,7 +77,7 @@ _ref:
77
77
  First register a custom JavaScript action: `getNormalizedEigenvector`
78
78
  ```yaml
79
79
  # file: lowdefy.yaml
80
- lowdefy: '3.22.0'
80
+ lowdefy: '3.23.1'
81
81
  app:
82
82
  html:
83
83
  appendHead: |
@@ -72,8 +72,8 @@ _ref:
72
72
  _change_case.capitalCase:
73
73
  on:
74
74
  foo: 'bar'
75
- options:
76
- convertKeys: true
75
+ options:
76
+ convertKeys: true
77
77
  ```
78
78
  Returns: `{ "Foo": "Bar" }`
79
79
 
@@ -82,8 +82,8 @@ _ref:
82
82
  _change_case.capitalCase:
83
83
  on:
84
84
  foo: 'bar'
85
- options:
86
- convertValues: false
85
+ options:
86
+ convertValues: false
87
87
  ```
88
88
  Returns: `{ "foo": "bar" }`
89
89
 
@@ -19,6 +19,7 @@ _ref:
19
19
  pageId: _event
20
20
  pageTitle: _event
21
21
  filePath: operators/_event.yaml
22
+ env: Client Only
22
23
  types: |
23
24
  ```
24
25
  (key: string): any
@@ -19,6 +19,7 @@ _ref:
19
19
  pageId: _global
20
20
  pageTitle: _global
21
21
  filePath: operators/_global.yaml
22
+ env: Client Only
22
23
  types: |
23
24
  ```
24
25
  (key: string): any
@@ -19,6 +19,7 @@ _ref:
19
19
  pageId: _index
20
20
  pageTitle: _index
21
21
  filePath: operators/_index.yaml
22
+ env: Client Only
22
23
  types: |
23
24
  ```
24
25
  (key: string): any
@@ -19,6 +19,7 @@ _ref:
19
19
  pageId: _input
20
20
  pageTitle: _input
21
21
  filePath: operators/_input.yaml
22
+ env: Client Only
22
23
  types: |
23
24
  ```
24
25
  (key: string): any
@@ -51,7 +51,7 @@ _ref:
51
51
  ```yaml
52
52
  # lowdefy.yaml
53
53
  name: make-me-primes
54
- lowdefy: '3.22.0'
54
+ lowdefy: '3.23.1'
55
55
  app:
56
56
  html:
57
57
  # This HTML will be appended to the head HTML tag in the Lowdefy app
@@ -119,7 +119,7 @@ _ref:
119
119
  ```yaml
120
120
  # file: lowdefy.yaml
121
121
  name: my-chart
122
- lowdefy: '3.22.0'
122
+ lowdefy: '3.23.1'
123
123
  app:
124
124
  html:
125
125
  appendHead:
@@ -73,7 +73,7 @@ _ref:
73
73
  ###### Reference pages:
74
74
  ```yaml
75
75
  # lowdefy.yaml
76
- lowdefy: '3.22.0'
76
+ lowdefy: '3.23.1'
77
77
  pages:
78
78
  - _ref: pages/page1.yaml
79
79
  - _ref: pages/page2.yaml
@@ -94,7 +94,7 @@ _ref:
94
94
  ```
95
95
  Returns:
96
96
  ```
97
- lowdefy: '3.22.0'
97
+ lowdefy: '3.23.1'
98
98
  pages:
99
99
  - id: page1
100
100
  type: PageHeaderMenu
@@ -176,12 +176,20 @@ _ref:
176
176
 
177
177
  const readFilePromise = promisify(fs.readFile);
178
178
 
179
- async function useLocalOrSharedConfig(path, vars, context) {
180
- const localFile = await readFilePromise(path.resolve(path), 'utf8');
179
+ async function useLocalOrSharedConfig(refPath, vars, context) {
180
+ let fileContent
181
+ try {
182
+ fileContent = await readFilePromise(path.resolve(refPath), 'utf8');
183
+ return fileContent;
184
+ } catch (error) {
185
+ if (error.code === 'ENOENT') {
186
+ fileContent = readFilePromise(path.resolve('../shared', refPath), 'utf8');
187
+ return fileContent;
188
+ }
189
+ throw error;
190
+ }
181
191
 
182
- if (localFile) return localFile;
183
192
 
184
- return readFilePromise(path.resolve('../shared', path), 'utf8');
185
193
  }
186
194
 
187
195
  module.exports = useLocalOrSharedConfig;
@@ -189,7 +197,7 @@ _ref:
189
197
 
190
198
  ```yaml
191
199
  // lowdefy.yaml
192
- lowdefy: 3.22.0
200
+ lowdefy: 3.23.1
193
201
 
194
202
  cli:
195
203
  refResolver: resolvers/useLocalOrSharedConfig.js
@@ -215,7 +223,7 @@ _ref:
215
223
  ```
216
224
  ```yaml
217
225
  // lowdefy.yaml
218
- lowdefy: 3.22.0
226
+ lowdefy: 3.23.1
219
227
 
220
228
  pages:
221
229
  - _ref:
@@ -19,6 +19,7 @@ _ref:
19
19
  pageId: _state
20
20
  pageTitle: _state
21
21
  filePath: operators/_state.yaml
22
+ env: Client Only
22
23
  types: |
23
24
  ```
24
25
  (key: string): any
@@ -0,0 +1,51 @@
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/operators.yaml.njk
17
+ transformer: templates/operatorsMethodTransformer.js
18
+ vars:
19
+ pageId: _switch
20
+ pageTitle: _switch
21
+ filePath: operators/_switch.yaml
22
+ types: |
23
+ ```
24
+ (arguments: {branches: {if: boolean, then: any}[], default: any}): any
25
+ ```
26
+ description: |
27
+ The `_switch` operator evaluates an array of conditions and returns the `then` argument of the first item for which the `if` argument evaluates to `true`. If no condition evaluates to `true`, the value of the `default` argument is returned.
28
+ arguments: |
29
+ ###### object
30
+ - `branches:`
31
+ `if: boolean`: The boolean result of a test.
32
+ `then: any`: The value to return if the test is `true`.
33
+ - `default: any`: The value to return if all the `if` tests are `false`.
34
+ examples: |
35
+ ###### Return a value based on a series of conditions:
36
+ ```yaml
37
+ _switch:
38
+ branches:
39
+ - if:
40
+ _eq:
41
+ - x
42
+ - y
43
+ then: A
44
+ - if:
45
+ _eq:
46
+ - x
47
+ - z
48
+ then: B
49
+ default: C
50
+ ```
51
+ Returns: `"C"` since both of the `if` tests are `false`.
@@ -19,6 +19,7 @@ _ref:
19
19
  pageId: _url_query
20
20
  pageTitle: _url_query
21
21
  filePath: operators/_url_query.yaml
22
+ env: Client Only
22
23
  types: |
23
24
  ```
24
25
  (key: string): any
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/docs",
3
- "version": "3.22.0",
3
+ "version": "4.0.0-alpha.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -31,14 +31,14 @@
31
31
  "test": "jest --coverage"
32
32
  },
33
33
  "devDependencies": {
34
- "@babel/cli": "7.14.3",
35
- "@babel/core": "7.14.3",
36
- "@babel/preset-env": "7.14.4",
37
- "babel-jest": "26.6.3",
38
- "jest": "26.6.3"
34
+ "@babel/cli": "7.15.7",
35
+ "@babel/core": "7.15.8",
36
+ "@babel/preset-env": "7.15.8",
37
+ "babel-jest": "27.3.1",
38
+ "jest": "27.3.1"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "af37daa86e1ba73397eb65f65cacbcbb5461ec79"
43
+ "gitHead": "c97a8fa6b5a641e7d50df09f5601a9c586eeb65a"
44
44
  }
package/pages.yaml CHANGED
@@ -11,6 +11,17 @@
11
11
  - _ref: tutorial/tutorial-deploy.yaml
12
12
  - _ref: tutorial/next-steps.yaml
13
13
 
14
+ - _ref:
15
+ path: howto/generate-csv.yaml.njk
16
+ vars:
17
+ version:
18
+ _ref: version.yaml
19
+ - _ref:
20
+ path: howto/generate-pdf.yaml.njk
21
+ vars:
22
+ version:
23
+ _ref: version.yaml
24
+
14
25
  - _ref: concepts/overview.yaml
15
26
  - _ref: concepts/cli.yaml
16
27
  - _ref: concepts/lowdefy-schema.yaml
@@ -104,20 +115,18 @@
104
115
  - _ref: blocks/container/Drawer.yaml
105
116
  - _ref: blocks/container/Label.yaml
106
117
  - _ref: blocks/container/Modal.yaml
118
+ - _ref: blocks/container/PageHCF.yaml
119
+ - _ref: blocks/container/PageHCSF.yaml
120
+ - _ref: blocks/container/PageHeaderMenu.yaml
121
+ - _ref: blocks/container/PageHSCF.yaml
122
+ - _ref: blocks/container/PageSHCF.yaml
123
+ - _ref: blocks/container/PageSiderMenu.yaml
107
124
  - _ref: blocks/container/Result.yaml
108
125
  - _ref: blocks/container/Span.yaml
109
126
  - _ref: blocks/container/Spin.yaml
110
127
  - _ref: blocks/container/Tabs.yaml
111
128
  - _ref: blocks/container/Tooltip.yaml
112
129
 
113
- - _ref: blocks/context/Context.yaml
114
- - _ref: blocks/context/PageHCF.yaml
115
- - _ref: blocks/context/PageHCSF.yaml
116
- - _ref: blocks/context/PageHeaderMenu.yaml
117
- - _ref: blocks/context/PageHSCF.yaml
118
- - _ref: blocks/context/PageSHCF.yaml
119
- - _ref: blocks/context/PageSiderMenu.yaml
120
-
121
130
  - _ref: blocks/list/ControlledList.yaml
122
131
  - _ref: blocks/list/List.yaml
123
132
  # - _ref: blocks/list/TimelineList.yaml
@@ -205,6 +214,7 @@
205
214
  - _ref: operators/_string.yaml
206
215
  - _ref: operators/_subtract.yaml
207
216
  - _ref: operators/_sum.yaml
217
+ - _ref: operators/_switch.yaml
208
218
  - _ref: operators/_type.yaml
209
219
  - _ref: operators/_uri.yaml
210
220
  - _ref: operators/_url_query.yaml
Binary file
@@ -0,0 +1,27 @@
1
+ const csvMakeFn = async (context, filename, data, fields) => {
2
+ if (!Array.isArray(data) || typeof data[0] !== 'object') {
3
+ throw new Error('csvMake data takes an array of objects');
4
+ }
5
+ if (!fields) {
6
+ fields = Object.keys(data[0]);
7
+ }
8
+ const arrays = [fields];
9
+ data.forEach((obj) => arrays.push(fields.map((field) => obj[field])));
10
+ const csv = arrays
11
+ .map((row) =>
12
+ row
13
+ .map((cell) => (typeof cell === 'undefined' || cell === null ? '' : cell))
14
+ .map(String)
15
+ .map((v) => v.replaceAll('"', '""'))
16
+ .map((v) => `"${v}"`)
17
+ .join(',')
18
+ )
19
+ .join('\r\n');
20
+ const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
21
+ const url = URL.createObjectURL(blob);
22
+ const el = document.createElement('a');
23
+ el.href = url;
24
+ el.setAttribute('download', filename);
25
+ el.click();
26
+ };
27
+ window.lowdefy.registerJsAction('csvMake', csvMakeFn);
@@ -0,0 +1,7 @@
1
+ export default async (url, module = { exports: {} }) =>
2
+ (Function('module', 'exports', await (await fetch(url)).text()).call(
3
+ module,
4
+ module,
5
+ module.exports
6
+ ),
7
+ module).exports;
@@ -0,0 +1,7 @@
1
+ import importUmd from './importUmd.js';
2
+ import vfs from './vfs_fonts.js';
3
+ const pdfMake = await importUmd(`https://unpkg.com/pdfmake@0.1.71/build/pdfmake.min.js`);
4
+ const pdfMakeFn = async (context, filename, docDefinition, tableLayouts, fonts) => {
5
+ await pdfMake.createPdf(docDefinition, tableLayouts, fonts, vfs).download(filename);
6
+ };
7
+ window.lowdefy.registerJsAction('pdfMake', pdfMakeFn);