@aehrc/smart-forms-renderer 0.40.2 → 0.41.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/AttachmentItem/AttachmentItem.js +2 -3
- package/lib/components/FormComponents/AttachmentItem/AttachmentItem.js.map +1 -1
- package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.js +1 -2
- package/lib/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.js.map +1 -1
- package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js +3 -4
- package/lib/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.js.map +1 -1
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js +2 -3
- package/lib/components/FormComponents/DecimalItem/DecimalItem.js.map +1 -1
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js +2 -3
- package/lib/components/FormComponents/IntegerItem/IntegerItem.js.map +1 -1
- package/lib/components/FormComponents/QuantityItem/QuantityItem.js +1 -2
- package/lib/components/FormComponents/QuantityItem/QuantityItem.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/AddItemButton.d.ts +2 -2
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js +2 -3
- package/lib/components/FormComponents/RepeatGroup/RepeatGroup.js.map +1 -1
- package/lib/components/FormComponents/RepeatGroup/RepeatGroupView.d.ts +2 -2
- package/lib/components/FormComponents/StringItem/StringItem.js +2 -3
- package/lib/components/FormComponents/StringItem/StringItem.js.map +1 -1
- package/lib/components/FormComponents/Tables/AddRowButton.d.ts +2 -2
- package/lib/components/FormComponents/Tables/GroupTable.js +3 -1
- package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -1
- package/lib/components/FormComponents/TextItem/TextItem.js +2 -3
- package/lib/components/FormComponents/TextItem/TextItem.js.map +1 -1
- package/lib/components/FormComponents/UrlItem/UrlItem.js +2 -3
- package/lib/components/FormComponents/UrlItem/UrlItem.js.map +1 -1
- package/lib/components/Renderer/BaseRenderer.js +4 -3
- package/lib/components/Renderer/BaseRenderer.js.map +1 -1
- package/lib/hooks/useGroupTableRows.d.ts +4 -4
- package/lib/hooks/useGroupTableRows.js +3 -5
- package/lib/hooks/useGroupTableRows.js.map +1 -1
- package/lib/hooks/useInitialiseGroupTableRows.d.ts +4 -0
- package/lib/hooks/{useNumberInput.js → useInitialiseGroupTableRows.js} +16 -13
- package/lib/hooks/useInitialiseGroupTableRows.js.map +1 -0
- package/lib/hooks/useInitialiseRepeatGroups.d.ts +2 -2
- package/lib/interfaces/repeatGroup.interface.d.ts +1 -1
- package/lib/stores/questionnaireResponseStore.d.ts +3 -0
- package/lib/stores/questionnaireResponseStore.js +5 -0
- package/lib/stores/questionnaireResponseStore.js.map +1 -1
- package/lib/tests/test-data/removeIdSample.d.ts +3 -0
- package/lib/tests/test-data/removeIdSample.js +99 -0
- package/lib/tests/test-data/removeIdSample.js.map +1 -0
- package/lib/theme/Theme.js +0 -2
- package/lib/theme/Theme.js.map +1 -1
- package/lib/utils/calculatedExpression.js +4 -4
- package/lib/utils/calculatedExpression.js.map +1 -1
- package/lib/utils/extractObservation.d.ts +1 -0
- package/lib/utils/extractObservation.js +1 -1
- package/lib/utils/extractObservation.js.map +1 -1
- package/lib/utils/manageForm.js +1 -1
- package/lib/utils/manageForm.js.map +1 -1
- package/lib/utils/openChoice.js +3 -3
- package/lib/utils/openChoice.js.map +1 -1
- package/lib/utils/removeRepeatId.d.ts +2 -0
- package/lib/utils/removeRepeatId.js +85 -0
- package/lib/utils/removeRepeatId.js.map +1 -0
- package/lib/utils/repeatId.d.ts +0 -2
- package/lib/utils/repeatId.js +0 -68
- package/lib/utils/repeatId.js.map +1 -1
- package/lib/utils/repopulateItems.js +8 -8
- package/lib/utils/repopulateItems.js.map +1 -1
- package/package.json +6 -2
- package/src/components/FormComponents/AttachmentItem/AttachmentItem.tsx +2 -3
- package/src/components/FormComponents/DateTimeItems/CustomDateItem/CustomDateItem.tsx +1 -2
- package/src/components/FormComponents/DateTimeItems/CustomDateTimeItem/CustomDateTimeItem.tsx +3 -4
- package/src/components/FormComponents/DecimalItem/DecimalItem.tsx +2 -3
- package/src/components/FormComponents/IntegerItem/IntegerItem.tsx +2 -3
- package/src/components/FormComponents/QuantityItem/QuantityItem.tsx +1 -2
- package/src/components/FormComponents/RepeatGroup/AddItemButton.tsx +2 -2
- package/src/components/FormComponents/RepeatGroup/RepeatGroup.tsx +2 -3
- package/src/components/FormComponents/RepeatGroup/RepeatGroupView.tsx +2 -2
- package/src/components/FormComponents/StringItem/StringItem.tsx +2 -3
- package/src/components/FormComponents/Tables/AddRowButton.tsx +2 -2
- package/src/components/FormComponents/Tables/GroupTable.tsx +5 -5
- package/src/components/FormComponents/TextItem/TextItem.tsx +2 -3
- package/src/components/FormComponents/UrlItem/UrlItem.tsx +2 -3
- package/src/components/Renderer/BaseRenderer.tsx +4 -3
- package/src/hooks/useGroupTableRows.ts +4 -9
- package/src/hooks/{useInitialiseGroupTable.ts → useInitialiseGroupTableRows.ts} +15 -11
- package/src/hooks/useInitialiseRepeatGroups.ts +2 -2
- package/src/interfaces/repeatGroup.interface.ts +1 -1
- package/src/stores/questionnaireResponseStore.ts +7 -0
- package/src/stories/assets/questionnaires/QButtonTester.ts +117 -0
- package/src/stories/storybookWrappers/IdRemoverButtonForStorybook.tsx +3 -5
- package/{lib/hooks/useInitialiseGroupTable.js → src/tests/removeId.test.ts} +11 -14
- package/src/tests/test-data/removeIdSample.ts +101 -0
- package/src/theme/Theme.tsx +0 -2
- package/src/utils/calculatedExpression.ts +4 -4
- package/src/utils/extractObservation.ts +1 -1
- package/src/utils/manageForm.ts +1 -1
- package/src/utils/openChoice.ts +3 -3
- package/src/utils/removeRepeatId.ts +113 -0
- package/src/utils/repeatId.ts +0 -96
- package/src/utils/repopulateItems.ts +8 -8
- package/lib/hooks/useInitialiseGroupTable.d.ts +0 -4
- package/lib/hooks/useInitialiseGroupTable.js.map +0 -1
- package/lib/hooks/useNumberInput.d.ts +0 -3
- package/lib/hooks/useNumberInput.js.map +0 -1
- package/lib/hooks/useRepeatGroups.d.ts +0 -4
- package/lib/hooks/useRepeatGroups.js +0 -38
- package/lib/hooks/useRepeatGroups.js.map +0 -1
- package/lib/hooks/useStringInput.d.ts +0 -3
- package/lib/hooks/useStringInput.js +0 -32
- package/lib/hooks/useStringInput.js.map +0 -1
- package/src/hooks/useNumberInput.ts +0 -38
- package/src/hooks/useRepeatGroups.ts +0 -51
- package/src/hooks/useStringInput.ts +0 -39
package/src/utils/repeatId.ts
CHANGED
|
@@ -16,12 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { nanoid } from 'nanoid';
|
|
19
|
-
import type {
|
|
20
|
-
QuestionnaireItem,
|
|
21
|
-
QuestionnaireResponseItem,
|
|
22
|
-
QuestionnaireResponseItemAnswer
|
|
23
|
-
} from 'fhir/r4';
|
|
24
|
-
import { getQrItemsIndex, mapQItemsIndex } from './mapItem';
|
|
25
19
|
|
|
26
20
|
export function generateNewRepeatId(linkId: string): string {
|
|
27
21
|
return `${linkId}-repeat-${nanoid()}`;
|
|
@@ -31,93 +25,3 @@ export function generateExistingRepeatId(linkId: string, index: number): string
|
|
|
31
25
|
const paddedIndex = index.toString().padStart(6, '0');
|
|
32
26
|
return `${linkId}-repeat-${paddedIndex}`;
|
|
33
27
|
}
|
|
34
|
-
|
|
35
|
-
export function removeInternalRepeatIdsRecursive(
|
|
36
|
-
qItem: QuestionnaireItem,
|
|
37
|
-
qrItemOrItems: QuestionnaireResponseItem | QuestionnaireResponseItem[] | null
|
|
38
|
-
): QuestionnaireResponseItem | QuestionnaireResponseItem[] | null {
|
|
39
|
-
// Process repeating group items separately
|
|
40
|
-
const hasMultipleAnswers = Array.isArray(qrItemOrItems);
|
|
41
|
-
if (hasMultipleAnswers) {
|
|
42
|
-
return removeInternalRepeatIdsFromRepeatGroup(qItem, qrItemOrItems);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// At this point qrItemOrItems is a single QuestionnaireResponseItem
|
|
46
|
-
const qrItem = qrItemOrItems;
|
|
47
|
-
|
|
48
|
-
// Process items with child items
|
|
49
|
-
const childQItems = qItem.item ?? [];
|
|
50
|
-
const childQrItems = qrItem?.item ?? [];
|
|
51
|
-
const updatedChildQrItems: QuestionnaireResponseItem[] = [];
|
|
52
|
-
if (childQItems.length > 0) {
|
|
53
|
-
const indexMap = mapQItemsIndex(qItem);
|
|
54
|
-
const qrItemsByIndex = getQrItemsIndex(childQItems, childQrItems, indexMap);
|
|
55
|
-
|
|
56
|
-
// Iterate child items
|
|
57
|
-
for (const [index, childQItem] of childQItems.entries()) {
|
|
58
|
-
const childQRItemOrItems = qrItemsByIndex[index];
|
|
59
|
-
|
|
60
|
-
const updatedChildQRItemOrItems = removeInternalRepeatIdsRecursive(
|
|
61
|
-
childQItem,
|
|
62
|
-
childQRItemOrItems ?? null
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
if (Array.isArray(updatedChildQRItemOrItems)) {
|
|
66
|
-
if (updatedChildQRItemOrItems.length > 0) {
|
|
67
|
-
updatedChildQrItems.push(...updatedChildQRItemOrItems);
|
|
68
|
-
}
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (updatedChildQRItemOrItems) {
|
|
73
|
-
updatedChildQrItems.push(updatedChildQRItemOrItems);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Construct updated qrItem
|
|
79
|
-
return removeInternalRepeatIdsFromItem(qItem, qrItem, updatedChildQrItems);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function removeInternalRepeatIdsFromRepeatGroup(
|
|
83
|
-
qItem: QuestionnaireItem,
|
|
84
|
-
qrItems: QuestionnaireResponseItem[]
|
|
85
|
-
) {
|
|
86
|
-
if (!qItem.item) {
|
|
87
|
-
return [];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return qrItems
|
|
91
|
-
.flatMap((childQrItem) => removeInternalRepeatIdsRecursive(qItem, childQrItem))
|
|
92
|
-
.filter((childQRItem): childQRItem is QuestionnaireResponseItem => !!childQRItem);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function removeInternalRepeatIdsFromItem(
|
|
96
|
-
qItem: QuestionnaireItem,
|
|
97
|
-
qrItem: QuestionnaireResponseItem | null,
|
|
98
|
-
childQrItems: QuestionnaireResponseItem[]
|
|
99
|
-
): QuestionnaireResponseItem | null {
|
|
100
|
-
if (!qrItem) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Remove internal repeatId from all answers
|
|
105
|
-
const updatedAnswers: QuestionnaireResponseItemAnswer[] =
|
|
106
|
-
qrItem.answer
|
|
107
|
-
?.map(
|
|
108
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
109
|
-
({ id, ...rest }) => {
|
|
110
|
-
return {
|
|
111
|
-
...rest
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
.filter((answer) => !!answer && Object.keys(answer).length > 0) ?? [];
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
linkId: qItem.linkId,
|
|
119
|
-
...(qItem.text && { text: qItem.text }),
|
|
120
|
-
...(childQrItems.length > 0 && { item: childQrItems }),
|
|
121
|
-
...(updatedAnswers.length > 0 && { answer: updatedAnswers })
|
|
122
|
-
};
|
|
123
|
-
}
|
|
@@ -22,9 +22,6 @@ import type {
|
|
|
22
22
|
QuestionnaireResponseItem
|
|
23
23
|
} from 'fhir/r4';
|
|
24
24
|
import type { Tabs } from '../interfaces/tab.interface';
|
|
25
|
-
import _isEqual from 'lodash/isEqual';
|
|
26
|
-
import _intersection from 'lodash/intersection';
|
|
27
|
-
import _difference from 'lodash/difference';
|
|
28
25
|
import { containsTabs, isTabContainer } from './tabs';
|
|
29
26
|
import { getShortText, isSpecificItemControl } from './itemControl';
|
|
30
27
|
import { getQrItemsIndex, mapQItemsIndex } from './mapItem';
|
|
@@ -34,6 +31,9 @@ import { questionnaireResponseStore, questionnaireStore } from '../stores';
|
|
|
34
31
|
import cloneDeep from 'lodash.clonedeep';
|
|
35
32
|
import { createQuestionnaireResponseItemMap } from './questionnaireResponseStoreUtils/updatableResponseItems';
|
|
36
33
|
import { getQuestionnaireItem, getSectionHeading } from './misc';
|
|
34
|
+
import difference from 'lodash.difference';
|
|
35
|
+
import intersection from 'lodash.intersection';
|
|
36
|
+
import isEqual from 'lodash.isequal';
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* ItemToRepopulate interface
|
|
@@ -99,11 +99,11 @@ export function generateItemsToRepopulate(populatedResponse: QuestionnaireRespon
|
|
|
99
99
|
// Get linkIds that are different between current QRItems and populated QRItems
|
|
100
100
|
// Doesn't work with repeat groups, but at the same time I'm not sure if it's needed, given you can't delete completely the first repeat group
|
|
101
101
|
const populatedResponseItemMap = createQuestionnaireResponseItemMap(populatedResponse);
|
|
102
|
-
const diffLinkIds =
|
|
102
|
+
const diffLinkIds = difference(
|
|
103
103
|
Object.keys(updatableResponseItems),
|
|
104
104
|
Object.keys(populatedResponseItemMap)
|
|
105
105
|
);
|
|
106
|
-
const diffLinkIdsWithInitialExpressions =
|
|
106
|
+
const diffLinkIdsWithInitialExpressions = intersection(
|
|
107
107
|
Object.keys(initialExpressions),
|
|
108
108
|
diffLinkIds
|
|
109
109
|
);
|
|
@@ -468,7 +468,7 @@ function retrieveSingleOldQRItem(
|
|
|
468
468
|
return;
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
if (
|
|
471
|
+
if (isEqual(oldQRItem, newQRItem)) {
|
|
472
472
|
delete itemsToRepopulate[qItem.linkId];
|
|
473
473
|
return;
|
|
474
474
|
}
|
|
@@ -490,7 +490,7 @@ function retrieveRepeatGroupOldQRItems(
|
|
|
490
490
|
return;
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
-
if (
|
|
493
|
+
if (isEqual(oldQRItems, newQRItems)) {
|
|
494
494
|
delete itemsToRepopulate[qItem.linkId];
|
|
495
495
|
return;
|
|
496
496
|
}
|
|
@@ -535,7 +535,7 @@ function retrieveGridGroupOldQRItems(
|
|
|
535
535
|
continue;
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
-
if (
|
|
538
|
+
if (isEqual(oldGridChildQrItem, newGridChildQRItem)) {
|
|
539
539
|
newGridChildQRItemMap.delete(gridChildQItem.linkId);
|
|
540
540
|
} else {
|
|
541
541
|
oldGridChildQRItems.push(oldGridChildQrItem);
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { QuestionnaireResponseItem } from 'fhir/r4';
|
|
2
|
-
import type { GroupTableRowModel } from '../interfaces/groupTable.interface';
|
|
3
|
-
declare function useInitialiseGroupTable(linkId: string, qrItems: QuestionnaireResponseItem[]): GroupTableRowModel[];
|
|
4
|
-
export default useInitialiseGroupTable;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInitialiseGroupTable.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseGroupTable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAElF,SAAS,uBAAuB,CAC9B,MAAc,EACd,OAAoC;IAEpC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,CAAC,EAAE,EAAE,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;KAC5D;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACnC,OAAO;YACL,EAAE,EAAE,wBAAwB,CAAC,MAAM,EAAE,KAAK,CAAC;YAC3C,MAAM;SACP,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useNumberInput.js","sourceRoot":"","sources":["../../src/hooks/useNumberInput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,SAAS,cAAc,CAAC,cAAsB;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEnD,SAAS,CACP,GAAG,EAAE;QACH,IAAI,KAAK,KAAK,cAAc,EAAE;YAC5B,QAAQ,CAAC,cAAc,CAAC,CAAC;SAC1B;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
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;
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
|
23
|
-
.map((repeatGroupSingle) => repeatGroupSingle.qrItem)
|
|
24
|
-
.filter((qrItem) => qrItem !== null);
|
|
25
|
-
const repeatGroupsQRItems = repeatGroups
|
|
26
|
-
.map((repeatGroupSingle) => repeatGroupSingle.qrItem)
|
|
27
|
-
.filter((qrItem) => qrItem !== null);
|
|
28
|
-
if (!_isEqual(valueFromPropsQRItems, repeatGroupsQRItems)) {
|
|
29
|
-
setRepeatGroups(valueFromProps);
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
// Only trigger this effect if prop value changes
|
|
33
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
-
[valueFromProps]);
|
|
35
|
-
return [repeatGroups, setRepeatGroups];
|
|
36
|
-
}
|
|
37
|
-
export default useRepeatGroups;
|
|
38
|
-
//# sourceMappingURL=useRepeatGroups.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAGtC,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;aACzC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC;aACpD,MAAM,CAAC,CAAC,MAAM,EAAuC,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;QAE5E,MAAM,mBAAmB,GAAG,YAAY;aACrC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC;aACpD,MAAM,CAAC,CAAC,MAAM,EAAuC,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;QAE5E,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"}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
// The purpose of this hook to sync the string state from external changes i.e. re-population changes etc.
|
|
19
|
-
function useStringInput(valueFromProps) {
|
|
20
|
-
const [input, setInput] = useState(valueFromProps);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (input !== valueFromProps) {
|
|
23
|
-
setInput(valueFromProps);
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
// Only trigger this effect if prop value changes
|
|
27
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
-
[valueFromProps]);
|
|
29
|
-
return [input, setInput];
|
|
30
|
-
}
|
|
31
|
-
export default useStringInput;
|
|
32
|
-
//# sourceMappingURL=useStringInput.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useStringInput.js","sourceRoot":"","sources":["../../src/hooks/useStringInput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,0GAA0G;AAC1G,SAAS,cAAc,CAAC,cAAsB;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAEnD,SAAS,CACP,GAAG,EAAE;QACH,IAAI,KAAK,KAAK,cAAc,EAAE;YAC5B,QAAQ,CAAC,cAAc,CAAC,CAAC;SAC1B;IACH,CAAC;IACD,iDAAiD;IACjD,uDAAuD;IACvD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
|
|
21
|
-
function useNumberInput(valueFromProps: number): [number, Dispatch<SetStateAction<number>>] {
|
|
22
|
-
const [value, setValue] = useState(valueFromProps);
|
|
23
|
-
|
|
24
|
-
useEffect(
|
|
25
|
-
() => {
|
|
26
|
-
if (value !== valueFromProps) {
|
|
27
|
-
setValue(valueFromProps);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
// Only trigger this effect if prop value changes
|
|
31
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
-
[valueFromProps]
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
return [value, setValue];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default useNumberInput;
|
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
import type { QuestionnaireResponseItem } from 'fhir/r4';
|
|
23
|
-
|
|
24
|
-
function useRepeatGroups(
|
|
25
|
-
valueFromProps: RepeatGroupSingle[]
|
|
26
|
-
): [RepeatGroupSingle[], Dispatch<SetStateAction<RepeatGroupSingle[]>>] {
|
|
27
|
-
const [repeatGroups, setRepeatGroups] = useState(valueFromProps);
|
|
28
|
-
|
|
29
|
-
useEffect(
|
|
30
|
-
() => {
|
|
31
|
-
const valueFromPropsQRItems = valueFromProps
|
|
32
|
-
.map((repeatGroupSingle) => repeatGroupSingle.qrItem)
|
|
33
|
-
.filter((qrItem): qrItem is QuestionnaireResponseItem => qrItem !== null);
|
|
34
|
-
|
|
35
|
-
const repeatGroupsQRItems = repeatGroups
|
|
36
|
-
.map((repeatGroupSingle) => repeatGroupSingle.qrItem)
|
|
37
|
-
.filter((qrItem): qrItem is QuestionnaireResponseItem => qrItem !== null);
|
|
38
|
-
|
|
39
|
-
if (!_isEqual(valueFromPropsQRItems, repeatGroupsQRItems)) {
|
|
40
|
-
setRepeatGroups(valueFromProps);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
// Only trigger this effect if prop value changes
|
|
44
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
-
[valueFromProps]
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
return [repeatGroups, setRepeatGroups];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default useRepeatGroups;
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
|
|
21
|
-
// The purpose of this hook to sync the string state from external changes i.e. re-population changes etc.
|
|
22
|
-
function useStringInput(valueFromProps: string): [string, Dispatch<SetStateAction<string>>] {
|
|
23
|
-
const [input, setInput] = useState(valueFromProps);
|
|
24
|
-
|
|
25
|
-
useEffect(
|
|
26
|
-
() => {
|
|
27
|
-
if (input !== valueFromProps) {
|
|
28
|
-
setInput(valueFromProps);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
// Only trigger this effect if prop value changes
|
|
32
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
-
[valueFromProps]
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return [input, setInput];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default useStringInput;
|