@aehrc/smart-forms-renderer 0.7.2 → 0.8.0
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/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js +0 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.d.ts +12 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js +39 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.d.ts +3 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js +14 -27
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.d.ts +13 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js +42 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.d.ts +4 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js +14 -22
- package/lib/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.d.ts +2 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js +3 -3
- package/lib/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.d.ts +12 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js +27 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.d.ts +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js +9 -24
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.d.ts +14 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js +42 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.d.ts +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js +8 -21
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.d.ts +10 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js +41 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js +7 -23
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.d.ts +12 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.js +42 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.js.map +1 -0
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js +8 -18
- package/lib/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js +4 -4
- package/lib/components/FormComponents/GroupItem/GroupItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/Item.styles.d.ts +2 -2
- package/lib/components/FormComponents/Item.styles.js +2 -2
- package/lib/components/FormComponents/Item.styles.js.map +1 -1
- package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.d.ts +8 -0
- package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.js +37 -0
- package/lib/components/FormComponents/ItemParts/RadioAnswerOptionButtons.js.map +1 -0
- package/lib/components/FormComponents/ItemParts/RadioButtons.d.ts +8 -0
- package/lib/components/FormComponents/ItemParts/RadioButtons.js +37 -0
- package/lib/components/FormComponents/ItemParts/RadioButtons.js.map +1 -0
- package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.d.ts +8 -0
- package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.js +37 -0
- package/lib/components/FormComponents/ItemParts/RadioButtonsAnswerOption.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.d.ts +20 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.js +49 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.d.ts +0 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.js +2 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteFieldEndAdornment.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js +11 -35
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.d.ts +17 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js +42 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.d.ts +3 -3
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js +23 -36
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.d.ts +2 -2
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js +3 -3
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.d.ts +15 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js +29 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.d.ts +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js +3 -23
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.d.ts +11 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.js +14 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.d.ts +0 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.js +2 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionFields.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js +18 -23
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.d.ts +12 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.js +16 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js +8 -14
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.js.map +1 -1
- package/lib/components/FormComponents/SingleItem/SingleItem.d.ts +2 -2
- package/lib/components/FormComponents/SingleItem/SingleItem.js +2 -2
- package/lib/components/FormComponents/SingleItem/SingleItem.js.map +1 -1
- package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.d.ts +2 -2
- package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js +3 -3
- package/lib/components/FormComponents/SingleItem/SingleItemSwitcher.js.map +1 -1
- package/lib/components/FormComponents/Tables/AddItemButton.d.ts +8 -0
- package/lib/components/FormComponents/Tables/AddItemButton.js +28 -0
- package/lib/components/FormComponents/Tables/AddItemButton.js.map +1 -0
- package/lib/components/FormComponents/Tables/AddRowButton.d.ts +8 -0
- package/lib/components/FormComponents/Tables/AddRowButton.js +28 -0
- package/lib/components/FormComponents/Tables/AddRowButton.js.map +1 -0
- package/lib/components/FormComponents/Tables/GroupTable.d.ts +10 -0
- package/lib/components/FormComponents/Tables/GroupTable.js +108 -0
- package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -0
- package/lib/components/FormComponents/Tables/GroupTableRow.d.ts +10 -0
- package/lib/components/FormComponents/Tables/GroupTableRow.js +46 -0
- package/lib/components/FormComponents/Tables/GroupTableRow.js.map +1 -0
- package/lib/components/FormComponents/Tables/index.d.ts +1 -1
- package/lib/components/FormComponents/Tables/index.js +1 -1
- package/lib/components/FormComponents/Tables/index.js.map +1 -1
- package/lib/components/Renderer/FormBodyTabbed.js +1 -1
- package/lib/components/Renderer/FormBodyTabbed.js.map +1 -1
- package/lib/components/Tabs/FormBodySingleTab.js +1 -1
- package/lib/components/Tabs/FormBodySingleTab.js.map +1 -1
- package/lib/components/Tabs/FormBodyTabList.d.ts +1 -0
- package/lib/components/Tabs/FormBodyTabList.js +3 -4
- package/lib/components/Tabs/FormBodyTabList.js.map +1 -1
- package/lib/components/Tabs/FormBodyTabListWrapper.d.ts +1 -1
- package/lib/components/Tabs/FormBodyTabListWrapper.js +6 -13
- package/lib/components/Tabs/FormBodyTabListWrapper.js.map +1 -1
- package/lib/components/Tabs/ShowCompletedTabsSection.d.ts +7 -0
- package/lib/components/Tabs/ShowCompletedTabsSection.js +34 -0
- package/lib/components/Tabs/ShowCompletedTabsSection.js.map +1 -0
- package/lib/hooks/useContextDisplayItems.d.ts +6 -0
- package/lib/hooks/useContextDisplayItems.js +30 -0
- package/lib/hooks/useContextDisplayItems.js.map +1 -0
- package/lib/hooks/useInitialiseRenderer.js +2 -2
- package/lib/hooks/useInitialiseRenderer.js.map +1 -1
- package/lib/hooks/useInitialiseRepeatGroups.d.ts +1 -1
- package/lib/hooks/useNumberInput.d.ts +1 -1
- package/lib/hooks/useNumberInput.js.map +1 -1
- package/lib/hooks/useStringInput.d.ts +1 -1
- package/lib/hooks/useStringInput.js.map +1 -1
- package/lib/hooks/useTerminologyServerQuery.js +3 -6
- package/lib/hooks/useTerminologyServerQuery.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/interfaces/renderProps.interface.d.ts +3 -0
- package/lib/stores/useQuestionnaireResponseStore.d.ts +2 -1
- package/lib/stores/useQuestionnaireResponseStore.js +5 -3
- package/lib/stores/useQuestionnaireResponseStore.js.map +1 -1
- package/lib/utils/qrItem.d.ts +2 -3
- package/lib/utils/qrItem.js +2 -3
- package/lib/utils/qrItem.js.map +1 -1
- package/lib/utils/repopulateIntoResponse.d.ts +2 -2
- package/lib/utils/repopulateItems.js +0 -1
- package/lib/utils/repopulateItems.js.map +1 -1
- package/package.json +7 -7
- package/src/components/FormComponents/ChoiceItems/ChoiceAutocompleteItem.tsx +0 -1
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionFields.tsx +85 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerOptionItem.tsx +35 -58
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetFields.tsx +79 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceCheckboxAnswerValueSetItem.tsx +37 -50
- package/src/components/FormComponents/ChoiceItems/ChoiceItemSwitcher.tsx +10 -5
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.tsx +48 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionItem.tsx +25 -53
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx +83 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetItem.tsx +27 -49
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionFields.tsx +81 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerOptionItem.tsx +19 -54
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetFields.tsx +97 -0
- package/src/components/FormComponents/ChoiceItems/ChoiceSelectAnswerValueSetItem.tsx +22 -60
- package/src/components/FormComponents/GroupItem/GroupItemSwitcher.tsx +4 -4
- package/src/components/FormComponents/Item.styles.ts +2 -2
- package/src/components/FormComponents/ItemParts/RadioAnswerOptionButtons.tsx +72 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteField.tsx +131 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceAutocompleteItem.tsx +38 -93
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionFields.tsx +112 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerOptionItem.tsx +57 -76
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceItemSwitcher.tsx +8 -5
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionFields.tsx +72 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerOptionItem.tsx +12 -59
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionField.tsx +54 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerOptionItem.tsx +40 -64
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetField.tsx +63 -0
- package/src/components/FormComponents/OpenChoiceItems/OpenChoiceSelectAnswerValueSetItem.tsx +22 -50
- package/src/components/FormComponents/SingleItem/SingleItem.tsx +6 -3
- package/src/components/FormComponents/SingleItem/SingleItemSwitcher.tsx +7 -3
- package/src/components/FormComponents/Tables/AddRowButton.tsx +49 -0
- package/src/components/FormComponents/Tables/{QItemGroupTable.tsx → GroupTable.tsx} +6 -17
- package/src/components/FormComponents/Tables/{QItemGroupTableRow.tsx → GroupTableRow.tsx} +2 -2
- package/src/components/FormComponents/Tables/index.ts +1 -1
- package/src/components/Renderer/FormBodyTabbed.tsx +1 -1
- package/src/components/Tabs/FormBodySingleTab.tsx +1 -1
- package/src/components/Tabs/FormBodyTabList.tsx +5 -8
- package/src/components/Tabs/FormBodyTabListWrapper.tsx +15 -26
- package/src/components/Tabs/ShowCompletedTabsSection.tsx +52 -0
- package/src/hooks/useContextDisplayItems.ts +40 -0
- package/src/hooks/useInitialiseRenderer.ts +2 -2
- package/src/hooks/useInitialiseRepeatGroups.ts +1 -1
- package/src/hooks/useNumberInput.ts +2 -1
- package/src/hooks/useStringInput.ts +2 -1
- package/src/hooks/useTerminologyServerQuery.ts +3 -6
- package/src/index.ts +2 -2
- package/src/interfaces/renderProps.interface.ts +4 -0
- package/src/stores/useQuestionnaireResponseStore.ts +5 -4
- package/src/utils/qrItem.ts +4 -3
- package/src/utils/repopulateIntoResponse.ts +2 -2
- package/src/utils/repopulateItems.ts +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import Autocomplete from '@mui/material/Autocomplete';
|
|
20
|
+
import { StandardTextField } from '../Textfield.styles';
|
|
21
|
+
import { StyledAlert } from '../../Alert.styles';
|
|
22
|
+
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
23
|
+
import Typography from '@mui/material/Typography';
|
|
24
|
+
import type { Coding, QuestionnaireItem } from 'fhir/r4';
|
|
25
|
+
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
26
|
+
import type { PropsWithIsTabledAttribute } from '../../../interfaces/renderProps.interface';
|
|
27
|
+
|
|
28
|
+
interface ChoiceSelectAnswerValueSetFieldsProps extends PropsWithIsTabledAttribute {
|
|
29
|
+
qItem: QuestionnaireItem;
|
|
30
|
+
codings: Coding[];
|
|
31
|
+
valueCoding: Coding | null;
|
|
32
|
+
serverError: Error | null;
|
|
33
|
+
onSelectChange: (newValue: Coding | null) => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function ChoiceSelectAnswerValueSetFields(props: ChoiceSelectAnswerValueSetFieldsProps) {
|
|
37
|
+
const { qItem, codings, valueCoding, serverError, isTabled, onSelectChange } = props;
|
|
38
|
+
|
|
39
|
+
const { displayUnit, displayPrompt, readOnly, entryFormat } = useRenderingExtensions(qItem);
|
|
40
|
+
|
|
41
|
+
if (codings.length > 0) {
|
|
42
|
+
return (
|
|
43
|
+
<Autocomplete
|
|
44
|
+
id={qItem.id}
|
|
45
|
+
options={codings}
|
|
46
|
+
getOptionLabel={(option) => `${option.display}`}
|
|
47
|
+
value={valueCoding ?? null}
|
|
48
|
+
onChange={(_, newValue) => onSelectChange(newValue)}
|
|
49
|
+
openOnFocus
|
|
50
|
+
autoHighlight
|
|
51
|
+
sx={{ maxWidth: !isTabled ? 280 : 3000, minWidth: 160, flexGrow: 1 }}
|
|
52
|
+
size="small"
|
|
53
|
+
disabled={readOnly}
|
|
54
|
+
placeholder={entryFormat}
|
|
55
|
+
renderInput={(params) => (
|
|
56
|
+
<StandardTextField
|
|
57
|
+
isTabled={isTabled}
|
|
58
|
+
label={displayPrompt}
|
|
59
|
+
{...params}
|
|
60
|
+
InputProps={{
|
|
61
|
+
...params.InputProps,
|
|
62
|
+
endAdornment: (
|
|
63
|
+
<>
|
|
64
|
+
{params.InputProps.endAdornment}
|
|
65
|
+
{displayUnit}
|
|
66
|
+
</>
|
|
67
|
+
)
|
|
68
|
+
}}
|
|
69
|
+
data-test="q-item-choice-dropdown-answer-value-set-field"
|
|
70
|
+
/>
|
|
71
|
+
)}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (serverError) {
|
|
77
|
+
return (
|
|
78
|
+
<StyledAlert color="error">
|
|
79
|
+
<ErrorOutlineIcon color="error" sx={{ pr: 0.75 }} />
|
|
80
|
+
<Typography variant="subtitle2">
|
|
81
|
+
There was an error fetching options from the terminology server
|
|
82
|
+
</Typography>
|
|
83
|
+
</StyledAlert>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<StyledAlert color="error">
|
|
89
|
+
<ErrorOutlineIcon color="error" sx={{ pr: 0.75 }} />
|
|
90
|
+
<Typography variant="subtitle2">
|
|
91
|
+
Unable to fetch options from the questionnaire or launch context
|
|
92
|
+
</Typography>
|
|
93
|
+
</StyledAlert>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default ChoiceSelectAnswerValueSetFields;
|
|
@@ -15,27 +15,22 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type { SyntheticEvent } from 'react';
|
|
19
18
|
import React, { useEffect, useMemo } from 'react';
|
|
20
|
-
import Autocomplete from '@mui/material/Autocomplete';
|
|
21
19
|
import Grid from '@mui/material/Grid';
|
|
22
|
-
import Typography from '@mui/material/Typography';
|
|
23
20
|
|
|
24
21
|
import type { Coding, QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
25
22
|
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
26
|
-
import { StandardTextField } from '../Textfield.styles';
|
|
27
23
|
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
28
24
|
import useValueSetCodings from '../../../hooks/useValueSetCodings';
|
|
29
25
|
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
30
|
-
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
31
26
|
import type {
|
|
32
27
|
PropsWithIsRepeatedAttribute,
|
|
33
28
|
PropsWithIsTabledAttribute,
|
|
34
29
|
PropsWithQrItemChangeHandler
|
|
35
30
|
} from '../../../interfaces/renderProps.interface';
|
|
36
|
-
import { StyledAlert } from '../../Alert.styles';
|
|
37
31
|
import DisplayInstructions from '../DisplayItem/DisplayInstructions';
|
|
38
32
|
import LabelWrapper from '../ItemParts/ItemLabelWrapper';
|
|
33
|
+
import ChoiceSelectAnswerValueSetFields from './ChoiceSelectAnswerValueSetFields';
|
|
39
34
|
|
|
40
35
|
interface ChoiceSelectAnswerValueSetItemProps
|
|
41
36
|
extends PropsWithQrItemChangeHandler<QuestionnaireResponseItem>,
|
|
@@ -50,14 +45,13 @@ function ChoiceSelectAnswerValueSetItem(props: ChoiceSelectAnswerValueSetItemPro
|
|
|
50
45
|
|
|
51
46
|
// Init input value
|
|
52
47
|
const qrChoiceSelect = qrItem ?? createEmptyQrItem(qItem);
|
|
53
|
-
let valueCoding: Coding |
|
|
48
|
+
let valueCoding: Coding | null = null;
|
|
54
49
|
if (qrChoiceSelect.answer) {
|
|
55
|
-
valueCoding = qrChoiceSelect.answer[0].valueCoding;
|
|
50
|
+
valueCoding = qrChoiceSelect.answer[0].valueCoding ?? null;
|
|
56
51
|
}
|
|
57
52
|
|
|
58
53
|
// Get additional rendering extensions
|
|
59
|
-
const {
|
|
60
|
-
useRenderingExtensions(qItem);
|
|
54
|
+
const { displayInstructions } = useRenderingExtensions(qItem);
|
|
61
55
|
|
|
62
56
|
// Get codings/options from valueSet
|
|
63
57
|
const { codings, serverError } = useValueSetCodings(qItem);
|
|
@@ -84,7 +78,7 @@ function ChoiceSelectAnswerValueSetItem(props: ChoiceSelectAnswerValueSetItemPro
|
|
|
84
78
|
);
|
|
85
79
|
|
|
86
80
|
// Event handlers
|
|
87
|
-
function handleChange(
|
|
81
|
+
function handleChange(newValue: Coding | null) {
|
|
88
82
|
if (newValue) {
|
|
89
83
|
onQrItemChange({
|
|
90
84
|
...createEmptyQrItem(qItem),
|
|
@@ -95,56 +89,17 @@ function ChoiceSelectAnswerValueSetItem(props: ChoiceSelectAnswerValueSetItemPro
|
|
|
95
89
|
onQrItemChange(createEmptyQrItem(qItem));
|
|
96
90
|
}
|
|
97
91
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
autoHighlight
|
|
108
|
-
sx={{ maxWidth: !isTabled ? 280 : 3000, minWidth: 160, flexGrow: 1 }}
|
|
109
|
-
size="small"
|
|
110
|
-
disabled={readOnly}
|
|
111
|
-
placeholder={entryFormat}
|
|
112
|
-
renderInput={(params) => (
|
|
113
|
-
<StandardTextField
|
|
114
|
-
isTabled={isTabled}
|
|
115
|
-
label={displayPrompt}
|
|
116
|
-
{...params}
|
|
117
|
-
InputProps={{
|
|
118
|
-
...params.InputProps,
|
|
119
|
-
endAdornment: (
|
|
120
|
-
<>
|
|
121
|
-
{params.InputProps.endAdornment}
|
|
122
|
-
{displayUnit}
|
|
123
|
-
</>
|
|
124
|
-
)
|
|
125
|
-
}}
|
|
126
|
-
data-test="q-item-choice-dropdown-answer-value-set-field"
|
|
127
|
-
/>
|
|
128
|
-
)}
|
|
92
|
+
if (isRepeated) {
|
|
93
|
+
return (
|
|
94
|
+
<ChoiceSelectAnswerValueSetFields
|
|
95
|
+
qItem={qItem}
|
|
96
|
+
codings={codings}
|
|
97
|
+
valueCoding={valueCoding}
|
|
98
|
+
serverError={serverError}
|
|
99
|
+
isTabled={isTabled}
|
|
100
|
+
onSelectChange={handleChange}
|
|
129
101
|
/>
|
|
130
|
-
) : serverError ? (
|
|
131
|
-
<StyledAlert color="error">
|
|
132
|
-
<ErrorOutlineIcon color="error" sx={{ pr: 0.75 }} />
|
|
133
|
-
<Typography variant="subtitle2">
|
|
134
|
-
There was an error fetching options from the terminology server
|
|
135
|
-
</Typography>
|
|
136
|
-
</StyledAlert>
|
|
137
|
-
) : (
|
|
138
|
-
<StyledAlert color="error">
|
|
139
|
-
<ErrorOutlineIcon color="error" sx={{ pr: 0.75 }} />
|
|
140
|
-
<Typography variant="subtitle2">
|
|
141
|
-
Unable to fetch options from the questionnaire or launch context
|
|
142
|
-
</Typography>
|
|
143
|
-
</StyledAlert>
|
|
144
102
|
);
|
|
145
|
-
|
|
146
|
-
if (isRepeated) {
|
|
147
|
-
return <>{choiceSelectAnswerValueSet}</>;
|
|
148
103
|
}
|
|
149
104
|
|
|
150
105
|
return (
|
|
@@ -154,7 +109,14 @@ function ChoiceSelectAnswerValueSetItem(props: ChoiceSelectAnswerValueSetItemPro
|
|
|
154
109
|
<LabelWrapper qItem={qItem} />
|
|
155
110
|
</Grid>
|
|
156
111
|
<Grid item xs={7}>
|
|
157
|
-
|
|
112
|
+
<ChoiceSelectAnswerValueSetFields
|
|
113
|
+
qItem={qItem}
|
|
114
|
+
codings={codings}
|
|
115
|
+
valueCoding={valueCoding}
|
|
116
|
+
serverError={serverError}
|
|
117
|
+
isTabled={isTabled}
|
|
118
|
+
onSelectChange={handleChange}
|
|
119
|
+
/>
|
|
158
120
|
<DisplayInstructions displayInstructions={displayInstructions} />
|
|
159
121
|
</Grid>
|
|
160
122
|
</Grid>
|
|
@@ -21,8 +21,8 @@ import type {
|
|
|
21
21
|
PropsWithQrRepeatGroupChangeHandler
|
|
22
22
|
} from '../../../interfaces/renderProps.interface';
|
|
23
23
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
24
|
-
import { isSpecificItemControl } from '../../../utils
|
|
25
|
-
import
|
|
24
|
+
import { isSpecificItemControl } from '../../../utils';
|
|
25
|
+
import GroupTable from '../Tables/GroupTable';
|
|
26
26
|
import RepeatGroup from '../RepeatGroup/RepeatGroup';
|
|
27
27
|
import { isRepeatItemAndNotCheckbox } from '../../../utils/qItem';
|
|
28
28
|
import RepeatItem from '../RepeatItem/RepeatItem';
|
|
@@ -60,7 +60,7 @@ function GroupItemSwitcher(props: GroupItemSwitcherProps) {
|
|
|
60
60
|
|
|
61
61
|
if (isSpecificItemControl(qItem, 'gtable')) {
|
|
62
62
|
return (
|
|
63
|
-
<
|
|
63
|
+
<GroupTable
|
|
64
64
|
qItem={qItem}
|
|
65
65
|
qrItems={qrItems}
|
|
66
66
|
groupCardElevation={groupCardElevation + 1}
|
|
@@ -100,7 +100,7 @@ function GroupItemSwitcher(props: GroupItemSwitcherProps) {
|
|
|
100
100
|
// their qrItem array should always be empty
|
|
101
101
|
if (isSpecificItemControl(qItem, 'gtable')) {
|
|
102
102
|
return (
|
|
103
|
-
<
|
|
103
|
+
<GroupTable
|
|
104
104
|
qItem={qItem}
|
|
105
105
|
qrItems={[]}
|
|
106
106
|
groupCardElevation={groupCardElevation + 1}
|
|
@@ -20,11 +20,11 @@ import RadioGroup from '@mui/material/RadioGroup';
|
|
|
20
20
|
import Typography from '@mui/material/Typography';
|
|
21
21
|
import { styled } from '@mui/material/styles';
|
|
22
22
|
|
|
23
|
-
export const
|
|
23
|
+
export const StyledFormGroup = styled(FormGroup)(() => ({
|
|
24
24
|
marginBottom: 4
|
|
25
25
|
}));
|
|
26
26
|
|
|
27
|
-
export const
|
|
27
|
+
export const StyledRadioGroup = styled(RadioGroup)(() => ({
|
|
28
28
|
marginBottom: 4
|
|
29
29
|
}));
|
|
30
30
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import ChoiceRadioSingle from '../ChoiceItems/ChoiceRadioSingle';
|
|
20
|
+
import type { QuestionnaireItem } from 'fhir/r4';
|
|
21
|
+
|
|
22
|
+
interface RadioAnswerOptionButtonsProps {
|
|
23
|
+
qItem: QuestionnaireItem;
|
|
24
|
+
readOnly: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function RadioAnswerOptionButtons(props: RadioAnswerOptionButtonsProps) {
|
|
28
|
+
const { qItem, readOnly } = props;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
{qItem.answerOption?.map((option) => {
|
|
33
|
+
if (option['valueCoding']) {
|
|
34
|
+
return (
|
|
35
|
+
<ChoiceRadioSingle
|
|
36
|
+
key={option.valueCoding.code ?? ''}
|
|
37
|
+
value={option.valueCoding.code ?? ''}
|
|
38
|
+
label={option.valueCoding.display ?? `${option.valueCoding.code}`}
|
|
39
|
+
readOnly={readOnly}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (option['valueString']) {
|
|
45
|
+
return (
|
|
46
|
+
<ChoiceRadioSingle
|
|
47
|
+
key={option.valueString}
|
|
48
|
+
value={option.valueString}
|
|
49
|
+
label={option.valueString}
|
|
50
|
+
readOnly={readOnly}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (option['valueInteger']) {
|
|
56
|
+
return (
|
|
57
|
+
<ChoiceRadioSingle
|
|
58
|
+
key={option.valueInteger}
|
|
59
|
+
value={option.valueInteger.toString()}
|
|
60
|
+
label={option.valueInteger.toString()}
|
|
61
|
+
readOnly={readOnly}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return null;
|
|
67
|
+
})}
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default RadioAnswerOptionButtons;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import Box from '@mui/material/Box';
|
|
20
|
+
import Autocomplete from '@mui/material/Autocomplete';
|
|
21
|
+
import { StandardTextField } from '../Textfield.styles';
|
|
22
|
+
import SearchIcon from '@mui/icons-material/Search';
|
|
23
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
24
|
+
import Fade from '@mui/material/Fade';
|
|
25
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
26
|
+
import InfoIcon from '@mui/icons-material/Info';
|
|
27
|
+
import WarningAmberIcon from '@mui/icons-material/WarningAmber';
|
|
28
|
+
import DoneIcon from '@mui/icons-material/Done';
|
|
29
|
+
import ErrorIcon from '@mui/icons-material/Error';
|
|
30
|
+
import type { Coding, QuestionnaireItem } from 'fhir/r4';
|
|
31
|
+
import type { PropsWithIsTabledAttribute } from '../../../interfaces/renderProps.interface';
|
|
32
|
+
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
33
|
+
import type { AlertColor } from '@mui/material/Alert';
|
|
34
|
+
|
|
35
|
+
interface OpenChoiceAutocompleteFieldProps extends PropsWithIsTabledAttribute {
|
|
36
|
+
qItem: QuestionnaireItem;
|
|
37
|
+
options: Coding[];
|
|
38
|
+
valueAutocomplete: string | Coding;
|
|
39
|
+
input: string;
|
|
40
|
+
loading: boolean;
|
|
41
|
+
feedback: { message: string; color: AlertColor } | null;
|
|
42
|
+
onInputChange: (newInput: string) => void;
|
|
43
|
+
onValueChange: (newValue: Coding | string | null) => void;
|
|
44
|
+
onUnfocus: () => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function OpenChoiceAutocompleteField(props: OpenChoiceAutocompleteFieldProps) {
|
|
48
|
+
const {
|
|
49
|
+
qItem,
|
|
50
|
+
options,
|
|
51
|
+
valueAutocomplete,
|
|
52
|
+
input,
|
|
53
|
+
loading,
|
|
54
|
+
feedback,
|
|
55
|
+
isTabled,
|
|
56
|
+
onInputChange,
|
|
57
|
+
onValueChange,
|
|
58
|
+
onUnfocus
|
|
59
|
+
} = props;
|
|
60
|
+
|
|
61
|
+
// Get additional rendering extensions
|
|
62
|
+
const { displayUnit, displayPrompt, readOnly, entryFormat } = useRenderingExtensions(qItem);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<Box display="flex">
|
|
66
|
+
<Autocomplete
|
|
67
|
+
id={qItem.id}
|
|
68
|
+
value={valueAutocomplete}
|
|
69
|
+
options={options}
|
|
70
|
+
getOptionLabel={(option) => (typeof option === 'string' ? option : `${option.display}`)}
|
|
71
|
+
disabled={readOnly}
|
|
72
|
+
loading={loading}
|
|
73
|
+
loadingText={'Fetching results...'}
|
|
74
|
+
clearOnEscape
|
|
75
|
+
freeSolo
|
|
76
|
+
autoHighlight
|
|
77
|
+
sx={{ maxWidth: !isTabled ? 280 : 3000, minWidth: 220, flexGrow: 1 }}
|
|
78
|
+
placeholder={entryFormat}
|
|
79
|
+
onChange={(_, newValue) => onValueChange(newValue)}
|
|
80
|
+
filterOptions={(x) => x}
|
|
81
|
+
renderInput={(params) => (
|
|
82
|
+
<StandardTextField
|
|
83
|
+
{...params}
|
|
84
|
+
value={input}
|
|
85
|
+
onBlur={onUnfocus}
|
|
86
|
+
onChange={(e) => onInputChange(e.target.value)}
|
|
87
|
+
isTabled={isTabled}
|
|
88
|
+
label={displayPrompt}
|
|
89
|
+
size="small"
|
|
90
|
+
InputProps={{
|
|
91
|
+
...params.InputProps,
|
|
92
|
+
startAdornment: (
|
|
93
|
+
<>
|
|
94
|
+
{!valueAutocomplete || valueAutocomplete === '' ? (
|
|
95
|
+
<SearchIcon fontSize="small" sx={{ ml: 0.5 }} />
|
|
96
|
+
) : null}
|
|
97
|
+
{params.InputProps.startAdornment}
|
|
98
|
+
</>
|
|
99
|
+
),
|
|
100
|
+
endAdornment: (
|
|
101
|
+
<>
|
|
102
|
+
{loading ? (
|
|
103
|
+
<CircularProgress color="inherit" size={16} />
|
|
104
|
+
) : feedback ? (
|
|
105
|
+
<Fade in={!!feedback} timeout={300}>
|
|
106
|
+
<Tooltip title={feedback.message} arrow sx={{ ml: 1 }}>
|
|
107
|
+
{
|
|
108
|
+
{
|
|
109
|
+
info: <InfoIcon fontSize="small" color="info" />,
|
|
110
|
+
warning: <WarningAmberIcon fontSize="small" color="warning" />,
|
|
111
|
+
success: <DoneIcon fontSize="small" color="success" />,
|
|
112
|
+
error: <ErrorIcon fontSize="small" color="error" />
|
|
113
|
+
}[feedback.color]
|
|
114
|
+
}
|
|
115
|
+
</Tooltip>
|
|
116
|
+
</Fade>
|
|
117
|
+
) : null}
|
|
118
|
+
{params.InputProps.endAdornment}
|
|
119
|
+
{displayUnit}
|
|
120
|
+
</>
|
|
121
|
+
)
|
|
122
|
+
}}
|
|
123
|
+
data-test="q-item-open-choice-autocomplete-field"
|
|
124
|
+
/>
|
|
125
|
+
)}
|
|
126
|
+
/>
|
|
127
|
+
</Box>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default OpenChoiceAutocompleteField;
|
|
@@ -15,27 +15,15 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type { ChangeEvent, SyntheticEvent } from 'react';
|
|
19
18
|
import React, { useState } from 'react';
|
|
20
|
-
import Autocomplete from '@mui/material/Autocomplete';
|
|
21
|
-
import Box from '@mui/material/Box';
|
|
22
|
-
import CircularProgress from '@mui/material/CircularProgress';
|
|
23
|
-
import Fade from '@mui/material/Fade';
|
|
24
19
|
import Grid from '@mui/material/Grid';
|
|
25
|
-
import Tooltip from '@mui/material/Tooltip';
|
|
26
20
|
|
|
27
21
|
import type { Coding, QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
28
22
|
|
|
29
23
|
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
30
|
-
import { StandardTextField } from '../Textfield.styles';
|
|
31
24
|
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
32
|
-
import SearchIcon from '@mui/icons-material/Search';
|
|
33
25
|
import useDebounce from '../../../hooks/useDebounce';
|
|
34
26
|
import useTerminologyServerQuery from '../../../hooks/useTerminologyServerQuery';
|
|
35
|
-
import WarningAmberIcon from '@mui/icons-material/WarningAmber';
|
|
36
|
-
import InfoIcon from '@mui/icons-material/Info';
|
|
37
|
-
import DoneIcon from '@mui/icons-material/Done';
|
|
38
|
-
import ErrorIcon from '@mui/icons-material/Error';
|
|
39
27
|
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
40
28
|
import type {
|
|
41
29
|
PropsWithIsRepeatedAttribute,
|
|
@@ -45,6 +33,7 @@ import type {
|
|
|
45
33
|
import { AUTOCOMPLETE_DEBOUNCE_DURATION } from '../../../utils/debounce';
|
|
46
34
|
import DisplayInstructions from '../DisplayItem/DisplayInstructions';
|
|
47
35
|
import LabelWrapper from '../ItemParts/ItemLabelWrapper';
|
|
36
|
+
import OpenChoiceAutocompleteField from './OpenChoiceAutocompleteField';
|
|
48
37
|
|
|
49
38
|
interface OpenChoiceAutocompleteItemProps
|
|
50
39
|
extends PropsWithQrItemChangeHandler<QuestionnaireResponseItem>,
|
|
@@ -70,10 +59,8 @@ function OpenChoiceAutocompleteItem(props: OpenChoiceAutocompleteItemProps) {
|
|
|
70
59
|
}
|
|
71
60
|
|
|
72
61
|
// Get additional rendering extensions
|
|
73
|
-
const {
|
|
74
|
-
useRenderingExtensions(qItem);
|
|
62
|
+
const { displayInstructions } = useRenderingExtensions(qItem);
|
|
75
63
|
|
|
76
|
-
// Query ontoserver for options
|
|
77
64
|
const maxList = 10;
|
|
78
65
|
|
|
79
66
|
const [input, setInput] = useState('');
|
|
@@ -91,7 +78,7 @@ function OpenChoiceAutocompleteItem(props: OpenChoiceAutocompleteItemProps) {
|
|
|
91
78
|
}
|
|
92
79
|
|
|
93
80
|
// Event handlers
|
|
94
|
-
function handleValueChange(
|
|
81
|
+
function handleValueChange(newValue: Coding | string | null) {
|
|
95
82
|
if (newValue === null) {
|
|
96
83
|
setInput('');
|
|
97
84
|
newValue = '';
|
|
@@ -114,84 +101,31 @@ function OpenChoiceAutocompleteItem(props: OpenChoiceAutocompleteItemProps) {
|
|
|
114
101
|
}
|
|
115
102
|
}
|
|
116
103
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
loading={loading}
|
|
127
|
-
loadingText={'Fetching results...'}
|
|
128
|
-
clearOnEscape
|
|
129
|
-
freeSolo
|
|
130
|
-
autoHighlight
|
|
131
|
-
sx={{ maxWidth: !isTabled ? 280 : 3000, minWidth: 220, flexGrow: 1 }}
|
|
132
|
-
placeholder={entryFormat}
|
|
133
|
-
onChange={handleValueChange}
|
|
134
|
-
filterOptions={(x) => x}
|
|
135
|
-
renderInput={(params) => (
|
|
136
|
-
<StandardTextField
|
|
137
|
-
{...params}
|
|
138
|
-
value={input}
|
|
139
|
-
onBlur={() => {
|
|
140
|
-
// set answer to current input when text field is unfocused
|
|
141
|
-
if (!valueAutocomplete && input !== '') {
|
|
142
|
-
onQrItemChange({
|
|
143
|
-
...createEmptyQrItem(qItem),
|
|
144
|
-
answer: [{ valueString: input }]
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
}}
|
|
148
|
-
onChange={(e: ChangeEvent<HTMLInputElement>) => setInput(e.target.value)}
|
|
149
|
-
isTabled={isTabled}
|
|
150
|
-
label={displayPrompt}
|
|
151
|
-
size="small"
|
|
152
|
-
InputProps={{
|
|
153
|
-
...params.InputProps,
|
|
154
|
-
startAdornment: (
|
|
155
|
-
<>
|
|
156
|
-
{!valueAutocomplete || valueAutocomplete === '' ? (
|
|
157
|
-
<SearchIcon fontSize="small" sx={{ ml: 0.5 }} />
|
|
158
|
-
) : null}
|
|
159
|
-
{params.InputProps.startAdornment}
|
|
160
|
-
</>
|
|
161
|
-
),
|
|
162
|
-
endAdornment: (
|
|
163
|
-
<>
|
|
164
|
-
{loading ? (
|
|
165
|
-
<CircularProgress color="inherit" size={16} />
|
|
166
|
-
) : feedback ? (
|
|
167
|
-
<Fade in={!!feedback} timeout={300}>
|
|
168
|
-
<Tooltip title={feedback.message} arrow sx={{ ml: 1 }}>
|
|
169
|
-
{
|
|
170
|
-
{
|
|
171
|
-
info: <InfoIcon fontSize="small" color="info" />,
|
|
172
|
-
warning: <WarningAmberIcon fontSize="small" color="warning" />,
|
|
173
|
-
success: <DoneIcon fontSize="small" color="success" />,
|
|
174
|
-
error: <ErrorIcon fontSize="small" color="error" />
|
|
175
|
-
}[feedback.color]
|
|
176
|
-
}
|
|
177
|
-
</Tooltip>
|
|
178
|
-
</Fade>
|
|
179
|
-
) : null}
|
|
180
|
-
{params.InputProps.endAdornment}
|
|
181
|
-
{displayUnit}
|
|
182
|
-
</>
|
|
183
|
-
)
|
|
184
|
-
}}
|
|
185
|
-
data-test="q-item-open-choice-autocomplete-field"
|
|
186
|
-
/>
|
|
187
|
-
)}
|
|
188
|
-
/>
|
|
189
|
-
</Box>
|
|
190
|
-
</>
|
|
191
|
-
);
|
|
104
|
+
function handleUnfocus() {
|
|
105
|
+
// set answer to current input when text field is unfocused
|
|
106
|
+
if (!valueAutocomplete && input !== '') {
|
|
107
|
+
onQrItemChange({
|
|
108
|
+
...createEmptyQrItem(qItem),
|
|
109
|
+
answer: [{ valueString: input }]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
192
113
|
|
|
193
114
|
if (isRepeated) {
|
|
194
|
-
return
|
|
115
|
+
return (
|
|
116
|
+
<OpenChoiceAutocompleteField
|
|
117
|
+
qItem={qItem}
|
|
118
|
+
options={options}
|
|
119
|
+
valueAutocomplete={valueAutocomplete}
|
|
120
|
+
input={input}
|
|
121
|
+
loading={loading}
|
|
122
|
+
feedback={feedback ?? null}
|
|
123
|
+
isTabled={isTabled}
|
|
124
|
+
onInputChange={(newValue) => setInput(newValue)}
|
|
125
|
+
onValueChange={handleValueChange}
|
|
126
|
+
onUnfocus={handleUnfocus}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
195
129
|
}
|
|
196
130
|
|
|
197
131
|
return (
|
|
@@ -201,7 +135,18 @@ function OpenChoiceAutocompleteItem(props: OpenChoiceAutocompleteItemProps) {
|
|
|
201
135
|
<LabelWrapper qItem={qItem} />
|
|
202
136
|
</Grid>
|
|
203
137
|
<Grid item xs={7}>
|
|
204
|
-
|
|
138
|
+
<OpenChoiceAutocompleteField
|
|
139
|
+
qItem={qItem}
|
|
140
|
+
options={options}
|
|
141
|
+
valueAutocomplete={valueAutocomplete}
|
|
142
|
+
input={input}
|
|
143
|
+
loading={loading}
|
|
144
|
+
feedback={feedback ?? null}
|
|
145
|
+
isTabled={isTabled}
|
|
146
|
+
onInputChange={(newValue) => setInput(newValue)}
|
|
147
|
+
onValueChange={handleValueChange}
|
|
148
|
+
onUnfocus={handleUnfocus}
|
|
149
|
+
/>
|
|
205
150
|
<DisplayInstructions displayInstructions={displayInstructions} />
|
|
206
151
|
</Grid>
|
|
207
152
|
</Grid>
|