@aehrc/smart-forms-renderer 0.6.4 → 0.6.5
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/README.md +23 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,32 +57,48 @@ function getResponse() {}
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
## Advanced Usage (If basic usage does not suffice)
|
|
60
|
+
|
|
60
61
|
```typescript
|
|
61
62
|
/* Components */
|
|
62
63
|
// A self-initialising wrapper around the rendering engine. This is sufficient for most use cases.
|
|
64
|
+
|
|
63
65
|
function SmartFormsRenderer(props: {
|
|
64
66
|
questionnaire: Questionnaire,
|
|
65
67
|
questionnaireResponse?: QuestionnaireResponse,
|
|
66
68
|
additionalVariables?: Record<string, Extension>
|
|
67
|
-
}) {}
|
|
69
|
+
}): JSX.Element {}
|
|
68
70
|
|
|
69
71
|
// BaseRenderer underneath the SmartFormsRenderer wrapper. Requires buildForm() to initialise form.
|
|
70
|
-
function BaseRenderer() {}
|
|
72
|
+
function BaseRenderer(): JSX.Element {}
|
|
71
73
|
|
|
72
74
|
/* Functions */
|
|
73
75
|
// Get the filled QuestionnaireResponse at its current state.
|
|
74
76
|
// If no changes have been made to the form, the initial QuestionnaireResponse is returned.
|
|
75
|
-
function getResponse() {}
|
|
77
|
+
function getResponse(): QuestionnaireResponse {}
|
|
76
78
|
|
|
77
79
|
// Build the form with an initial Questionnaire and an optional filled QuestionnaireResponse.
|
|
78
80
|
// If a QuestionnaireResponse is not provided, an empty QuestionnaireResponse is set as the initial QuestionnaireResponse.
|
|
79
|
-
function buildForm(
|
|
81
|
+
async function buildForm(
|
|
82
|
+
questionnaire: Questionnaire,
|
|
83
|
+
questionnaireResponse?: QuestionnaireResponse
|
|
84
|
+
): Promise<void> {}
|
|
80
85
|
|
|
81
86
|
// Destroy the form to clean up the questionnaire and questionnaireResponse stores.
|
|
82
|
-
function destroyForm() {}
|
|
83
|
-
|
|
87
|
+
function destroyForm(): void {}
|
|
84
88
|
|
|
85
89
|
// Remove all hidden answers from the filled QuestionnaireResponse.
|
|
86
90
|
// This takes into account the questionnaire-hidden extension, enableWhens and enableWhenExpressions.
|
|
87
|
-
function removeHiddenAnswersFromResponse(
|
|
91
|
+
function removeHiddenAnswersFromResponse(
|
|
92
|
+
questionnaire: Questionnaire,
|
|
93
|
+
questionnaireResponse: QuestionnaireResponse
|
|
94
|
+
): QuestionnaireResponse {}
|
|
88
95
|
```
|
|
96
|
+
|
|
97
|
+
The Smart Forms app uses a even finer-grained control which directly interacts with the state management stores.
|
|
98
|
+
|
|
99
|
+
At the moment there are no plans to document it, but I am happy to do so if there is demand for it.
|
|
100
|
+
Raise a request in https://github.com/aehrc/smart-forms/issues if you want to see it happen!
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
Copyright © 2022, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230. All rights reserved.
|