@aehrc/smart-forms-renderer 0.27.0 → 0.27.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.
- package/lib/components/FormComponents/BooleanItem/BooleanField.js +1 -2
- package/lib/components/FormComponents/BooleanItem/BooleanField.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js +1 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.js.map +1 -1
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js +1 -2
- package/lib/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.js.map +1 -1
- package/lib/components/FormComponents/ItemParts/RadioOptionList.d.ts +8 -0
- package/lib/components/FormComponents/ItemParts/RadioOptionList.js +36 -0
- package/lib/components/FormComponents/ItemParts/RadioOptionList.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.d.ts +18 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.js +48 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.d.ts +9 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.js +93 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxFields.d.ts +2 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxFields.js +20 -4
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxFields.js.map +1 -1
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.d.ts +16 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.js +48 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.js.map +1 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetItem.d.ts +9 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetItem.js +95 -0
- package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetItem.js.map +1 -0
- package/lib/hooks/useOpenLabel.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/FormComponents/BooleanItem/BooleanField.tsx +1 -5
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.tsx +1 -5
- package/src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx +1 -5
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import React, { memo } from 'react';
|
|
18
|
-
import { TEXT_FIELD_WIDTH } from '../Textfield.styles';
|
|
19
18
|
import Box from '@mui/material/Box';
|
|
20
19
|
import Button from '@mui/material/Button';
|
|
21
20
|
import { grey } from '@mui/material/colors';
|
|
@@ -32,7 +31,7 @@ const BooleanField = memo(function BooleanField(props) {
|
|
|
32
31
|
// defaults to horizontal, only set to vertical if explicitly set
|
|
33
32
|
const orientation = (_a = getChoiceOrientation(qItem)) !== null && _a !== void 0 ? _a : ChoiceItemOrientation.Horizontal;
|
|
34
33
|
const selection = valueBoolean === undefined ? null : valueBoolean.toString();
|
|
35
|
-
return (React.createElement(Box, { display: "flex", alignItems: "center"
|
|
34
|
+
return (React.createElement(Box, { display: "flex", alignItems: "center" },
|
|
36
35
|
React.createElement(StyledRadioGroup, { row: orientation === ChoiceItemOrientation.Horizontal, name: qItem.text, id: qItem.id, onChange: (e) => onCheckedChange(e.target.value), value: selection },
|
|
37
36
|
React.createElement(ChoiceRadioSingle, { value: "true", label: "Yes", readOnly: readOnly }),
|
|
38
37
|
React.createElement(ChoiceRadioSingle, { value: "false", label: "No", readOnly: readOnly })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanField.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/BooleanItem/BooleanField.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,
|
|
1
|
+
{"version":3,"file":"BooleanField.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/BooleanItem/BooleanField.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,GAAG,MAAM,mBAAmB,CAAC;AACpC,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAW3D,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,YAAY,CAAC,KAAwB;;IACtE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,GACzF,KAAK,CAAC;IAER,iEAAiE;IACjE,MAAM,WAAW,GAAG,MAAA,oBAAoB,CAAC,KAAK,CAAC,mCAAI,qBAAqB,CAAC,UAAU,CAAC;IAEpF,MAAM,SAAS,G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from '../ItemParts/RadioAnswerOptionButtons';
|
|
20
20
|
import { StyledRadioGroup } from '../Item.styles';
|
|
21
21
|
import { getChoiceOrientation } from '../../../utils/choice';
|
|
22
|
-
import { TEXT_FIELD_WIDTH } from '../Textfield.styles';
|
|
23
22
|
import Box from '@mui/material/Box';
|
|
24
23
|
import FadingCheckIcon from '../ItemParts/FadingCheckIcon';
|
|
25
24
|
function ChoiceRadioAnswerOptionFields(props) {
|
|
26
25
|
var _a;
|
|
27
26
|
const { qItem, valueRadio, readOnly, calcExpUpdated, isTabled, onCheckedChange } = props;
|
|
28
27
|
const orientation = (_a = getChoiceOrientation(qItem)) !== null && _a !== void 0 ? _a : ChoiceItemOrientation.Vertical;
|
|
29
|
-
return (React.createElement(Box, { display: "flex", alignItems: "center"
|
|
28
|
+
return (React.createElement(Box, { display: "flex", alignItems: "center" },
|
|
30
29
|
React.createElement(StyledRadioGroup, { row: orientation === ChoiceItemOrientation.Horizontal, name: qItem.text, id: qItem.id, onChange: (e) => onCheckedChange(e.target.value), value: valueRadio, "data-test": "q-item-radio-group" },
|
|
31
30
|
React.createElement(RadioAnswerOptionButtons, { qItem: qItem, readOnly: readOnly })),
|
|
32
31
|
React.createElement(Box, { flexGrow: 1 }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceRadioAnswerOptionFields.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerOptionFields.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,wBAAwB,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ChoiceRadioAnswerOptionFields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AC;AACJ,CAAC;AAED,eAAe,6BAA6B,CAAC"}
|
|
@@ -22,7 +22,6 @@ import { StyledRadioGroup } from '../Item.styles';
|
|
|
22
22
|
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
23
23
|
import { StyledAlert } from '../../Alert.styles';
|
|
24
24
|
import { getChoiceOrientation } from '../../../utils/choice';
|
|
25
|
-
import { TEXT_FIELD_WIDTH } from '../Textfield.styles';
|
|
26
25
|
import FadingCheckIcon from '../ItemParts/FadingCheckIcon';
|
|
27
26
|
import Box from '@mui/material/Box';
|
|
28
27
|
function ChoiceRadioAnswerValueSetFields(props) {
|
|
@@ -30,7 +29,7 @@ function ChoiceRadioAnswerValueSetFields(props) {
|
|
|
30
29
|
const { qItem, codings, valueRadio, readOnly, calcExpUpdated, terminologyError, isTabled, onCheckedChange } = props;
|
|
31
30
|
const orientation = (_a = getChoiceOrientation(qItem)) !== null && _a !== void 0 ? _a : ChoiceItemOrientation.Vertical;
|
|
32
31
|
if (codings.length > 0) {
|
|
33
|
-
return (React.createElement(Box, { display: "flex", alignItems: "center"
|
|
32
|
+
return (React.createElement(Box, { display: "flex", alignItems: "center" },
|
|
34
33
|
React.createElement(StyledRadioGroup, { row: orientation === ChoiceItemOrientation.Horizontal, name: qItem.text, id: qItem.id, onChange: (e) => onCheckedChange(e.target.value), value: valueRadio !== null && valueRadio !== void 0 ? valueRadio : null }, codings.map((coding) => {
|
|
35
34
|
var _a, _b, _c;
|
|
36
35
|
return (React.createElement(ChoiceRadioSingle, { key: (_a = coding.code) !== null && _a !== void 0 ? _a : '', value: (_b = coding.code) !== null && _b !== void 0 ? _b : '', label: (_c = coding.display) !== null && _c !== void 0 ? _c : `${coding.code}`, readOnly: readOnly }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChoiceRadioAnswerValueSetFields.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"ChoiceRadioAnswerValueSetFields.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/ChoiceItems/ChoiceRadioAnswerValueSetFields.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,OAAO,GAAG,MAAM,mBAAmB,CAAC;AAYpC,SAAS,+BAA+B,CAAC,KAA2C;;IAClF,MAAM,EACJ,KAAK,EACL,OAAO,EACP,UAAU,EACV,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,eAAe,EAChB,GAAG,KAAK,CAAC;IAEV,MAAM,WAAW,GAAG,MAAA,oBAAoB,CAAC,K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CACf,CAAC;KACH;IAED,OAAO,CACL,oBAAC,WAAW,IAAC,KAAK,EAAC,OAAO;QACxB,oBAAC,gBAAgB,IAAC,KAAK,EAAC,OAAO,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAI;QACpD,oBAAC,UAAU,IAAC,OAAO,EAAC,WAAW,uEAElB,CACD,CACf,CAAC;AACJ,CAAC;AAED,eAAe,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { QuestionnaireItemAnswerOption } from 'fhir/r4';
|
|
3
|
+
interface RadioOptionListProps {
|
|
4
|
+
options: QuestionnaireItemAnswerOption[];
|
|
5
|
+
readOnly: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare function RadioOptionList(props: RadioOptionListProps): React.JSX.Element;
|
|
8
|
+
export default RadioOptionList;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
import React from 'react';
|
|
18
|
+
import ChoiceRadioSingle from '../ChoiceItems/ChoiceRadioSingle';
|
|
19
|
+
function RadioOptionList(props) {
|
|
20
|
+
const { options, readOnly } = props;
|
|
21
|
+
return (React.createElement(React.Fragment, null, options.map((option) => {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
if (option['valueCoding']) {
|
|
24
|
+
return (React.createElement(ChoiceRadioSingle, { key: (_a = option.valueCoding.code) !== null && _a !== void 0 ? _a : '', value: (_b = option.valueCoding.code) !== null && _b !== void 0 ? _b : '', label: (_c = option.valueCoding.display) !== null && _c !== void 0 ? _c : `${option.valueCoding.code}`, readOnly: readOnly }));
|
|
25
|
+
}
|
|
26
|
+
if (option['valueString']) {
|
|
27
|
+
return (React.createElement(ChoiceRadioSingle, { key: option.valueString, value: option.valueString, label: option.valueString, readOnly: readOnly }));
|
|
28
|
+
}
|
|
29
|
+
if (option['valueInteger']) {
|
|
30
|
+
return (React.createElement(ChoiceRadioSingle, { key: option.valueInteger, value: option.valueInteger.toString(), label: option.valueInteger.toString(), readOnly: readOnly }));
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
})));
|
|
34
|
+
}
|
|
35
|
+
export default RadioOptionList;
|
|
36
|
+
//# sourceMappingURL=RadioOptionList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioOptionList.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/ItemParts/RadioOptionList.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AAQjE,SAAS,eAAe,CAAC,KAA2B;IAClD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAEpC,OAAO,CACL,0CACG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;;QACtB,IAAI,MAAM,CAAC,aAAa,CAAC,EAAE;YACzB,OAAO,CACL,oBAAC,iBAAiB,IAChB,GAAG,EAAE,MAAA,MAAM,CAAC,WAAW,CAAC,IAAI,mCAAI,EAAE,EAClC,KAAK,EAAE,MAAA,MAAM,CAAC,WAAW,CAAC,IAAI,mCAAI,EAAE,EACpC,KAAK,EAAE,MAAA,MAAM,CAAC,WAAW,CAAC,OAAO,mCAAI,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,EACjE,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;SACH;QAED,IAAI,MAAM,CAAC,aAAa,CAAC,EAAE;YACzB,OAAO,CACL,oBAAC,iBAAiB,IAChB,GAAG,EAAE,MAAM,CAAC,WAAW,EACvB,KAAK,EAAE,MAAM,CAAC,WAAW,EACzB,KAAK,EAAE,MAAM,CAAC,WAAW,EACzB,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;SACH;QAED,IAAI,MAAM,CAAC,cAAc,CAAC,EAAE;YAC1B,OAAO,CACL,oBAAC,iBAAiB,IAChB,GAAG,EAAE,MAAM,CAAC,YAAY,EACxB,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,EACrC,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,EACrC,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;SACH;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CACD,CACJ,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC"}
|
package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { QuestionnaireItem, QuestionnaireItemAnswerOption, QuestionnaireResponseItemAnswer } from 'fhir/r4';
|
|
3
|
+
import type { TerminologyError } from '../../../hooks/useValueSetCodings';
|
|
4
|
+
interface OpenChoiceCheckboxFieldsProps {
|
|
5
|
+
qItem: QuestionnaireItem;
|
|
6
|
+
options: QuestionnaireItemAnswerOption[];
|
|
7
|
+
answers: QuestionnaireResponseItemAnswer[];
|
|
8
|
+
openLabelText: string | null;
|
|
9
|
+
openLabelValue: string;
|
|
10
|
+
openLabelChecked: boolean;
|
|
11
|
+
readOnly: boolean;
|
|
12
|
+
terminologyError: TerminologyError;
|
|
13
|
+
onOptionChange: (changedOptionValue: string) => void;
|
|
14
|
+
onOpenLabelCheckedChange: (checked: boolean) => void;
|
|
15
|
+
onOpenLabelInputChange: (input: string) => void;
|
|
16
|
+
}
|
|
17
|
+
declare function OpenChoiceCheckboxAnswerValueSetFields(props: OpenChoiceCheckboxFieldsProps): React.JSX.Element;
|
|
18
|
+
export default OpenChoiceCheckboxAnswerValueSetFields;
|
package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
import React from 'react';
|
|
18
|
+
import { ChoiceItemOrientation } from '../../../interfaces/choice.enum';
|
|
19
|
+
import CheckboxSingleWithOpenLabel from '../ItemParts/CheckboxSingleWithOpenLabel';
|
|
20
|
+
import { getChoiceOrientation } from '../../../utils/choice';
|
|
21
|
+
import { StyledFormGroup } from '../Item.styles';
|
|
22
|
+
import CheckboxOptionList from '../ChoiceItems/CheckboxOptionList';
|
|
23
|
+
import { StyledAlert } from '../../Alert.styles';
|
|
24
|
+
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
25
|
+
import Typography from '@mui/material/Typography';
|
|
26
|
+
function OpenChoiceCheckboxAnswerValueSetFields(props) {
|
|
27
|
+
var _a;
|
|
28
|
+
const { qItem, options, answers, openLabelText, openLabelValue, openLabelChecked, readOnly, terminologyError, onOptionChange, onOpenLabelCheckedChange, onOpenLabelInputChange } = props;
|
|
29
|
+
const orientation = (_a = getChoiceOrientation(qItem)) !== null && _a !== void 0 ? _a : ChoiceItemOrientation.Vertical;
|
|
30
|
+
if (options.length > 0) {
|
|
31
|
+
return (React.createElement(StyledFormGroup, { row: orientation === ChoiceItemOrientation.Horizontal },
|
|
32
|
+
React.createElement(CheckboxOptionList, { options: options, answers: answers, readOnly: readOnly, onCheckedChange: onOptionChange }),
|
|
33
|
+
openLabelText !== null ? (React.createElement(CheckboxSingleWithOpenLabel, { value: openLabelValue, label: openLabelText, isChecked: openLabelChecked, onCheckedChange: onOpenLabelCheckedChange, onInputChange: onOpenLabelInputChange })) : null));
|
|
34
|
+
}
|
|
35
|
+
if (terminologyError.error) {
|
|
36
|
+
return (React.createElement(StyledAlert, { color: "error" },
|
|
37
|
+
React.createElement(ErrorOutlineIcon, { color: "error", sx: { pr: 0.75 } }),
|
|
38
|
+
React.createElement(Typography, { variant: "subtitle2" },
|
|
39
|
+
"There was an error fetching options from the terminology server for",
|
|
40
|
+
' ',
|
|
41
|
+
terminologyError.answerValueSet)));
|
|
42
|
+
}
|
|
43
|
+
return (React.createElement(StyledAlert, { color: "error" },
|
|
44
|
+
React.createElement(ErrorOutlineIcon, { color: "error", sx: { pr: 0.75 } }),
|
|
45
|
+
React.createElement(Typography, { variant: "subtitle2" }, "Unable to fetch options from the questionnaire or launch context")));
|
|
46
|
+
}
|
|
47
|
+
export default OpenChoiceCheckboxAnswerValueSetFields;
|
|
48
|
+
//# sourceMappingURL=OpenChoiceCheckboxAnswerValueSetFields.js.map
|
package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenChoiceCheckboxAnswerValueSetFields.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetFields.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,2BAA2B,MAAM,0CAA0C,CAAC;AAMnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,kBAAkB,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAiBlD,SAAS,sCAAsC,CAAC,KAAoC;;IAClF,MAAM,EACJ,KAAK,EACL,OAAO,EACP,OAAO,EACP,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,wBAAwB,EACxB,sBAAsB,EACvB,GAAG,KAAK,CAAC;IAEV,MAAM,WAAW,GAAG,MAAA,oBAAoB,CAAC,KAAK,CAAC,mCAAI,qBAAqB,CAAC,QAAQ,CAAC;IAElF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,OAAO,CACL,oBAAC,eAAe,IAAC,GAAG,EAAE,WAAW,KAAK,qBAAqB,CAAC,UAAU;YACpE,oBAAC,kBAAkB,IACjB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,cAAc,GAC/B;YAED,aAAa,KAAK,IAAI,CAAC,CAAC,CAAC,CACxB,oBAAC,2BAA2B,IAC1B,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,aAAa,EACpB,SAAS,EAAE,gBAAgB,EAC3B,eAAe,EAAE,wBAAwB,EACzC,aAAa,EAAE,sBAAsB,GACrC,CACH,CAAC,CAAC,CAAC,IAAI,CACQ,CACnB,CAAC;KACH;IAED,IAAI,gBAAgB,CAAC,KAAK,EAAE;QAC1B,OAAO,CACL,oBAAC,WAAW,IAAC,KAAK,EAAC,OAAO;YACxB,oBAAC,gBAAgB,IAAC,KAAK,EAAC,OAAO,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAI;YACpD,oBAAC,UAAU,IAAC,OAAO,EAAC,WAAW;;gBACuC,GAAG;gBACtE,gBAAgB,CAAC,cAAc,CACrB,CACD,CACf,CAAC;KACH;IAED,OAAO,CACL,oBAAC,WAAW,IAAC,KAAK,EAAC,OAAO;QACxB,oBAAC,gBAAgB,IAAC,KAAK,EAAC,OAAO,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAI;QACpD,oBAAC,UAAU,IAAC,OAAO,EAAC,WAAW,uEAElB,CACD,CACf,CAAC;AACJ,CAAC;AAED,eAAe,sCAAsC,CAAC"}
|
package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
3
|
+
import type { PropsWithIsRepeatedAttribute, PropsWithParentIsReadOnlyAttribute, PropsWithQrItemChangeHandler, PropsWithShowMinimalViewAttribute } from '../../../interfaces/renderProps.interface';
|
|
4
|
+
interface OpenChoiceCheckboxAnswerValueSetItemProps extends PropsWithQrItemChangeHandler, PropsWithIsRepeatedAttribute, PropsWithShowMinimalViewAttribute, PropsWithParentIsReadOnlyAttribute {
|
|
5
|
+
qItem: QuestionnaireItem;
|
|
6
|
+
qrItem: QuestionnaireResponseItem | null;
|
|
7
|
+
}
|
|
8
|
+
declare function OpenChoiceCheckboxAnswerValueSetItem(props: OpenChoiceCheckboxAnswerValueSetItemProps): React.JSX.Element;
|
|
9
|
+
export default OpenChoiceCheckboxAnswerValueSetItem;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
import React, { useCallback, useMemo } from 'react';
|
|
18
|
+
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
19
|
+
import { getOpenLabelText } from '../../../utils/itemControl';
|
|
20
|
+
import { updateOpenLabelAnswer } from '../../../utils/openChoice';
|
|
21
|
+
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
22
|
+
import debounce from 'lodash.debounce';
|
|
23
|
+
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
24
|
+
import { DEBOUNCE_DURATION } from '../../../utils/debounce';
|
|
25
|
+
import DisplayInstructions from '../DisplayItem/DisplayInstructions';
|
|
26
|
+
import OpenChoiceCheckboxAnswerValueSetFields from './OpenChoiceCheckboxAnswerValueSetFields';
|
|
27
|
+
import useReadOnly from '../../../hooks/useReadOnly';
|
|
28
|
+
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
29
|
+
import { useQuestionnaireStore } from '../../../stores';
|
|
30
|
+
import useOpenLabel from '../../../hooks/useOpenLabel';
|
|
31
|
+
import { convertCodingsToAnswerOptions, updateChoiceCheckboxAnswers } from '../../../utils/choice';
|
|
32
|
+
import useValueSetCodings from '../../../hooks/useValueSetCodings';
|
|
33
|
+
function OpenChoiceCheckboxAnswerValueSetItem(props) {
|
|
34
|
+
var _a;
|
|
35
|
+
const { qItem, qrItem, isRepeated, showMinimalView = false, parentIsReadOnly, onQrItemChange } = props;
|
|
36
|
+
const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();
|
|
37
|
+
// Init input value
|
|
38
|
+
const qrOpenChoiceCheckbox = qrItem !== null && qrItem !== void 0 ? qrItem : createEmptyQrItem(qItem);
|
|
39
|
+
const answers = (_a = qrOpenChoiceCheckbox.answer) !== null && _a !== void 0 ? _a : [];
|
|
40
|
+
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
41
|
+
const { displayInstructions } = useRenderingExtensions(qItem);
|
|
42
|
+
const openLabelText = getOpenLabelText(qItem);
|
|
43
|
+
// Get codings/options from valueSet
|
|
44
|
+
const { codings, terminologyError } = useValueSetCodings(qItem);
|
|
45
|
+
const options = useMemo(() => convertCodingsToAnswerOptions(codings), [codings]);
|
|
46
|
+
const { openLabelValue, setOpenLabelValue, openLabelChecked, setOpenLabelChecked } = useOpenLabel(options, answers);
|
|
47
|
+
// Event handlers
|
|
48
|
+
// One of the options is changed
|
|
49
|
+
// Processing is similar to a choice checkbox
|
|
50
|
+
function handleOptionChange(changedOptionValue) {
|
|
51
|
+
if (options.length === 0) {
|
|
52
|
+
onQrItemChange(createEmptyQrItem(qItem));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// Process as a choice checkbox
|
|
56
|
+
const updatedQrItem = updateChoiceCheckboxAnswers(changedOptionValue, answers, options, qrOpenChoiceCheckbox, isRepeated);
|
|
57
|
+
if (updatedQrItem) {
|
|
58
|
+
onQrItemChange(updatedQrItem);
|
|
59
|
+
}
|
|
60
|
+
// If single-selection, uncheck open label
|
|
61
|
+
if (!isRepeated) {
|
|
62
|
+
setOpenLabelChecked(false);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function handleOpenLabelChange(openLabelChecked, changedOpenLabelValue) {
|
|
66
|
+
const updatedQrItem = updateOpenLabelAnswer(openLabelChecked, changedOpenLabelValue, answers, options, qrOpenChoiceCheckbox, isRepeated);
|
|
67
|
+
if (updatedQrItem) {
|
|
68
|
+
onQrItemChange(updatedQrItem);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function handleOpenLabelCheckedChange(checked) {
|
|
72
|
+
handleOpenLabelChange(checked, openLabelValue);
|
|
73
|
+
setOpenLabelChecked(checked);
|
|
74
|
+
}
|
|
75
|
+
function handleOpenLabelInputChange(newValue) {
|
|
76
|
+
updateOpenLabelValueWithDebounce(newValue);
|
|
77
|
+
setOpenLabelValue(newValue);
|
|
78
|
+
}
|
|
79
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
+
const updateOpenLabelValueWithDebounce = useCallback(debounce((input) => {
|
|
81
|
+
handleOpenLabelChange(openLabelChecked, input);
|
|
82
|
+
}, DEBOUNCE_DURATION), [handleOpenLabelChange]); // Dependencies are tested, debounce is causing eslint to not recognise dependencies
|
|
83
|
+
if (showMinimalView) {
|
|
84
|
+
return (React.createElement(React.Fragment, null,
|
|
85
|
+
React.createElement(OpenChoiceCheckboxAnswerValueSetFields, { qItem: qItem, options: options, answers: answers, openLabelText: openLabelText, openLabelValue: openLabelValue, openLabelChecked: openLabelChecked, readOnly: readOnly, terminologyError: terminologyError, onOptionChange: handleOptionChange, onOpenLabelCheckedChange: handleOpenLabelCheckedChange, onOpenLabelInputChange: handleOpenLabelInputChange }),
|
|
86
|
+
React.createElement(DisplayInstructions, { displayInstructions: displayInstructions, readOnly: readOnly })));
|
|
87
|
+
}
|
|
88
|
+
return (React.createElement(FullWidthFormComponentBox, { "data-test": "q-item-open-choice-checkbox-answer-option-box", "data-linkid": qItem.linkId, onClick: () => onFocusLinkId(qItem.linkId) },
|
|
89
|
+
React.createElement(ItemFieldGrid, { qItem: qItem, readOnly: readOnly },
|
|
90
|
+
React.createElement(OpenChoiceCheckboxAnswerValueSetFields, { qItem: qItem, options: options, answers: answers, openLabelText: openLabelText, openLabelValue: openLabelValue, openLabelChecked: openLabelChecked, readOnly: readOnly, terminologyError: terminologyError, onOptionChange: handleOptionChange, onOpenLabelCheckedChange: handleOpenLabelCheckedChange, onOpenLabelInputChange: handleOpenLabelInputChange }))));
|
|
91
|
+
}
|
|
92
|
+
export default OpenChoiceCheckboxAnswerValueSetItem;
|
|
93
|
+
//# sourceMappingURL=OpenChoiceCheckboxAnswerValueSetItem.js.map
|
package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenChoiceCheckboxAnswerValueSetItem.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxAnswerValueSetItem.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,sBAAsB,MAAM,uCAAuC,CAAC;AAO3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,mBAAmB,MAAM,oCAAoC,CAAC;AACrE,OAAO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AC,oFAAoF;IAEvF,IAAI,eAAe,EAAE;QACnB,OAAO,CACL;YACE,oBAAC,sCAAsC,IACrC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,kBAAkB,EAClC,wBAAwB,EAAE,4BAA4B,EACtD,sBAAsB,EAAE,0BAA0B,GAClD;YACF,oBAAC,mBAAmB,IAAC,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,QAAQ,GAAI,CACpF,CACJ,CAAC;KACH;IAED,OAAO,CACL,oBAAC,yBAAyB,iBACd,+CAA+C,iBAC5C,KAAK,CAAC,MAAM,EACzB,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;QAC1C,oBAAC,aAAa,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ;YAC7C,oBAAC,sCAAsC,IACrC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,kBAAkB,EAClC,wBAAwB,EAAE,4BAA4B,EACtD,sBAAsB,EAAE,0BAA0B,GAClD,CACY,CACU,CAC7B,CAAC;AACJ,CAAC;AAED,eAAe,oCAAoC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { QuestionnaireItem, QuestionnaireItemAnswerOption, QuestionnaireResponseItemAnswer } from 'fhir/r4';
|
|
3
|
+
import { TerminologyError } from '../../../hooks/useValueSetCodings';
|
|
3
4
|
interface OpenChoiceCheckboxFieldsProps {
|
|
4
5
|
qItem: QuestionnaireItem;
|
|
5
6
|
options: QuestionnaireItemAnswerOption[];
|
|
@@ -8,6 +9,7 @@ interface OpenChoiceCheckboxFieldsProps {
|
|
|
8
9
|
openLabelValue: string;
|
|
9
10
|
openLabelChecked: boolean;
|
|
10
11
|
readOnly: boolean;
|
|
12
|
+
terminologyError: TerminologyError;
|
|
11
13
|
onOptionChange: (changedOptionValue: string) => void;
|
|
12
14
|
onOpenLabelCheckedChange: (checked: boolean) => void;
|
|
13
15
|
onOpenLabelInputChange: (input: string) => void;
|
|
@@ -20,13 +20,29 @@ import CheckboxSingleWithOpenLabel from '../ItemParts/CheckboxSingleWithOpenLabe
|
|
|
20
20
|
import { getChoiceOrientation } from '../../../utils/choice';
|
|
21
21
|
import { StyledFormGroup } from '../Item.styles';
|
|
22
22
|
import CheckboxOptionList from '../ChoiceItems/CheckboxOptionList';
|
|
23
|
+
import { StyledAlert } from '../../Alert.styles';
|
|
24
|
+
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
25
|
+
import Typography from '@mui/material/Typography';
|
|
23
26
|
function OpenChoiceCheckboxFields(props) {
|
|
24
27
|
var _a;
|
|
25
|
-
const { qItem, options, answers, openLabelText, openLabelValue, openLabelChecked, readOnly, onOptionChange, onOpenLabelCheckedChange, onOpenLabelInputChange } = props;
|
|
28
|
+
const { qItem, options, answers, openLabelText, openLabelValue, openLabelChecked, readOnly, terminologyError, onOptionChange, onOpenLabelCheckedChange, onOpenLabelInputChange } = props;
|
|
26
29
|
const orientation = (_a = getChoiceOrientation(qItem)) !== null && _a !== void 0 ? _a : ChoiceItemOrientation.Vertical;
|
|
27
|
-
|
|
28
|
-
React.createElement(
|
|
29
|
-
|
|
30
|
+
if (options.length > 0) {
|
|
31
|
+
return (React.createElement(StyledFormGroup, { row: orientation === ChoiceItemOrientation.Horizontal },
|
|
32
|
+
React.createElement(CheckboxOptionList, { options: options, answers: answers, readOnly: readOnly, onCheckedChange: onOptionChange }),
|
|
33
|
+
openLabelText !== null ? (React.createElement(CheckboxSingleWithOpenLabel, { value: openLabelValue, label: openLabelText, isChecked: openLabelChecked, onCheckedChange: onOpenLabelCheckedChange, onInputChange: onOpenLabelInputChange })) : null));
|
|
34
|
+
}
|
|
35
|
+
if (terminologyError.error) {
|
|
36
|
+
return (React.createElement(StyledAlert, { color: "error" },
|
|
37
|
+
React.createElement(ErrorOutlineIcon, { color: "error", sx: { pr: 0.75 } }),
|
|
38
|
+
React.createElement(Typography, { variant: "subtitle2" },
|
|
39
|
+
"There was an error fetching options from the terminology server for",
|
|
40
|
+
' ',
|
|
41
|
+
terminologyError.answerValueSet)));
|
|
42
|
+
}
|
|
43
|
+
return (React.createElement(StyledAlert, { color: "error" },
|
|
44
|
+
React.createElement(ErrorOutlineIcon, { color: "error", sx: { pr: 0.75 } }),
|
|
45
|
+
React.createElement(Typography, { variant: "subtitle2" }, "Unable to fetch options from the questionnaire or launch context")));
|
|
30
46
|
}
|
|
31
47
|
export default OpenChoiceCheckboxFields;
|
|
32
48
|
//# sourceMappingURL=OpenChoiceCheckboxFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenChoiceCheckboxFields.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/OpenChoiceItems/OpenChoiceCheckboxFields.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,2BAA2B,MAAM,0CAA0C,CAAC;AAMnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,kBAAkB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"OpenChoiceCheckboxFields.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E,wBAAwB,EACzC,aAAa,EAAE,sBAAsB,GACrC,CACH,CAAC,CAAC,CAAC,IAAI,CACQ,CACnB,CAAC;KACH;IAED,IAAI,gBAAgB,CAAC,KAAK,EAAE;QAC1B,OAAO,CACL,oBAAC,WAAW,IAAC,KAAK,EAAC,OAAO;YACxB,oBAAC,gBAAgB,IAAC,KAAK,EAAC,OAAO,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAI;YACpD,oBAAC,UAAU,IAAC,OAAO,EAAC,WAAW;;gBACuC,GAAG;gBACtE,gBAAgB,CAAC,cAAc,CACrB,CACD,CACf,CAAC;KACH;IAED,OAAO,CACL,oBAAC,WAAW,IAAC,KAAK,EAAC,OAAO;QACxB,oBAAC,gBAAgB,IAAC,KAAK,EAAC,OAAO,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAI;QACpD,oBAAC,UAAU,IAAC,OAAO,EAAC,WAAW,uEAElB,CACD,CACf,CAAC;AACJ,CAAC;AAED,eAAe,wBAAwB,CAAC"}
|
package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { QuestionnaireItem, QuestionnaireItemAnswerOption } from 'fhir/r4';
|
|
3
|
+
import type { TerminologyError } from '../../../hooks/useValueSetCodings';
|
|
4
|
+
interface OpenChoiceRadioAnswerValueSetFieldsProps {
|
|
5
|
+
qItem: QuestionnaireItem;
|
|
6
|
+
options: QuestionnaireItemAnswerOption[];
|
|
7
|
+
valueRadio: string | null;
|
|
8
|
+
openLabelText: string | null;
|
|
9
|
+
openLabelValue: string | null;
|
|
10
|
+
openLabelSelected: boolean;
|
|
11
|
+
readOnly: boolean;
|
|
12
|
+
terminologyError: TerminologyError;
|
|
13
|
+
onValueChange: (changedOptionValue: string | null, changedOpenLabelValue: string | null) => void;
|
|
14
|
+
}
|
|
15
|
+
declare function OpenChoiceRadioAnswerValueSetFields(props: OpenChoiceRadioAnswerValueSetFieldsProps): React.JSX.Element;
|
|
16
|
+
export default OpenChoiceRadioAnswerValueSetFields;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
import React from 'react';
|
|
18
|
+
import { ChoiceItemOrientation } from '../../../interfaces/choice.enum';
|
|
19
|
+
import { StyledRadioGroup } from '../Item.styles';
|
|
20
|
+
import RadioButtonWithOpenLabel from '../ItemParts/RadioButtonWithOpenLabel';
|
|
21
|
+
import RadioOptionList from '../ItemParts/RadioOptionList';
|
|
22
|
+
import { getChoiceOrientation } from '../../../utils/choice';
|
|
23
|
+
import { StyledAlert } from '../../Alert.styles';
|
|
24
|
+
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
25
|
+
import Typography from '@mui/material/Typography';
|
|
26
|
+
function OpenChoiceRadioAnswerValueSetFields(props) {
|
|
27
|
+
var _a;
|
|
28
|
+
const { qItem, options, valueRadio, openLabelText, openLabelValue, openLabelSelected, readOnly, terminologyError, onValueChange } = props;
|
|
29
|
+
const orientation = (_a = getChoiceOrientation(qItem)) !== null && _a !== void 0 ? _a : ChoiceItemOrientation.Vertical;
|
|
30
|
+
if (options.length > 0) {
|
|
31
|
+
return (React.createElement(StyledRadioGroup, { row: orientation === ChoiceItemOrientation.Horizontal, name: qItem.text, id: qItem.id, onChange: (e) => onValueChange(e.target.value, null), value: valueRadio, "data-test": "q-item-radio-group" },
|
|
32
|
+
React.createElement(RadioOptionList, { options: options, readOnly: readOnly }),
|
|
33
|
+
openLabelText ? (React.createElement(RadioButtonWithOpenLabel, { value: openLabelValue, label: openLabelText, readOnly: readOnly, isSelected: openLabelSelected, onInputChange: (input) => onValueChange(null, input) })) : null));
|
|
34
|
+
}
|
|
35
|
+
if (terminologyError.error) {
|
|
36
|
+
return (React.createElement(StyledAlert, { color: "error" },
|
|
37
|
+
React.createElement(ErrorOutlineIcon, { color: "error", sx: { pr: 0.75 } }),
|
|
38
|
+
React.createElement(Typography, { variant: "subtitle2" },
|
|
39
|
+
"There was an error fetching options from the terminology server for",
|
|
40
|
+
' ',
|
|
41
|
+
terminologyError.answerValueSet)));
|
|
42
|
+
}
|
|
43
|
+
return (React.createElement(StyledAlert, { color: "error" },
|
|
44
|
+
React.createElement(ErrorOutlineIcon, { color: "error", sx: { pr: 0.75 } }),
|
|
45
|
+
React.createElement(Typography, { variant: "subtitle2" }, "Unable to fetch options from the questionnaire or launch context")));
|
|
46
|
+
}
|
|
47
|
+
export default OpenChoiceRadioAnswerValueSetFields;
|
|
48
|
+
//# sourceMappingURL=OpenChoiceRadioAnswerValueSetFields.js.map
|
package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenChoiceRadioAnswerValueSetFields.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetFields.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM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aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,GACpD,CACH,CAAC,CAAC,CAAC,IAAI,CACS,CACpB,CAAC;KACH;IAED,IAAI,gBAAgB,CAAC,KAAK,EAAE;QAC1B,OAAO,CACL,oBAAC,WAAW,IAAC,KAAK,EAAC,OAAO;YACxB,oBAAC,gBAAgB,IAAC,KAAK,EAAC,OAAO,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAI;YACpD,oBAAC,UAAU,IAAC,OAAO,EAAC,WAAW;;gBACuC,GAAG;gBACtE,gBAAgB,CAAC,cAAc,CACrB,CACD,CACf,CAAC;KACH;IAED,OAAO,CACL,oBAAC,WAAW,IAAC,KAAK,EAAC,OAAO;QACxB,oBAAC,gBAAgB,IAAC,KAAK,EAAC,OAAO,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAI;QACpD,oBAAC,UAAU,IAAC,OAAO,EAAC,WAAW,uEAElB,CACD,CACf,CAAC;AACJ,CAAC;AAED,eAAe,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
3
|
+
import type { PropsWithIsRepeatedAttribute, PropsWithParentIsReadOnlyAttribute, PropsWithQrItemChangeHandler } from '../../../interfaces/renderProps.interface';
|
|
4
|
+
interface OpenChoiceRadioAnswerValueSetItemProps extends PropsWithQrItemChangeHandler, PropsWithIsRepeatedAttribute, PropsWithParentIsReadOnlyAttribute {
|
|
5
|
+
qItem: QuestionnaireItem;
|
|
6
|
+
qrItem: QuestionnaireResponseItem | null;
|
|
7
|
+
}
|
|
8
|
+
declare function OpenChoiceRadioAnswerValueSetItem(props: OpenChoiceRadioAnswerValueSetItemProps): React.JSX.Element;
|
|
9
|
+
export default OpenChoiceRadioAnswerValueSetItem;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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
|
+
import React, { useMemo, useState } from 'react';
|
|
18
|
+
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
19
|
+
import { getOpenLabelText } from '../../../utils/itemControl';
|
|
20
|
+
import { getOldOpenLabelAnswer } from '../../../utils/openChoice';
|
|
21
|
+
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
22
|
+
import { convertCodingsToAnswerOptions, findInAnswerOptions, getQrChoiceValue } from '../../../utils/choice';
|
|
23
|
+
import OpenChoiceRadioAnswerValueSetFields from './OpenChoiceRadioAnswerValueSetFields';
|
|
24
|
+
import useReadOnly from '../../../hooks/useReadOnly';
|
|
25
|
+
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
26
|
+
import { useQuestionnaireStore } from '../../../stores';
|
|
27
|
+
import useValueSetCodings from '../../../hooks/useValueSetCodings';
|
|
28
|
+
function OpenChoiceRadioAnswerValueSetItem(props) {
|
|
29
|
+
var _a;
|
|
30
|
+
const { qItem, qrItem, parentIsReadOnly, onQrItemChange } = props;
|
|
31
|
+
const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();
|
|
32
|
+
// Init answers
|
|
33
|
+
const qrOpenChoiceRadio = qrItem !== null && qrItem !== void 0 ? qrItem : createEmptyQrItem(qItem);
|
|
34
|
+
let valueRadio = getQrChoiceValue(qrOpenChoiceRadio, true);
|
|
35
|
+
const answers = (_a = qrOpenChoiceRadio.answer) !== null && _a !== void 0 ? _a : [];
|
|
36
|
+
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
37
|
+
const openLabelText = getOpenLabelText(qItem);
|
|
38
|
+
// Get codings/options from valueSet
|
|
39
|
+
const { codings, terminologyError } = useValueSetCodings(qItem);
|
|
40
|
+
const options = useMemo(() => convertCodingsToAnswerOptions(codings), [codings]);
|
|
41
|
+
// Init empty open label
|
|
42
|
+
let initialOpenLabelValue = '';
|
|
43
|
+
let initialOpenLabelSelected = false;
|
|
44
|
+
if (options) {
|
|
45
|
+
const oldLabelAnswer = getOldOpenLabelAnswer(answers, options);
|
|
46
|
+
if (oldLabelAnswer && oldLabelAnswer.valueString) {
|
|
47
|
+
initialOpenLabelValue = oldLabelAnswer.valueString;
|
|
48
|
+
initialOpenLabelSelected = true;
|
|
49
|
+
valueRadio = initialOpenLabelValue;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const [openLabelValue, setOpenLabelValue] = useState(initialOpenLabelValue);
|
|
53
|
+
const [openLabelSelected, setOpenLabelSelected] = useState(initialOpenLabelSelected);
|
|
54
|
+
// Allow open label to remain selected even if its input was cleared
|
|
55
|
+
if (openLabelSelected && valueRadio === null) {
|
|
56
|
+
valueRadio = '';
|
|
57
|
+
}
|
|
58
|
+
// Event handlers
|
|
59
|
+
function handleValueChange(changedOptionValue, changedOpenLabelValue) {
|
|
60
|
+
if (options.length === 0) {
|
|
61
|
+
onQrItemChange(createEmptyQrItem(qItem));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (changedOptionValue !== null) {
|
|
65
|
+
const qrAnswer = findInAnswerOptions(options, changedOptionValue);
|
|
66
|
+
// If selected answer can be found in options, it is a non-open label selection
|
|
67
|
+
if (qrAnswer) {
|
|
68
|
+
onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [qrAnswer] }));
|
|
69
|
+
setOpenLabelSelected(false);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// Otherwise, it is an open-label selection
|
|
73
|
+
onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueString: changedOptionValue }] }));
|
|
74
|
+
setOpenLabelValue(changedOptionValue);
|
|
75
|
+
setOpenLabelSelected(true);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (changedOpenLabelValue !== null) {
|
|
79
|
+
setOpenLabelValue(changedOpenLabelValue);
|
|
80
|
+
// If open label is unchecked, remove it from answers
|
|
81
|
+
if (changedOpenLabelValue === '') {
|
|
82
|
+
onQrItemChange(createEmptyQrItem(qItem));
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Otherwise, add open label to answers
|
|
86
|
+
setOpenLabelValue(changedOpenLabelValue);
|
|
87
|
+
onQrItemChange(Object.assign(Object.assign({}, createEmptyQrItem(qItem)), { answer: [{ valueString: changedOpenLabelValue }] }));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return (React.createElement(FullWidthFormComponentBox, { "data-test": "q-item-open-choice-radio-answer-option-box", "data-linkid": qItem.linkId, onClick: () => onFocusLinkId(qItem.linkId) },
|
|
91
|
+
React.createElement(ItemFieldGrid, { qItem: qItem, readOnly: readOnly },
|
|
92
|
+
React.createElement(OpenChoiceRadioAnswerValueSetFields, { qItem: qItem, options: options, valueRadio: valueRadio, openLabelText: openLabelText, openLabelValue: openLabelValue, openLabelSelected: openLabelSelected, readOnly: readOnly, terminologyError: terminologyError, onValueChange: handleValueChange }))));
|
|
93
|
+
}
|
|
94
|
+
export default OpenChoiceRadioAnswerValueSetItem;
|
|
95
|
+
//# sourceMappingURL=OpenChoiceRadioAnswerValueSetItem.js.map
|
package/lib/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetItem.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenChoiceRadioAnswerValueSetItem.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/OpenChoiceItems/OpenChoiceRadioAnswerValueSetItem.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAM/B,OAAO,mCAAmC,MAAM,uCAAuC,CAAC;AACxF,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,kBAAkB,MAAM,mCAAmC,CAAC;AAUnE,SAAS,iCAAiC,CAAC,KAA6C;;IACtF,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAElE,MAAM,aAAa,GAAG,qBAAqB,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IAEhE,eAAe;IACf,MAAM,iBAAiB,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,UAAU,GAAkB,gBAAgB,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAC1E,MAAM,OAAO,GAAG,MAAA,iBAAiB,CAAC,MAAM,mCAAI,EAAE,CAAC;IAE/C,MAAM,QAAQ,GA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ACpC,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,iBAAiB,GAChC,CACY,CACU,CAC7B,CAAC;AACJ,CAAC;AAED,eAAe,iCAAiC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { QuestionnaireItemAnswerOption, QuestionnaireResponseItemAnswer } from 'fhir/r4';
|
|
2
3
|
declare function useOpenLabel(options: QuestionnaireItemAnswerOption[], answers: QuestionnaireResponseItemAnswer[]): {
|
|
3
4
|
openLabelValue: string;
|
package/package.json
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
|
|
18
18
|
import React, { memo } from 'react';
|
|
19
19
|
import type { PropsWithIsTabledAttribute } from '../../../interfaces/renderProps.interface';
|
|
20
|
-
import { TEXT_FIELD_WIDTH } from '../Textfield.styles';
|
|
21
20
|
import Box from '@mui/material/Box';
|
|
22
21
|
import Button from '@mui/material/Button';
|
|
23
22
|
import { grey } from '@mui/material/colors';
|
|
@@ -49,10 +48,7 @@ const BooleanField = memo(function BooleanField(props: BooleanFieldProps) {
|
|
|
49
48
|
const selection = valueBoolean === undefined ? null : valueBoolean.toString();
|
|
50
49
|
|
|
51
50
|
return (
|
|
52
|
-
<Box
|
|
53
|
-
display="flex"
|
|
54
|
-
alignItems="center"
|
|
55
|
-
sx={{ maxWidth: !isTabled ? TEXT_FIELD_WIDTH : 3000, minWidth: 160 }}>
|
|
51
|
+
<Box display="flex" alignItems="center">
|
|
56
52
|
<StyledRadioGroup
|
|
57
53
|
row={orientation === ChoiceItemOrientation.Horizontal}
|
|
58
54
|
name={qItem.text}
|
|
@@ -21,7 +21,6 @@ import type { QuestionnaireItem } from 'fhir/r4';
|
|
|
21
21
|
import RadioAnswerOptionButtons from '../ItemParts/RadioAnswerOptionButtons';
|
|
22
22
|
import { StyledRadioGroup } from '../Item.styles';
|
|
23
23
|
import { getChoiceOrientation } from '../../../utils/choice';
|
|
24
|
-
import { TEXT_FIELD_WIDTH } from '../Textfield.styles';
|
|
25
24
|
import type { PropsWithIsTabledAttribute } from '../../../interfaces/renderProps.interface';
|
|
26
25
|
import Box from '@mui/material/Box';
|
|
27
26
|
import FadingCheckIcon from '../ItemParts/FadingCheckIcon';
|
|
@@ -40,10 +39,7 @@ function ChoiceRadioAnswerOptionFields(props: ChoiceRadioAnswerOptionFieldsProps
|
|
|
40
39
|
const orientation = getChoiceOrientation(qItem) ?? ChoiceItemOrientation.Vertical;
|
|
41
40
|
|
|
42
41
|
return (
|
|
43
|
-
<Box
|
|
44
|
-
display="flex"
|
|
45
|
-
alignItems="center"
|
|
46
|
-
sx={{ maxWidth: !isTabled ? TEXT_FIELD_WIDTH : 3000, minWidth: 160 }}>
|
|
42
|
+
<Box display="flex" alignItems="center">
|
|
47
43
|
<StyledRadioGroup
|
|
48
44
|
row={orientation === ChoiceItemOrientation.Horizontal}
|
|
49
45
|
name={qItem.text}
|
|
@@ -25,7 +25,6 @@ import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
|
25
25
|
import { StyledAlert } from '../../Alert.styles';
|
|
26
26
|
import type { TerminologyError } from '../../../hooks/useValueSetCodings';
|
|
27
27
|
import { getChoiceOrientation } from '../../../utils/choice';
|
|
28
|
-
import { TEXT_FIELD_WIDTH } from '../Textfield.styles';
|
|
29
28
|
import FadingCheckIcon from '../ItemParts/FadingCheckIcon';
|
|
30
29
|
import type { PropsWithIsTabledAttribute } from '../../../interfaces/renderProps.interface';
|
|
31
30
|
import Box from '@mui/material/Box';
|
|
@@ -56,10 +55,7 @@ function ChoiceRadioAnswerValueSetFields(props: ChoiceRadioAnswerValueSetFieldsP
|
|
|
56
55
|
|
|
57
56
|
if (codings.length > 0) {
|
|
58
57
|
return (
|
|
59
|
-
<Box
|
|
60
|
-
display="flex"
|
|
61
|
-
alignItems="center"
|
|
62
|
-
sx={{ maxWidth: !isTabled ? TEXT_FIELD_WIDTH : 3000, minWidth: 160 }}>
|
|
58
|
+
<Box display="flex" alignItems="center">
|
|
63
59
|
<StyledRadioGroup
|
|
64
60
|
row={orientation === ChoiceItemOrientation.Horizontal}
|
|
65
61
|
name={qItem.text}
|