@aehrc/smart-forms-renderer 0.29.0 → 0.30.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/DateTimeItems/CustomDateItem/CustomDateItem.js +2 -1
- package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.js.map +1 -1
- package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js +4 -3
- package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +3 -2
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js +3 -2
- package/lib/components/FormComponents/RepeatItem/RepeatItem.js.map +1 -1
- package/lib/components/FormComponents/UrlItem/UrlItem.js +3 -2
- package/lib/components/FormComponents/UrlItem/UrlItem.js.map +1 -1
- package/lib/hooks/useInitialiseRepeatAnswers.js +2 -2
- package/lib/hooks/useInitialiseRepeatAnswers.js.map +1 -1
- package/lib/hooks/useInitialiseRepeatGroups.d.ts +1 -2
- package/lib/hooks/useInitialiseRepeatGroups.js +2 -2
- package/lib/hooks/useInitialiseRepeatGroups.js.map +1 -1
- package/lib/hooks/useRepeatAnswers.d.ts +4 -0
- package/lib/hooks/useRepeatAnswers.js +34 -0
- package/lib/hooks/useRepeatAnswers.js.map +1 -0
- package/lib/hooks/useRepeatGroups.d.ts +4 -0
- package/lib/hooks/useRepeatGroups.js +34 -0
- package/lib/hooks/useRepeatGroups.js.map +1 -0
- package/lib/hooks/useRepeatitemState.d.ts +0 -0
- package/lib/hooks/useRepeatitemState.js +2 -0
- package/lib/hooks/useRepeatitemState.js.map +1 -0
- package/package.json +1 -1
- package/src/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.tsx +2 -1
- package/src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.tsx +4 -3
- package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +3 -2
- package/src/components/FormComponents/RepeatItem/RepeatItem.tsx +3 -2
- package/src/components/FormComponents/UrlItem/UrlItem.tsx +3 -2
- package/src/hooks/useInitialiseRepeatAnswers.ts +2 -2
- package/src/hooks/useInitialiseRepeatGroups.ts +3 -4
- package/src/hooks/useRepeatAnswers.ts +45 -0
- package/src/hooks/useRepeatGroups.ts +47 -0
- package/src/stories/BuildFormButtonForStorybook.tsx +41 -0
- package/src/stories/BuildFormButtonTesterWrapper.tsx +61 -0
- package/src/stories/assets/questionnaires/QBuildFormButtonTester.ts +270 -0
- package/src/stories/rebuildForm/BuildFormTesterWrapper.stories.tsx +43 -0
- package/vite.config.ts +3 -1
|
@@ -24,6 +24,7 @@ import { createEmptyQrItem } from '../../../../utils/qrItem';
|
|
|
24
24
|
import useDateValidation from '../../../../hooks/useDateValidation';
|
|
25
25
|
import CustomDateField from './CustomDateField';
|
|
26
26
|
import { useQuestionnaireStore } from '../../../../stores';
|
|
27
|
+
import useStringInput from '../../../../hooks/useStringInput';
|
|
27
28
|
function CustomDateItem(props) {
|
|
28
29
|
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
29
30
|
const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();
|
|
@@ -41,7 +42,7 @@ function CustomDateItem(props) {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
const { displayDate, dateParseFail } = parseFhirDateToDisplayDate(valueDate);
|
|
44
|
-
const [input, setInput] =
|
|
45
|
+
const [input, setInput] = useStringInput(displayDate);
|
|
45
46
|
const [focused, setFocused] = useState(false);
|
|
46
47
|
// Perform validation checks
|
|
47
48
|
const errorFeedback = useDateValidation(input, dateParseFail);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomDateItem.js","sourceRoot":"","sources":["../../../../../src/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQxC,OAAO,WAAW,MAAM,+BAA+B,CAAC;AACxD,OAAO,sBAAsB,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,qCAAqC,CAAC;AACpE,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomDateItem.js","sourceRoot":"","sources":["../../../../../src/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQxC,OAAO,WAAW,MAAM,+BAA+B,CAAC;AACxD,OAAO,sBAAsB,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,qCAAqC,CAAC;AACpE,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,cAAc,MAA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,EAAE,KAAK,CAAC,MAAM,EACpB,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,EAC7B,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,iBAAiB,EAChC,YAAY,EAAE,gBAAgB,GAC9B,CACY,CACU,CAC7B,CAAC;AACJ,CAAC;AAED,eAAe,cAAc,CAAC"}
|
package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js
CHANGED
|
@@ -30,6 +30,7 @@ import { parseDateTimeToDisplayTime, parseInputDateTimeToFhirDateTime, validateT
|
|
|
30
30
|
import useTimeValidation from '../../../../hooks/useTimeValidation';
|
|
31
31
|
import useDateNonEmptyValidation from '../../../../hooks/useDateTimeNonEmpty';
|
|
32
32
|
import DateTimeField from './DateTimeField';
|
|
33
|
+
import useStringInput from '../../../../hooks/useStringInput';
|
|
33
34
|
function CustomDateTimeItem(props) {
|
|
34
35
|
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
35
36
|
const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();
|
|
@@ -58,9 +59,9 @@ function CustomDateTimeItem(props) {
|
|
|
58
59
|
}
|
|
59
60
|
const { displayDate, dateParseFail } = parseFhirDateToDisplayDate(valueDate);
|
|
60
61
|
const { displayTime, displayPeriod, timeParseFail } = parseDateTimeToDisplayTime(dateTimeDayJs);
|
|
61
|
-
const [dateInput, setDateInput] =
|
|
62
|
-
const [timeInput, setTimeInput] =
|
|
63
|
-
const [periodInput, setPeriodInput] =
|
|
62
|
+
const [dateInput, setDateInput] = useStringInput(displayDate);
|
|
63
|
+
const [timeInput, setTimeInput] = useStringInput(displayTime);
|
|
64
|
+
const [periodInput, setPeriodInput] = useStringInput(displayPeriod);
|
|
64
65
|
const [dateFocused, setDateFocused] = useState(false);
|
|
65
66
|
// Perform validation checks
|
|
66
67
|
let dateFeedback = useDateValidation(dateInput, dateParseFail);
|
package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomDateTimeItem.js","sourceRoot":"","sources":["../../../../../src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQxC,OAAO,WAAW,MAAM,+BAA+B,CAAC;AACxD,OAAO,sBAAsB,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,iBAAiB,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,MAAM,qBAAqB,CAAC;AAExC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,iBAAiB,MAAM,qCAAqC,CAAC;AACpE,OAAO,yBAAyB,MAAM,uCAAuC,CAAC;AAC9E,OAAO,aAAa,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomDateTimeItem.js","sourceRoot":"","s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,oBAAC,yBAAyB,iBACd,iBAAiB,iBACd,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,aAAa,IACZ,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,EAChC,YAAY,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,EAChC,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,qBAAqB,EACxC,YAAY,EAAE,gBAAgB,EAC9B,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,qBAAqB,GACxC,CACY,CACU,CAC7B,CAAC;AACJ,CAAC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import React
|
|
17
|
+
import React from 'react';
|
|
18
18
|
import useInitialiseRepeatGroups from '../../../hooks/useInitialiseRepeatGroups';
|
|
19
19
|
import { QGroupContainerBox } from '../../Box.styles';
|
|
20
20
|
import Card from '@mui/material/Card';
|
|
@@ -30,12 +30,13 @@ import cloneDeep from 'lodash.clonedeep';
|
|
|
30
30
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
31
31
|
import Typography from '@mui/material/Typography';
|
|
32
32
|
import { useQuestionnaireStore } from '../../../stores';
|
|
33
|
+
import useRepeatGroups from '../../../hooks/useRepeatGroups';
|
|
33
34
|
function RepeatGroup(props) {
|
|
34
35
|
const { qItem, qrItems, groupCardElevation, showMinimalView, parentIsReadOnly, onQrRepeatGroupChange } = props;
|
|
35
36
|
const mutateRepeatEnableWhenItems = useQuestionnaireStore.use.mutateRepeatEnableWhenItems();
|
|
36
37
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
37
38
|
const initialRepeatGroups = useInitialiseRepeatGroups(qItem, qrItems);
|
|
38
|
-
const [repeatGroups, setRepeatGroups] =
|
|
39
|
+
const [repeatGroups, setRepeatGroups] = useRepeatGroups(initialRepeatGroups);
|
|
39
40
|
function handleAnswerChange(newQrItem, index) {
|
|
40
41
|
const updatedRepeatGroups = [...repeatGroups];
|
|
41
42
|
if (newQrItem.item) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepeatGroup.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/RepeatGroup/RepeatGroup.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"RepeatGroup.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/RepeatGroup/RepeatGroup.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,yBAAyB,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CA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|
|
16
16
|
*/
|
|
17
|
-
import React
|
|
17
|
+
import React from 'react';
|
|
18
18
|
import { nanoid } from 'nanoid';
|
|
19
19
|
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
20
20
|
import { FullWidthFormComponentBox } from '../../Box.styles';
|
|
@@ -26,12 +26,13 @@ import useInitialiseRepeatAnswers from '../../../hooks/useInitialiseRepeatAnswer
|
|
|
26
26
|
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
27
27
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
28
28
|
import { useQuestionnaireStore } from '../../../stores';
|
|
29
|
+
import useRepeatAnswers from '../../../hooks/useRepeatAnswers';
|
|
29
30
|
function RepeatItem(props) {
|
|
30
31
|
const { qItem, qrItem, groupCardElevation, showMinimalView, parentIsReadOnly, onQrItemChange } = props;
|
|
31
32
|
const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();
|
|
32
33
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
33
34
|
const initialRepeatAnswers = useInitialiseRepeatAnswers(qItem, qrItem);
|
|
34
|
-
const [repeatAnswers, setRepeatAnswers] =
|
|
35
|
+
const [repeatAnswers, setRepeatAnswers] = useRepeatAnswers(initialRepeatAnswers);
|
|
35
36
|
// Event Handlers
|
|
36
37
|
function handleAnswerChange(newQrItem, index) {
|
|
37
38
|
const updatedRepeatAnswers = [...repeatAnswers];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepeatItem.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/RepeatItem/RepeatItem.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"RepeatItem.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/RepeatItem/RepeatItem.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,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,CAAC,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,GACnE,CACO,CACZ,CAAC;YACJ,CAAC,CAAC,CACc,CACJ;QAEhB,oBAAC,aAAa,IAAC,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,GAAI,CACnE,CAC7B,CAAC;AACJ,CAAC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import React, { useCallback
|
|
17
|
+
import React, { useCallback } from 'react';
|
|
18
18
|
import useRenderingExtensions from '../../../hooks/useRenderingExtensions';
|
|
19
19
|
import useValidationFeedback from '../../../hooks/useValidationFeedback';
|
|
20
20
|
import debounce from 'lodash.debounce';
|
|
@@ -25,6 +25,7 @@ import UrlField from './UrlField';
|
|
|
25
25
|
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
26
26
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
27
27
|
import { useQuestionnaireStore } from '../../../stores';
|
|
28
|
+
import useStringInput from '../../../hooks/useStringInput';
|
|
28
29
|
function UrlItem(props) {
|
|
29
30
|
const { qItem, qrItem, isRepeated, isTabled, parentIsReadOnly, onQrItemChange } = props;
|
|
30
31
|
const onFocusLinkId = useQuestionnaireStore.use.onFocusLinkId();
|
|
@@ -35,7 +36,7 @@ function UrlItem(props) {
|
|
|
35
36
|
if ((qrItem === null || qrItem === void 0 ? void 0 : qrItem.answer) && (qrItem === null || qrItem === void 0 ? void 0 : qrItem.answer[0].valueUri)) {
|
|
36
37
|
valueUri = qrItem.answer[0].valueUri;
|
|
37
38
|
}
|
|
38
|
-
const [input, setInput] =
|
|
39
|
+
const [input, setInput] = useStringInput(valueUri);
|
|
39
40
|
// Perform validation checks
|
|
40
41
|
const feedback = useValidationFeedback(qItem, input);
|
|
41
42
|
// Event handlers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlItem.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/UrlItem/UrlItem.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"UrlItem.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/UrlItem/UrlItem.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAQ3C,OAAO,sBAAsB,MAAM,uCAAuC,CAAC;AAC3E,OAAO,qBAAqB,MAAM,sCAAsC,CAAC;AACzE,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,cAAc,MAAM,+BAA+B,CAAC;AAU3D,SAAS,OAAO,CAAC,KAAmB;IAClC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAExF,MAAM,aAAa,GAAG,qBAAqB,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IAEhE,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACtD,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,sBAAsB,CAAC,KAAK,CAAC,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,EACxB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,YAAY,EAC3B,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;KACH;IACD,OAAO,CACL,oBAAC,yBAAyB,iBACd,mBAAmB,iBAChB,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,QAAQ,IACP,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,YAAY,EAC3B,QAAQ,EAAE,QAAQ,GAClB,CACY,CACU,CAC7B,CAAC;AACJ,CAAC;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -34,9 +34,9 @@ function useInitialiseRepeatAnswers(qItem, qrItem) {
|
|
|
34
34
|
}
|
|
35
35
|
return initialRepeatAnswers;
|
|
36
36
|
},
|
|
37
|
-
//
|
|
37
|
+
// Requires checking of both qItem and qrItem
|
|
38
38
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
-
[qItem]);
|
|
39
|
+
[qItem, qrItem]);
|
|
40
40
|
}
|
|
41
41
|
export default useInitialiseRepeatAnswers;
|
|
42
42
|
//# sourceMappingURL=useInitialiseRepeatAnswers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitialiseRepeatAnswers.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRepeatAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,SAAS,0BAA0B,CACjC,KAAwB,EACxB,MAAwC;IAExC,OAAO,OAAO,CACZ,GAAG,EAAE;QACH,IAAI,oBAAoB,GAAmB;YACzC;gBACE,MAAM,EAAE,MAAM,EAAE;gBAChB,MAAM,EAAE,IAAI;aACb;SACF,CAAC;QAEF,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;YAClB,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;gBAClD,OAAO;oBACL,MAAM,EAAE,MAAM,EAAE;oBAChB,MAAM;iBACP,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD
|
|
1
|
+
{"version":3,"file":"useInitialiseRepeatAnswers.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRepeatAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,SAAS,0BAA0B,CACjC,KAAwB,EACxB,MAAwC;IAExC,OAAO,OAAO,CACZ,GAAG,EAAE;QACH,IAAI,oBAAoB,GAAmB;YACzC;gBACE,MAAM,EAAE,MAAM,EAAE;gBAChB,MAAM,EAAE,IAAI;aACb;SACF,CAAC;QAEF,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;YAClB,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;gBAClD,OAAO;oBACL,MAAM,EAAE,MAAM,EAAE;oBAChB,MAAM;iBACP,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,6CAA6C;IAC7C,uDAAuD;IACvD,CAAC,KAAK,EAAE,MAAM,CAAC,CAChB,CAAC;AACJ,CAAC;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { QuestionnaireResponseItem } from 'fhir/r4';
|
|
2
|
-
import type { QuestionnaireItem } from 'fhir/r4';
|
|
1
|
+
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
3
2
|
import type { RepeatGroupSingle } from '../interfaces/repeatGroup.interface';
|
|
4
3
|
declare function useInitialiseRepeatGroups(qItem: QuestionnaireItem, qrItems: QuestionnaireResponseItem[]): RepeatGroupSingle[];
|
|
5
4
|
export default useInitialiseRepeatGroups;
|
|
@@ -34,9 +34,9 @@ function useInitialiseRepeatGroups(qItem, qrItems) {
|
|
|
34
34
|
}
|
|
35
35
|
return initialRepeatGroupAnswers;
|
|
36
36
|
},
|
|
37
|
-
//
|
|
37
|
+
// Requires checking of both qItem and qrItems
|
|
38
38
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
-
[qItem]);
|
|
39
|
+
[qItem, qrItems]);
|
|
40
40
|
}
|
|
41
41
|
export default useInitialiseRepeatGroups;
|
|
42
42
|
//# sourceMappingURL=useInitialiseRepeatGroups.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitialiseRepeatGroups.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRepeatGroups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"useInitialiseRepeatGroups.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRepeatGroups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,SAAS,yBAAyB,CAChC,KAAwB,EACxB,OAAoC;IAEpC,OAAO,OAAO,CACZ,GAAG,EAAE;QACH,IAAI,yBAAyB,GAAwB;YACnD;gBACE,MAAM,EAAE,MAAM,EAAE;gBAChB,MAAM,EAAE,IAAI;aACb;SACF,CAAC;QAEF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACtB,yBAAyB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;gBACjD,OAAO;oBACL,MAAM,EAAE,MAAM,EAAE;oBAChB,MAAM;iBACP,CAAC;YACJ,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,yBAAyB,CAAC;IACnC,CAAC;IACD,8CAA8C;IAC9C,uDAAuD;IACvD,CAAC,KAAK,EAAE,OAAO,CAAC,CACjB,CAAC;AACJ,CAAC;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import type { RepeatAnswer } from '../interfaces/repeatItem.interface';
|
|
3
|
+
declare function useRepeatAnswers(valueFromProps: RepeatAnswer[]): [RepeatAnswer[], Dispatch<SetStateAction<RepeatAnswer[]>>];
|
|
4
|
+
export default useRepeatAnswers;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { useEffect, useState } from 'react';
|
|
18
|
+
import _isEqual from 'lodash/isEqual';
|
|
19
|
+
function useRepeatAnswers(valueFromProps) {
|
|
20
|
+
const [repeatAnswers, setRepeatAnswers] = useState(valueFromProps);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const valueFromPropsQRItemAnswers = valueFromProps.map((answer) => answer.answer);
|
|
23
|
+
const repeatAnswersQRItemAnswers = repeatAnswers.map((answer) => answer.answer);
|
|
24
|
+
if (!_isEqual(valueFromPropsQRItemAnswers, repeatAnswersQRItemAnswers)) {
|
|
25
|
+
setRepeatAnswers(valueFromProps);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
// Only trigger this effect if prop value changes
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
[valueFromProps]);
|
|
31
|
+
return [repeatAnswers, setRepeatAnswers];
|
|
32
|
+
}
|
|
33
|
+
export default useRepeatAnswers;
|
|
34
|
+
//# sourceMappingURL=useRepeatAnswers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRepeatAnswers.js","sourceRoot":"","sources":["../../src/hooks/useRepeatAnswers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,SAAS,gBAAgB,CACvB,cAA8B;IAE9B,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEnE,SAAS,CACP,GAAG,EAAE;QACH,MAAM,2BAA2B,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAClF,MAAM,0BAA0B,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEhF,IAAI,CAAC,QAAQ,CAAC,2BAA2B,EAAE,0BAA0B,CAAC,EAAE;YACtE,gBAAgB,CAAC,cAAc,CAAC,CAAC;SAClC;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AAC3C,CAAC;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import type { RepeatGroupSingle } from '../interfaces/repeatGroup.interface';
|
|
3
|
+
declare function useRepeatGroups(valueFromProps: RepeatGroupSingle[]): [RepeatGroupSingle[], Dispatch<SetStateAction<RepeatGroupSingle[]>>];
|
|
4
|
+
export default useRepeatGroups;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { useEffect, useState } from 'react';
|
|
18
|
+
import _isEqual from 'lodash/isEqual';
|
|
19
|
+
function useRepeatGroups(valueFromProps) {
|
|
20
|
+
const [repeatGroups, setRepeatGroups] = useState(valueFromProps);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const valueFromPropsQRItems = valueFromProps.map((repeatGroupSingle) => repeatGroupSingle.qrItem);
|
|
23
|
+
const repeatGroupsQRItems = repeatGroups.map((repeatGroupSingle) => repeatGroupSingle.qrItem);
|
|
24
|
+
if (!_isEqual(valueFromPropsQRItems, repeatGroupsQRItems)) {
|
|
25
|
+
setRepeatGroups(valueFromProps);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
// Only trigger this effect if prop value changes
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
[valueFromProps]);
|
|
31
|
+
return [repeatGroups, setRepeatGroups];
|
|
32
|
+
}
|
|
33
|
+
export default useRepeatGroups;
|
|
34
|
+
//# sourceMappingURL=useRepeatGroups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRepeatGroups.js","sourceRoot":"","sources":["../../src/hooks/useRepeatGroups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,SAAS,eAAe,CACtB,cAAmC;IAEnC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEjE,SAAS,CACP,GAAG,EAAE;QACH,MAAM,qBAAqB,GAAG,cAAc,CAAC,GAAG,CAC9C,CAAC,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAChD,CAAC;QACF,MAAM,mBAAmB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAE9F,IAAI,CAAC,QAAQ,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,EAAE;YACzD,eAAe,CAAC,cAAc,CAAC,CAAC;SACjC;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;AACzC,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRepeatitemState.js","sourceRoot":"","sources":["../../src/hooks/useRepeatitemState.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -36,6 +36,7 @@ import { createEmptyQrItem } from '../../../../utils/qrItem';
|
|
|
36
36
|
import useDateValidation from '../../../../hooks/useDateValidation';
|
|
37
37
|
import CustomDateField from './CustomDateField';
|
|
38
38
|
import { useQuestionnaireStore } from '../../../../stores';
|
|
39
|
+
import useStringInput from '../../../../hooks/useStringInput';
|
|
39
40
|
|
|
40
41
|
interface CustomDateItemProps
|
|
41
42
|
extends PropsWithQrItemChangeHandler,
|
|
@@ -68,7 +69,7 @@ function CustomDateItem(props: CustomDateItemProps) {
|
|
|
68
69
|
|
|
69
70
|
const { displayDate, dateParseFail } = parseFhirDateToDisplayDate(valueDate);
|
|
70
71
|
|
|
71
|
-
const [input, setInput] =
|
|
72
|
+
const [input, setInput] = useStringInput(displayDate);
|
|
72
73
|
const [focused, setFocused] = useState(false);
|
|
73
74
|
|
|
74
75
|
// Perform validation checks
|
package/src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.tsx
CHANGED
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
import useTimeValidation from '../../../../hooks/useTimeValidation';
|
|
44
44
|
import useDateNonEmptyValidation from '../../../../hooks/useDateTimeNonEmpty';
|
|
45
45
|
import DateTimeField from './DateTimeField';
|
|
46
|
+
import useStringInput from '../../../../hooks/useStringInput';
|
|
46
47
|
|
|
47
48
|
interface CustomDateTimeItemProps
|
|
48
49
|
extends PropsWithQrItemChangeHandler,
|
|
@@ -86,9 +87,9 @@ function CustomDateTimeItem(props: CustomDateTimeItemProps) {
|
|
|
86
87
|
const { displayDate, dateParseFail } = parseFhirDateToDisplayDate(valueDate);
|
|
87
88
|
const { displayTime, displayPeriod, timeParseFail } = parseDateTimeToDisplayTime(dateTimeDayJs);
|
|
88
89
|
|
|
89
|
-
const [dateInput, setDateInput] =
|
|
90
|
-
const [timeInput, setTimeInput] =
|
|
91
|
-
const [periodInput, setPeriodInput] =
|
|
90
|
+
const [dateInput, setDateInput] = useStringInput(displayDate);
|
|
91
|
+
const [timeInput, setTimeInput] = useStringInput(displayTime);
|
|
92
|
+
const [periodInput, setPeriodInput] = useStringInput(displayPeriod);
|
|
92
93
|
const [dateFocused, setDateFocused] = useState(false);
|
|
93
94
|
|
|
94
95
|
// Perform validation checks
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import React
|
|
18
|
+
import React from 'react';
|
|
19
19
|
import type {
|
|
20
20
|
PropsWithParentIsReadOnlyAttribute,
|
|
21
21
|
PropsWithParentIsRepeatGroupAttribute,
|
|
@@ -38,6 +38,7 @@ import cloneDeep from 'lodash.clonedeep';
|
|
|
38
38
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
39
39
|
import Typography from '@mui/material/Typography';
|
|
40
40
|
import { useQuestionnaireStore } from '../../../stores';
|
|
41
|
+
import useRepeatGroups from '../../../hooks/useRepeatGroups';
|
|
41
42
|
|
|
42
43
|
interface RepeatGroupProps
|
|
43
44
|
extends PropsWithQrRepeatGroupChangeHandler,
|
|
@@ -65,7 +66,7 @@ function RepeatGroup(props: RepeatGroupProps) {
|
|
|
65
66
|
|
|
66
67
|
const initialRepeatGroups = useInitialiseRepeatGroups(qItem, qrItems);
|
|
67
68
|
|
|
68
|
-
const [repeatGroups, setRepeatGroups] =
|
|
69
|
+
const [repeatGroups, setRepeatGroups] = useRepeatGroups(initialRepeatGroups);
|
|
69
70
|
|
|
70
71
|
function handleAnswerChange(newQrItem: QuestionnaireResponseItem, index: number) {
|
|
71
72
|
const updatedRepeatGroups = [...repeatGroups];
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import React
|
|
18
|
+
import React from 'react';
|
|
19
19
|
import type {
|
|
20
20
|
PropsWithParentIsReadOnlyAttribute,
|
|
21
21
|
PropsWithQrItemChangeHandler,
|
|
@@ -33,6 +33,7 @@ import useInitialiseRepeatAnswers from '../../../hooks/useInitialiseRepeatAnswer
|
|
|
33
33
|
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
34
34
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
35
35
|
import { useQuestionnaireStore } from '../../../stores';
|
|
36
|
+
import useRepeatAnswers from '../../../hooks/useRepeatAnswers';
|
|
36
37
|
|
|
37
38
|
interface RepeatItemProps
|
|
38
39
|
extends PropsWithQrItemChangeHandler,
|
|
@@ -53,7 +54,7 @@ function RepeatItem(props: RepeatItemProps) {
|
|
|
53
54
|
|
|
54
55
|
const initialRepeatAnswers = useInitialiseRepeatAnswers(qItem, qrItem);
|
|
55
56
|
|
|
56
|
-
const [repeatAnswers, setRepeatAnswers] =
|
|
57
|
+
const [repeatAnswers, setRepeatAnswers] = useRepeatAnswers(initialRepeatAnswers);
|
|
57
58
|
|
|
58
59
|
// Event Handlers
|
|
59
60
|
function handleAnswerChange(newQrItem: QuestionnaireResponseItem, index: number) {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import React, { useCallback
|
|
18
|
+
import React, { useCallback } from 'react';
|
|
19
19
|
import type {
|
|
20
20
|
PropsWithIsRepeatedAttribute,
|
|
21
21
|
PropsWithIsTabledAttribute,
|
|
@@ -33,6 +33,7 @@ import UrlField from './UrlField';
|
|
|
33
33
|
import ItemFieldGrid from '../ItemParts/ItemFieldGrid';
|
|
34
34
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
35
35
|
import { useQuestionnaireStore } from '../../../stores';
|
|
36
|
+
import useStringInput from '../../../hooks/useStringInput';
|
|
36
37
|
|
|
37
38
|
interface UrlItemProps
|
|
38
39
|
extends PropsWithQrItemChangeHandler,
|
|
@@ -55,7 +56,7 @@ function UrlItem(props: UrlItemProps) {
|
|
|
55
56
|
if (qrItem?.answer && qrItem?.answer[0].valueUri) {
|
|
56
57
|
valueUri = qrItem.answer[0].valueUri;
|
|
57
58
|
}
|
|
58
|
-
const [input, setInput] =
|
|
59
|
+
const [input, setInput] = useStringInput(valueUri);
|
|
59
60
|
|
|
60
61
|
// Perform validation checks
|
|
61
62
|
const feedback = useValidationFeedback(qItem, input);
|
|
@@ -44,9 +44,9 @@ function useInitialiseRepeatAnswers(
|
|
|
44
44
|
|
|
45
45
|
return initialRepeatAnswers;
|
|
46
46
|
},
|
|
47
|
-
//
|
|
47
|
+
// Requires checking of both qItem and qrItem
|
|
48
48
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
|
-
[qItem]
|
|
49
|
+
[qItem, qrItem]
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import type { QuestionnaireResponseItem } from 'fhir/r4';
|
|
19
|
-
import type { QuestionnaireItem } from 'fhir/r4';
|
|
18
|
+
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
20
19
|
import { nanoid } from 'nanoid';
|
|
21
20
|
import type { RepeatGroupSingle } from '../interfaces/repeatGroup.interface';
|
|
22
21
|
import { useMemo } from 'react';
|
|
@@ -44,9 +43,9 @@ function useInitialiseRepeatGroups(
|
|
|
44
43
|
}
|
|
45
44
|
return initialRepeatGroupAnswers;
|
|
46
45
|
},
|
|
47
|
-
//
|
|
46
|
+
// Requires checking of both qItem and qrItems
|
|
48
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
|
-
[qItem]
|
|
48
|
+
[qItem, qrItems]
|
|
50
49
|
);
|
|
51
50
|
}
|
|
52
51
|
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
|
|
18
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
19
|
+
import { useEffect, useState } from 'react';
|
|
20
|
+
import type { RepeatAnswer } from '../interfaces/repeatItem.interface';
|
|
21
|
+
import _isEqual from 'lodash/isEqual';
|
|
22
|
+
|
|
23
|
+
function useRepeatAnswers(
|
|
24
|
+
valueFromProps: RepeatAnswer[]
|
|
25
|
+
): [RepeatAnswer[], Dispatch<SetStateAction<RepeatAnswer[]>>] {
|
|
26
|
+
const [repeatAnswers, setRepeatAnswers] = useState(valueFromProps);
|
|
27
|
+
|
|
28
|
+
useEffect(
|
|
29
|
+
() => {
|
|
30
|
+
const valueFromPropsQRItemAnswers = valueFromProps.map((answer) => answer.answer);
|
|
31
|
+
const repeatAnswersQRItemAnswers = repeatAnswers.map((answer) => answer.answer);
|
|
32
|
+
|
|
33
|
+
if (!_isEqual(valueFromPropsQRItemAnswers, repeatAnswersQRItemAnswers)) {
|
|
34
|
+
setRepeatAnswers(valueFromProps);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
// Only trigger this effect if prop value changes
|
|
38
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
+
[valueFromProps]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return [repeatAnswers, setRepeatAnswers];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default useRepeatAnswers;
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
|
|
18
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
19
|
+
import { useEffect, useState } from 'react';
|
|
20
|
+
import type { RepeatGroupSingle } from '../interfaces/repeatGroup.interface';
|
|
21
|
+
import _isEqual from 'lodash/isEqual';
|
|
22
|
+
|
|
23
|
+
function useRepeatGroups(
|
|
24
|
+
valueFromProps: RepeatGroupSingle[]
|
|
25
|
+
): [RepeatGroupSingle[], Dispatch<SetStateAction<RepeatGroupSingle[]>>] {
|
|
26
|
+
const [repeatGroups, setRepeatGroups] = useState(valueFromProps);
|
|
27
|
+
|
|
28
|
+
useEffect(
|
|
29
|
+
() => {
|
|
30
|
+
const valueFromPropsQRItems = valueFromProps.map(
|
|
31
|
+
(repeatGroupSingle) => repeatGroupSingle.qrItem
|
|
32
|
+
);
|
|
33
|
+
const repeatGroupsQRItems = repeatGroups.map((repeatGroupSingle) => repeatGroupSingle.qrItem);
|
|
34
|
+
|
|
35
|
+
if (!_isEqual(valueFromPropsQRItems, repeatGroupsQRItems)) {
|
|
36
|
+
setRepeatGroups(valueFromProps);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
// Only trigger this effect if prop value changes
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
[valueFromProps]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return [repeatGroups, setRepeatGroups];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default useRepeatGroups;
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
import React from 'react';
|
|
20
|
+
import { Box, IconButton, Tooltip } from '@mui/material';
|
|
21
|
+
import Iconify from '../components/Iconify/Iconify';
|
|
22
|
+
|
|
23
|
+
interface BuildFormButtonProps {
|
|
24
|
+
onBuild: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function BuildFormButtonForStorybook(props: BuildFormButtonProps) {
|
|
28
|
+
const { onBuild } = props;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Box display="flex" mb={0.5} alignItems="center" columnGap={3}>
|
|
32
|
+
<Tooltip title="Build form" placement="right">
|
|
33
|
+
<IconButton onClick={onBuild} size="small" color="primary">
|
|
34
|
+
<Iconify icon="ph:hammer" sx={{ mb: 0.5 }} />
|
|
35
|
+
</IconButton>
|
|
36
|
+
</Tooltip>
|
|
37
|
+
</Box>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default BuildFormButtonForStorybook;
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
import React from 'react';
|
|
20
|
+
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
21
|
+
import { BaseRenderer } from '../components';
|
|
22
|
+
import { QueryClientProvider } from '@tanstack/react-query';
|
|
23
|
+
import ThemeProvider from '../theme/Theme';
|
|
24
|
+
import useQueryClient from '../hooks/useQueryClient';
|
|
25
|
+
import useBuildFormForStorybook from './useBuildFormForStorybook';
|
|
26
|
+
import { buildForm } from '../utils';
|
|
27
|
+
import BuildFormButtonForStorybook from './BuildFormButtonForStorybook';
|
|
28
|
+
|
|
29
|
+
interface BuildFormButtonTesterWrapperProps {
|
|
30
|
+
questionnaire: Questionnaire;
|
|
31
|
+
questionnaireResponse?: QuestionnaireResponse;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function BuildFormButtonTesterWrapper(props: BuildFormButtonTesterWrapperProps) {
|
|
35
|
+
const { questionnaire, questionnaireResponse } = props;
|
|
36
|
+
|
|
37
|
+
const queryClient = useQueryClient();
|
|
38
|
+
|
|
39
|
+
const isBuilding = useBuildFormForStorybook(questionnaire);
|
|
40
|
+
|
|
41
|
+
async function handleBuildForm() {
|
|
42
|
+
await buildForm(questionnaire, questionnaireResponse);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (isBuilding) {
|
|
46
|
+
return <div>Loading...</div>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<ThemeProvider>
|
|
51
|
+
<QueryClientProvider client={queryClient}>
|
|
52
|
+
<div>
|
|
53
|
+
<BuildFormButtonForStorybook onBuild={handleBuildForm} />
|
|
54
|
+
<BaseRenderer />
|
|
55
|
+
</div>
|
|
56
|
+
</QueryClientProvider>
|
|
57
|
+
</ThemeProvider>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default BuildFormButtonTesterWrapper;
|
|
@@ -0,0 +1,270 @@
|
|
|
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
|
+
|
|
18
|
+
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
|
|
19
|
+
|
|
20
|
+
export const qBuildFormButtonTester: Questionnaire = {
|
|
21
|
+
resourceType: 'Questionnaire',
|
|
22
|
+
id: 'BuildFormButtonTester',
|
|
23
|
+
name: 'BuildFormButtonTester',
|
|
24
|
+
title: 'BuildForm Button Tester',
|
|
25
|
+
version: '0.1.0',
|
|
26
|
+
status: 'draft',
|
|
27
|
+
publisher: 'AEHRC CSIRO',
|
|
28
|
+
date: '2024-05-01',
|
|
29
|
+
url: 'https://smartforms.csiro.au/docs/tester/build-form-button',
|
|
30
|
+
item: [
|
|
31
|
+
{
|
|
32
|
+
linkId: 'decimal',
|
|
33
|
+
type: 'decimal',
|
|
34
|
+
repeats: false,
|
|
35
|
+
text: 'Decimal Test'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
linkId: 'integer',
|
|
39
|
+
type: 'integer',
|
|
40
|
+
repeats: false,
|
|
41
|
+
text: 'Integer Test'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
linkId: 'string',
|
|
45
|
+
type: 'string',
|
|
46
|
+
repeats: false,
|
|
47
|
+
text: 'String Test'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
linkId: 'text',
|
|
51
|
+
type: 'text',
|
|
52
|
+
repeats: false,
|
|
53
|
+
text: 'Text Test'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
linkId: 'date',
|
|
57
|
+
type: 'date',
|
|
58
|
+
repeats: false,
|
|
59
|
+
text: 'Date Test'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
linkId: 'dateTime',
|
|
63
|
+
type: 'dateTime',
|
|
64
|
+
repeats: false,
|
|
65
|
+
text: 'DateTime Test'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
linkId: 'url',
|
|
69
|
+
type: 'url',
|
|
70
|
+
repeats: false,
|
|
71
|
+
text: 'URL Test'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
linkId: 'repeats-container',
|
|
75
|
+
type: 'group',
|
|
76
|
+
repeats: false,
|
|
77
|
+
text: '',
|
|
78
|
+
item: [
|
|
79
|
+
{
|
|
80
|
+
linkId: 'repeats-string',
|
|
81
|
+
type: 'string',
|
|
82
|
+
repeats: true,
|
|
83
|
+
text: 'Repeats Test (String)'
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
linkId: 'repeats-group',
|
|
89
|
+
type: 'group',
|
|
90
|
+
repeats: true,
|
|
91
|
+
text: 'Repeats Group Test',
|
|
92
|
+
item: [
|
|
93
|
+
{
|
|
94
|
+
linkId: 'repeats-group-boolean',
|
|
95
|
+
type: 'boolean',
|
|
96
|
+
repeats: false,
|
|
97
|
+
text: 'Boolean'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
linkId: 'repeats-group-integer',
|
|
101
|
+
type: 'integer',
|
|
102
|
+
repeats: false,
|
|
103
|
+
text: 'Integer'
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
linkId: 'repeats-group-string',
|
|
107
|
+
type: 'string',
|
|
108
|
+
repeats: false,
|
|
109
|
+
text: 'String'
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const qrBuildFormTesterResponse: QuestionnaireResponse = {
|
|
117
|
+
resourceType: 'QuestionnaireResponse',
|
|
118
|
+
status: 'in-progress',
|
|
119
|
+
item: [
|
|
120
|
+
{
|
|
121
|
+
linkId: 'decimal',
|
|
122
|
+
text: 'Decimal Test',
|
|
123
|
+
answer: [
|
|
124
|
+
{
|
|
125
|
+
valueDecimal: 123.45
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
linkId: 'integer',
|
|
131
|
+
text: 'Integer Test',
|
|
132
|
+
answer: [
|
|
133
|
+
{
|
|
134
|
+
valueInteger: 123
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
linkId: 'string',
|
|
140
|
+
text: 'String Test',
|
|
141
|
+
answer: [
|
|
142
|
+
{
|
|
143
|
+
valueString: 'Sample String'
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
linkId: 'text',
|
|
149
|
+
text: 'Text Test',
|
|
150
|
+
answer: [
|
|
151
|
+
{
|
|
152
|
+
valueString: 'Sample Text'
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
linkId: 'date',
|
|
158
|
+
text: 'Date Test',
|
|
159
|
+
answer: [
|
|
160
|
+
{
|
|
161
|
+
valueDate: '2024-05-20'
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
linkId: 'dateTime',
|
|
167
|
+
text: 'DateTime Test',
|
|
168
|
+
answer: [
|
|
169
|
+
{
|
|
170
|
+
valueDateTime: '2024-05-20T15:30:00Z'
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
linkId: 'url',
|
|
176
|
+
text: 'URL Test',
|
|
177
|
+
answer: [
|
|
178
|
+
{
|
|
179
|
+
valueUri: 'https://example.com'
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
linkId: 'repeats-container',
|
|
185
|
+
text: '',
|
|
186
|
+
item: [
|
|
187
|
+
{
|
|
188
|
+
linkId: 'repeats-string',
|
|
189
|
+
text: 'Repeats Test (String)',
|
|
190
|
+
answer: [
|
|
191
|
+
{
|
|
192
|
+
valueString: 'First String'
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
valueString: 'Second String'
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
linkId: 'repeats-group',
|
|
203
|
+
text: 'Repeats Group Test',
|
|
204
|
+
item: [
|
|
205
|
+
{
|
|
206
|
+
linkId: 'repeats-group-boolean',
|
|
207
|
+
text: 'Boolean',
|
|
208
|
+
answer: [
|
|
209
|
+
{
|
|
210
|
+
valueBoolean: true
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
linkId: 'repeats-group-integer',
|
|
216
|
+
text: 'Integer',
|
|
217
|
+
answer: [
|
|
218
|
+
{
|
|
219
|
+
valueInteger: 123
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
linkId: 'repeats-group-string',
|
|
225
|
+
text: 'String',
|
|
226
|
+
answer: [
|
|
227
|
+
{
|
|
228
|
+
valueString: 'Nested String 1'
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
]
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
linkId: 'repeats-group',
|
|
236
|
+
text: 'Repeats Group Test',
|
|
237
|
+
item: [
|
|
238
|
+
{
|
|
239
|
+
linkId: 'repeats-group-boolean',
|
|
240
|
+
text: 'Boolean',
|
|
241
|
+
answer: [
|
|
242
|
+
{
|
|
243
|
+
valueBoolean: false
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
linkId: 'repeats-group-integer',
|
|
249
|
+
text: 'Integer',
|
|
250
|
+
answer: [
|
|
251
|
+
{
|
|
252
|
+
valueInteger: 456
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
linkId: 'repeats-group-string',
|
|
258
|
+
text: 'String',
|
|
259
|
+
answer: [
|
|
260
|
+
{
|
|
261
|
+
valueString: 'Nested String 2'
|
|
262
|
+
}
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
]
|
|
266
|
+
}
|
|
267
|
+
],
|
|
268
|
+
|
|
269
|
+
questionnaire: 'https://smartforms.csiro.au/docs/tester/build-form-button'
|
|
270
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
|
|
18
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
19
|
+
import BuildFormButtonTesterWrapper from '../BuildFormButtonTesterWrapper';
|
|
20
|
+
import {
|
|
21
|
+
qBuildFormButtonTester,
|
|
22
|
+
qrBuildFormTesterResponse
|
|
23
|
+
} from '../assets/questionnaires/QBuildFormButtonTester';
|
|
24
|
+
|
|
25
|
+
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
26
|
+
const meta = {
|
|
27
|
+
title: 'Component/Testing/Build Form Button Tester',
|
|
28
|
+
component: BuildFormButtonTesterWrapper,
|
|
29
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
|
|
30
|
+
tags: []
|
|
31
|
+
} satisfies Meta<typeof BuildFormButtonTesterWrapper>;
|
|
32
|
+
|
|
33
|
+
export default meta;
|
|
34
|
+
type Story = StoryObj<typeof meta>;
|
|
35
|
+
|
|
36
|
+
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
|
|
37
|
+
|
|
38
|
+
export const BuildFormButtonTester: Story = {
|
|
39
|
+
args: {
|
|
40
|
+
questionnaire: qBuildFormButtonTester,
|
|
41
|
+
questionnaireResponse: qrBuildFormTesterResponse
|
|
42
|
+
}
|
|
43
|
+
};
|
package/vite.config.ts
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import { defineConfig } from 'vite';
|
|
19
19
|
|
|
20
|
+
// This Vite config is for storybook usage only.
|
|
20
21
|
// https://vitejs.dev/config/
|
|
21
22
|
export default defineConfig({
|
|
22
23
|
plugins: [],
|
|
@@ -27,5 +28,6 @@ export default defineConfig({
|
|
|
27
28
|
commonjsOptions: {
|
|
28
29
|
include: [/node_modules/, '@aehrc/sdc-populate']
|
|
29
30
|
}
|
|
30
|
-
}
|
|
31
|
+
},
|
|
32
|
+
resolve: { preserveSymlinks: true }
|
|
31
33
|
});
|