@aehrc/smart-forms-renderer 0.10.0 → 0.10.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/Tables/GroupTable.js +24 -13
- package/lib/components/FormComponents/Tables/GroupTable.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTableBody.d.ts +3 -3
- package/lib/components/FormComponents/Tables/GroupTableBody.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTableRow.d.ts +2 -2
- package/lib/components/FormComponents/Tables/GroupTableRowCells.d.ts +1 -2
- package/lib/components/FormComponents/Tables/GroupTableRowCells.js +1 -12
- package/lib/components/FormComponents/Tables/GroupTableRowCells.js.map +1 -1
- package/lib/components/FormComponents/Tables/GroupTableView.d.ts +3 -3
- package/lib/hooks/useGroupTableRows.d.ts +9 -0
- package/lib/hooks/useGroupTableRows.js +26 -0
- package/lib/hooks/useGroupTableRows.js.map +1 -0
- package/lib/hooks/useInitialiseRenderer.js +2 -1
- package/lib/hooks/useInitialiseRenderer.js.map +1 -1
- package/lib/stores/selector.d.ts +1 -1
- package/lib/stores/selector.js.map +1 -1
- package/lib/stories/MedicalHistoryTable.stories.js +1 -5
- package/lib/utils/groupTable.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/FormComponents/Tables/GroupTable.tsx +12 -17
- package/src/components/FormComponents/Tables/GroupTableBody.tsx +5 -4
- package/src/components/FormComponents/Tables/GroupTableRow.tsx +2 -2
- package/src/components/FormComponents/Tables/GroupTableRowCells.tsx +2 -5
- package/src/components/FormComponents/Tables/GroupTableView.tsx +3 -3
- package/src/hooks/useGroupTableRows.ts +33 -0
- package/src/hooks/useInitialiseRenderer.ts +2 -1
- package/src/stores/selector.ts +2 -1
- package/src/stories/MedicalHistoryTable.stories.tsx +2 -6
- package/src/utils/groupTable.ts +1 -1
|
@@ -14,20 +14,27 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
import React, { useMemo } from 'react';
|
|
18
27
|
import { mapQItemsIndex } from '../../../utils/mapItem';
|
|
19
|
-
import useInitialiseGroupTable from '../../../hooks/useInitialiseGroupTable';
|
|
20
28
|
import { nanoid } from 'nanoid';
|
|
21
29
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
22
30
|
import GroupTableView from './GroupTableView';
|
|
23
31
|
import { getGroupTableItemsToUpdate } from '../../../utils/groupTable';
|
|
32
|
+
import useGroupTableRows from '../../../hooks/useGroupTableRows';
|
|
33
|
+
import { flushSync } from 'react-dom';
|
|
24
34
|
function GroupTable(props) {
|
|
25
35
|
const { qItem, qrItems, groupCardElevation, showMinimalView, parentIsReadOnly, onQrRepeatGroupChange } = props;
|
|
26
|
-
// TODO come back to fix stuttering on dnd update
|
|
27
36
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
28
|
-
const
|
|
29
|
-
const [tableRows, setTableRows] = useState(initialisedGroupTables);
|
|
30
|
-
const [selectedIds, setSelectedIds] = useState(initialisedGroupTables.map((row) => row.nanoId));
|
|
37
|
+
const { tableRows, selectedIds, setTableRows, setSelectedIds } = useGroupTableRows(qrItems);
|
|
31
38
|
// Generate item labels as table headers
|
|
32
39
|
const qItems = qItem.item;
|
|
33
40
|
const itemLabels = useMemo(() => { var _a; return (_a = qItems === null || qItems === void 0 ? void 0 : qItems.map((item) => { var _a; return (_a = item.text) !== null && _a !== void 0 ? _a : ''; })) !== null && _a !== void 0 ? _a : []; }, [qItems]);
|
|
@@ -54,12 +61,14 @@ function GroupTable(props) {
|
|
|
54
61
|
}
|
|
55
62
|
function handleRemoveRow(index) {
|
|
56
63
|
const updatedTableRows = [...tableRows];
|
|
64
|
+
const rowToRemove = updatedTableRows[index];
|
|
57
65
|
updatedTableRows.splice(index, 1);
|
|
58
66
|
setTableRows(updatedTableRows);
|
|
59
67
|
onQrRepeatGroupChange({
|
|
60
68
|
linkId: qItem.linkId,
|
|
61
69
|
qrItems: getGroupTableItemsToUpdate(updatedTableRows, selectedIds)
|
|
62
70
|
});
|
|
71
|
+
setSelectedIds(selectedIds.filter((id) => id !== rowToRemove.nanoId));
|
|
63
72
|
}
|
|
64
73
|
function handleAddRow() {
|
|
65
74
|
const newRowNanoId = nanoid();
|
|
@@ -96,14 +105,16 @@ function GroupTable(props) {
|
|
|
96
105
|
qrItems: getGroupTableItemsToUpdate(tableRows, updatedSelectedIds)
|
|
97
106
|
});
|
|
98
107
|
}
|
|
99
|
-
// TODO fix error message
|
|
100
|
-
// TODO add swc
|
|
101
|
-
// TODO add listener
|
|
102
108
|
function handleReorderRows(newTableRows) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
// Prevent state batching when reordering to prevent view stuttering https://react.dev/reference/react-dom/flushSync
|
|
111
|
+
flushSync(() => {
|
|
112
|
+
setTableRows(newTableRows);
|
|
113
|
+
});
|
|
114
|
+
onQrRepeatGroupChange({
|
|
115
|
+
linkId: qItem.linkId,
|
|
116
|
+
qrItems: getGroupTableItemsToUpdate(newTableRows, selectedIds)
|
|
117
|
+
});
|
|
107
118
|
});
|
|
108
119
|
}
|
|
109
120
|
return (React.createElement(GroupTableView, { qItem: qItem, qItemsIndexMap: qItemsIndexMap, groupCardElevation: groupCardElevation, readOnly: readOnly, tableRows: tableRows, selectedIds: selectedIds, itemLabels: itemLabels, showMinimalView: showMinimalView, parentIsReadOnly: parentIsReadOnly, onAddRow: handleAddRow, onRowChange: handleRowChange, onRemoveRow: handleRemoveRow, onSelectRow: handleSelectRow, onSelectAll: handleSelectAll, onReorderRows: handleReorderRows }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupTable.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/Tables/GroupTable.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG
|
|
1
|
+
{"version":3,"file":"GroupTable.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/Tables/GroupTable.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;AAEH,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAMxD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAWtC,SAAS,UAAU,CAAC,KAAsB;IACxC,MAAM,EACJ,KAAK,EACL,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACtB,GAAG,KAAK,CAAC;IAEV,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IAEtD,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAE5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AAM,CAAC,CAAC;SACjC;aAAM;YACL,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SACrC;QAED,cAAc,CAAC,kBAAkB,CAAC,CAAC;QACnC,qBAAqB,CAAC;YACpB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,OAAO,EAAE,0BAA0B,CAAC,SAAS,EAAE,kBAAkB,CAAC;SACnE,CAAC,CAAC;IACL,CAAC;IAED,SAAe,iBAAiB,CAAC,YAAkC;;YACjE,oHAAoH;YACpH,SAAS,CAAC,GAAG,EAAE;gBACb,YAAY,CAAC,YAAY,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;YACH,qBAAqB,CAAC;gBACpB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,OAAO,EAAE,0BAA0B,CAAC,YAAY,EAAE,WAAW,CAAC;aAC/D,CAAC,CAAC;QACL,CAAC;KAAA;IAED,OAAO,CACL,oBAAC,cAAc,IACb,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,eAAe,EAC5B,aAAa,EAAE,iBAAiB,GAChC,CACH,CAAC;AACJ,CAAC;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
3
|
-
import { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
4
|
-
import { PropsWithParentIsReadOnlyAttribute, PropsWithShowMinimalViewAttribute } from '../../../interfaces/renderProps.interface';
|
|
2
|
+
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
3
|
+
import type { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
4
|
+
import type { PropsWithParentIsReadOnlyAttribute, PropsWithShowMinimalViewAttribute } from '../../../interfaces/renderProps.interface';
|
|
5
5
|
interface GroupTableBodyProps extends PropsWithParentIsReadOnlyAttribute, PropsWithShowMinimalViewAttribute {
|
|
6
6
|
tableQItem: QuestionnaireItem;
|
|
7
7
|
readOnly: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupTableBody.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/Tables/GroupTableBody.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO1D,OAAO,aAAa,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"GroupTableBody.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/Tables/GroupTableBody.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO1D,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAgBhD,SAAS,cAAc,CAAC,KAA0B;IAChD,MAAM,EACJ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,EACd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EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,GACxB,CACH,CAAC;YACJ,CAAC,CAAC;YACD,iBAAiB,CAAC,WAAW,CACpB,CACb,CACS,CACI,CACnB,CAAC;AACJ,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
3
3
|
import type { PropsWithParentIsReadOnlyAttribute, PropsWithShowMinimalViewAttribute } from '../../../interfaces/renderProps.interface';
|
|
4
|
-
import { TableRowProps } from '@mui/material/TableRow';
|
|
5
|
-
import { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
4
|
+
import type { TableRowProps } from '@mui/material/TableRow';
|
|
5
|
+
import type { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
6
6
|
interface GroupTableRowProps extends PropsWithShowMinimalViewAttribute, PropsWithParentIsReadOnlyAttribute, TableRowProps {
|
|
7
7
|
nanoId: string;
|
|
8
8
|
index: number;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
3
3
|
import type { PropsWithParentIsReadOnlyAttribute, PropsWithQrItemChangeHandler } from '../../../interfaces/renderProps.interface';
|
|
4
|
-
|
|
5
|
-
interface GroupTableRowCellsProps extends PropsWithQrItemChangeHandler, PropsWithParentIsReadOnlyAttribute, TableRowProps {
|
|
4
|
+
interface GroupTableRowCellsProps extends PropsWithQrItemChangeHandler, PropsWithParentIsReadOnlyAttribute {
|
|
6
5
|
qItem: QuestionnaireItem;
|
|
7
6
|
qrItem: QuestionnaireResponseItem | null;
|
|
8
7
|
qItemsIndexMap: Record<string, number>;
|
|
@@ -14,24 +14,13 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
18
|
-
var t = {};
|
|
19
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
20
|
-
t[p] = s[p];
|
|
21
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
22
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
23
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24
|
-
t[p[i]] = s[p[i]];
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
27
|
-
};
|
|
28
17
|
import React from 'react';
|
|
29
18
|
import { createEmptyQrGroup, updateQrItemsInGroup } from '../../../utils/qrItem';
|
|
30
19
|
import SingleItem from '../SingleItem/SingleItem';
|
|
31
20
|
import { getQrItemsIndex } from '../../../utils/mapItem';
|
|
32
21
|
import { StandardTableCell } from './Table.styles';
|
|
33
22
|
function GroupTableRowCells(props) {
|
|
34
|
-
const { qItem, qrItem, qItemsIndexMap, parentIsReadOnly, onQrItemChange } = props
|
|
23
|
+
const { qItem, qrItem, qItemsIndexMap, parentIsReadOnly, onQrItemChange } = props;
|
|
35
24
|
const rowItems = qItem.item;
|
|
36
25
|
const row = qrItem && qrItem.item ? qrItem : createEmptyQrGroup(qItem);
|
|
37
26
|
const rowQrItems = row.item;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupTableRowCells.js","sourceRoot":"","sources":["../../../../src/components/FormComponents/Tables/GroupTableRowCells.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG
|
|
1
|
+
{"version":3,"file":"GroupTableRowCells.js","sourceRoot":"","s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M,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC;SACb;QAED,OAAO,CACL,oBAAC,iBAAiB,IAAC,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,KAAK,CAAC;YAChF,oBAAC,UAAU,IACT,GAAG,EAAE,KAAK,CAAC,MAAM,EACjB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,IAAI,EACtB,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,eAAe,EAAE,IAAI,EACrB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,qBAAqB,GACrC,CACgB,CACrB,CAAC;IACJ,CAAC,CAAC,CACD,CACJ,CAAC;AACJ,CAAC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
3
|
-
import { PropsWithParentIsReadOnlyAttribute, PropsWithShowMinimalViewAttribute } from '../../../interfaces/renderProps.interface';
|
|
4
|
-
import { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
2
|
+
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
3
|
+
import type { PropsWithParentIsReadOnlyAttribute, PropsWithShowMinimalViewAttribute } from '../../../interfaces/renderProps.interface';
|
|
4
|
+
import type { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
5
5
|
interface GroupTableViewProps extends PropsWithShowMinimalViewAttribute, PropsWithParentIsReadOnlyAttribute {
|
|
6
6
|
qItem: QuestionnaireItem;
|
|
7
7
|
qItemsIndexMap: Record<string, number>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { QuestionnaireResponseItem } from 'fhir/r4';
|
|
3
|
+
declare function useGroupTableRows(qrItems: QuestionnaireResponseItem[]): {
|
|
4
|
+
tableRows: import("../interfaces/groupTable.interface").GroupTableRowModel[];
|
|
5
|
+
selectedIds: string[];
|
|
6
|
+
setTableRows: import("react").Dispatch<import("react").SetStateAction<import("../interfaces/groupTable.interface").GroupTableRowModel[]>>;
|
|
7
|
+
setSelectedIds: import("react").Dispatch<import("react").SetStateAction<string[]>>;
|
|
8
|
+
};
|
|
9
|
+
export default useGroupTableRows;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { useState } from 'react';
|
|
18
|
+
import useInitialiseGroupTable from './useInitialiseGroupTable';
|
|
19
|
+
function useGroupTableRows(qrItems) {
|
|
20
|
+
const initialisedGroupTableRows = useInitialiseGroupTable(qrItems);
|
|
21
|
+
const [tableRows, setTableRows] = useState(initialisedGroupTableRows);
|
|
22
|
+
const [selectedIds, setSelectedIds] = useState(initialisedGroupTableRows.map((row) => row.nanoId));
|
|
23
|
+
return { tableRows, selectedIds, setTableRows, setSelectedIds };
|
|
24
|
+
}
|
|
25
|
+
export default useGroupTableRows;
|
|
26
|
+
//# sourceMappingURL=useGroupTableRows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGroupTableRows.js","sourceRoot":"","sources":["../../src/hooks/useGroupTableRows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAGhE,SAAS,iBAAiB,CAAC,OAAoC;IAC7D,MAAM,yBAAyB,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAEnE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IACtE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAC5C,yBAAyB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CACnD,CAAC;IAEF,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAClE,CAAC;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitialiseRenderer.js","sourceRoot":"","sources":["../../src/hooks/useInitialiseRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,WAAW,CAAC;AAEnB,SAAS,qBAAqB,CAC5B,aAA4B,EAC5B,qBAA6C,EAC7C,mBAA4C,EAC5C,oBAA6B,EAC7B,UAAmB;IAEnB,MAAM,wBAAwB,GAAG,qBAAqB,CAAC,GAAG,CAAC,wBAAwB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C;YACH,aAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;gBAC3C,YAAY,CAAC,SAAS,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;SACJ;QAED,gFAAgF;QAChF,IAAI,oBAAoB,EAAE;YACxB,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;SAC/C;aAAM;YACL,yBAAyB,EAAE,CAAC;SAC7B;QAED,mJAAmJ;QACnJ,wBAAwB,CACtB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,CACrB,CAAC,IAAI,CAAC,GAAG,EAAE;YACV,mBAAmB,CAAC,gCAAgC,CAAC,aAAa,CAAC,CAAC,CAAC;YAErE,IAAI,qBAAqB,EAAE;gBACzB,MAAM,eAAe,GAAG,yBAAyB,CAAC,qBAAqB,CAAC,CAAC;gBACzE,+BAA+B,CAAC,eAAe,CAAC,CAAC;aAClD;YACD,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,EAAE;QACD,aAAa;QACb,qBAAqB;QACrB,wBAAwB;QACxB,mBAAmB;QACnB,+BAA+B;QAC/B,yBAAyB;QACzB,mBAAmB;QACnB,UAAU;QACV,cAAc;QACd,UAAU;QACV,OAAO;QACP,YAAY;QACZ,oBAAoB;QACpB,uBAAuB;QACvB,yBAAyB;KAC1B,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,eAAe,qBAAqB,CAAC"}
|
package/lib/stores/selector.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selector.js","sourceRoot":"","sources":["../../src/stores/selector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"selector.js","sourceRoot":"","sources":["../../src/stores/selector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMnC,MAAM,CAAC,MAAM,eAAe,GAAG,CAA6B,MAAS,EAAE,EAAE;IACvE,MAAM,KAAK,GAAG,MAAsC,CAAC;IACrD,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;IACf,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,EAAE;QAC7C,sDAAsD;QACrD,KAAK,CAAC,GAAW,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAmB,CAAC,CAAC,CAAC;KAC/E;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -18,8 +18,6 @@ import { GroupTable } from '../components';
|
|
|
18
18
|
import GTableMedicalHistoryItemJson from './assets/QItems-and-QRItems/Q_GTableMedicalHistory.json';
|
|
19
19
|
import GTableMedicalHistoryAnswersJson from './assets/QItems-and-QRItems/QR_GTableMedicalHistory.json';
|
|
20
20
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
21
|
-
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
22
|
-
import { DndProvider } from 'react-dnd';
|
|
23
21
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
24
22
|
const meta = {
|
|
25
23
|
title: 'Component/GroupTable',
|
|
@@ -29,9 +27,7 @@ const meta = {
|
|
|
29
27
|
decorators: [
|
|
30
28
|
(Story)=>/*#__PURE__*/ React.createElement(ThemeProvider, null, /*#__PURE__*/ React.createElement(QueryClientProvider, {
|
|
31
29
|
client: new QueryClient()
|
|
32
|
-
},
|
|
33
|
-
backend: HTML5Backend
|
|
34
|
-
}, Story())))
|
|
30
|
+
}, Story()))
|
|
35
31
|
]
|
|
36
32
|
};
|
|
37
33
|
const GTableMedicalHistoryItem = GTableMedicalHistoryItemJson;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { GroupTableRowModel } from '../interfaces/groupTable.interface';
|
|
1
|
+
import type { GroupTableRowModel } from '../interfaces/groupTable.interface';
|
|
2
2
|
export declare function reorderRows(rows: GroupTableRowModel[], sourceIndex: number, destinationIndex: number): GroupTableRowModel[];
|
|
3
3
|
export declare function getGroupTableItemsToUpdate(tableRows: GroupTableRowModel[], selectedIds: string[]): import("fhir/r4").QuestionnaireResponseItem[];
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import React, { useMemo
|
|
18
|
+
import React, { useMemo } from 'react';
|
|
19
19
|
|
|
20
20
|
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
21
21
|
import { mapQItemsIndex } from '../../../utils/mapItem';
|
|
@@ -24,12 +24,13 @@ import type {
|
|
|
24
24
|
PropsWithQrRepeatGroupChangeHandler,
|
|
25
25
|
PropsWithShowMinimalViewAttribute
|
|
26
26
|
} from '../../../interfaces/renderProps.interface';
|
|
27
|
-
import useInitialiseGroupTable from '../../../hooks/useInitialiseGroupTable';
|
|
28
27
|
import { nanoid } from 'nanoid';
|
|
29
28
|
import useReadOnly from '../../../hooks/useReadOnly';
|
|
30
29
|
import GroupTableView from './GroupTableView';
|
|
31
|
-
import { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
30
|
+
import type { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
32
31
|
import { getGroupTableItemsToUpdate } from '../../../utils/groupTable';
|
|
32
|
+
import useGroupTableRows from '../../../hooks/useGroupTableRows';
|
|
33
|
+
import { flushSync } from 'react-dom';
|
|
33
34
|
|
|
34
35
|
interface GroupTableProps
|
|
35
36
|
extends PropsWithQrRepeatGroupChangeHandler,
|
|
@@ -50,16 +51,9 @@ function GroupTable(props: GroupTableProps) {
|
|
|
50
51
|
onQrRepeatGroupChange
|
|
51
52
|
} = props;
|
|
52
53
|
|
|
53
|
-
// TODO come back to fix stuttering on dnd update
|
|
54
|
-
|
|
55
54
|
const readOnly = useReadOnly(qItem, parentIsReadOnly);
|
|
56
55
|
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const [tableRows, setTableRows] = useState(initialisedGroupTables);
|
|
60
|
-
const [selectedIds, setSelectedIds] = useState<string[]>(
|
|
61
|
-
initialisedGroupTables.map((row) => row.nanoId)
|
|
62
|
-
);
|
|
56
|
+
const { tableRows, selectedIds, setTableRows, setSelectedIds } = useGroupTableRows(qrItems);
|
|
63
57
|
|
|
64
58
|
// Generate item labels as table headers
|
|
65
59
|
const qItems = qItem.item;
|
|
@@ -96,6 +90,7 @@ function GroupTable(props: GroupTableProps) {
|
|
|
96
90
|
|
|
97
91
|
function handleRemoveRow(index: number) {
|
|
98
92
|
const updatedTableRows = [...tableRows];
|
|
93
|
+
const rowToRemove = updatedTableRows[index];
|
|
99
94
|
|
|
100
95
|
updatedTableRows.splice(index, 1);
|
|
101
96
|
|
|
@@ -104,6 +99,7 @@ function GroupTable(props: GroupTableProps) {
|
|
|
104
99
|
linkId: qItem.linkId,
|
|
105
100
|
qrItems: getGroupTableItemsToUpdate(updatedTableRows, selectedIds)
|
|
106
101
|
});
|
|
102
|
+
setSelectedIds(selectedIds.filter((id) => id !== rowToRemove.nanoId));
|
|
107
103
|
}
|
|
108
104
|
|
|
109
105
|
function handleAddRow() {
|
|
@@ -146,12 +142,11 @@ function GroupTable(props: GroupTableProps) {
|
|
|
146
142
|
});
|
|
147
143
|
}
|
|
148
144
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
setTableRows(newTableRows);
|
|
145
|
+
async function handleReorderRows(newTableRows: GroupTableRowModel[]) {
|
|
146
|
+
// Prevent state batching when reordering to prevent view stuttering https://react.dev/reference/react-dom/flushSync
|
|
147
|
+
flushSync(() => {
|
|
148
|
+
setTableRows(newTableRows);
|
|
149
|
+
});
|
|
155
150
|
onQrRepeatGroupChange({
|
|
156
151
|
linkId: qItem.linkId,
|
|
157
152
|
qrItems: getGroupTableItemsToUpdate(newTableRows, selectedIds)
|
|
@@ -17,14 +17,15 @@
|
|
|
17
17
|
|
|
18
18
|
import React from 'react';
|
|
19
19
|
import { createEmptyQrItem } from '../../../utils/qrItem';
|
|
20
|
-
import { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
21
|
-
import { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
22
|
-
import {
|
|
20
|
+
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
21
|
+
import type { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
22
|
+
import type {
|
|
23
23
|
PropsWithParentIsReadOnlyAttribute,
|
|
24
24
|
PropsWithShowMinimalViewAttribute
|
|
25
25
|
} from '../../../interfaces/renderProps.interface';
|
|
26
26
|
import GroupTableRow from './GroupTableRow';
|
|
27
|
-
import {
|
|
27
|
+
import type { DropResult } from 'react-beautiful-dnd';
|
|
28
|
+
import { DragDropContext, Droppable } from 'react-beautiful-dnd';
|
|
28
29
|
import { reorderRows } from '../../../utils/groupTable';
|
|
29
30
|
import TableBody from '@mui/material/TableBody';
|
|
30
31
|
|
|
@@ -21,11 +21,11 @@ import type {
|
|
|
21
21
|
PropsWithParentIsReadOnlyAttribute,
|
|
22
22
|
PropsWithShowMinimalViewAttribute
|
|
23
23
|
} from '../../../interfaces/renderProps.interface';
|
|
24
|
-
import { TableRowProps } from '@mui/material/TableRow';
|
|
24
|
+
import type { TableRowProps } from '@mui/material/TableRow';
|
|
25
25
|
import SelectRowButton from './SelectRowButton';
|
|
26
26
|
import GroupTableRowCells from './GroupTableRowCells';
|
|
27
27
|
import RemoveRowButton from './RemoveRowButton';
|
|
28
|
-
import { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
28
|
+
import type { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
29
29
|
import DragIndicator from '@mui/icons-material/DragIndicator';
|
|
30
30
|
import TableCell from '@mui/material/TableCell';
|
|
31
31
|
import Box from '@mui/material/Box';
|
|
@@ -25,20 +25,17 @@ import type {
|
|
|
25
25
|
PropsWithParentIsReadOnlyAttribute,
|
|
26
26
|
PropsWithQrItemChangeHandler
|
|
27
27
|
} from '../../../interfaces/renderProps.interface';
|
|
28
|
-
import { TableRowProps } from '@mui/material/TableRow';
|
|
29
28
|
|
|
30
29
|
interface GroupTableRowCellsProps
|
|
31
30
|
extends PropsWithQrItemChangeHandler,
|
|
32
|
-
PropsWithParentIsReadOnlyAttribute
|
|
33
|
-
TableRowProps {
|
|
31
|
+
PropsWithParentIsReadOnlyAttribute {
|
|
34
32
|
qItem: QuestionnaireItem;
|
|
35
33
|
qrItem: QuestionnaireResponseItem | null;
|
|
36
34
|
qItemsIndexMap: Record<string, number>;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
function GroupTableRowCells(props: GroupTableRowCellsProps) {
|
|
40
|
-
const { qItem, qrItem, qItemsIndexMap, parentIsReadOnly, onQrItemChange
|
|
41
|
-
props;
|
|
38
|
+
const { qItem, qrItem, qItemsIndexMap, parentIsReadOnly, onQrItemChange } = props;
|
|
42
39
|
|
|
43
40
|
const rowItems = qItem.item;
|
|
44
41
|
const row = qrItem && qrItem.item ? qrItem : createEmptyQrGroup(qItem);
|
|
@@ -29,12 +29,12 @@ import Typography from '@mui/material/Typography';
|
|
|
29
29
|
import LabelWrapper from '../ItemParts/ItemLabelWrapper';
|
|
30
30
|
import Divider from '@mui/material/Divider';
|
|
31
31
|
import AddRowButton from './AddRowButton';
|
|
32
|
-
import { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
33
|
-
import {
|
|
32
|
+
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
33
|
+
import type {
|
|
34
34
|
PropsWithParentIsReadOnlyAttribute,
|
|
35
35
|
PropsWithShowMinimalViewAttribute
|
|
36
36
|
} from '../../../interfaces/renderProps.interface';
|
|
37
|
-
import { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
37
|
+
import type { GroupTableRowModel } from '../../../interfaces/groupTable.interface';
|
|
38
38
|
import GroupTableBody from './GroupTableBody';
|
|
39
39
|
import Checkbox from '@mui/material/Checkbox';
|
|
40
40
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Commonwealth Scientific and Industrial Research
|
|
3
|
+
* Organisation (CSIRO) ABN 41 687 119 230.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { useState } from 'react';
|
|
19
|
+
import useInitialiseGroupTable from './useInitialiseGroupTable';
|
|
20
|
+
import type { QuestionnaireResponseItem } from 'fhir/r4';
|
|
21
|
+
|
|
22
|
+
function useGroupTableRows(qrItems: QuestionnaireResponseItem[]) {
|
|
23
|
+
const initialisedGroupTableRows = useInitialiseGroupTable(qrItems);
|
|
24
|
+
|
|
25
|
+
const [tableRows, setTableRows] = useState(initialisedGroupTableRows);
|
|
26
|
+
const [selectedIds, setSelectedIds] = useState<string[]>(
|
|
27
|
+
initialisedGroupTableRows.map((row) => row.nanoId)
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return { tableRows, selectedIds, setTableRows, setSelectedIds };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default useGroupTableRows;
|
package/src/stores/selector.ts
CHANGED
|
@@ -20,10 +20,8 @@ import type { Meta, StoryObj } from '@storybook/react';
|
|
|
20
20
|
import { GroupTable } from '../components';
|
|
21
21
|
import GTableMedicalHistoryItemJson from './assets/QItems-and-QRItems/Q_GTableMedicalHistory.json';
|
|
22
22
|
import GTableMedicalHistoryAnswersJson from './assets/QItems-and-QRItems/QR_GTableMedicalHistory.json';
|
|
23
|
-
import { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
23
|
+
import type { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4';
|
|
24
24
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
25
|
-
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
26
|
-
import { DndProvider } from 'react-dnd';
|
|
27
25
|
|
|
28
26
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
29
27
|
const meta = {
|
|
@@ -34,9 +32,7 @@ const meta = {
|
|
|
34
32
|
decorators: [
|
|
35
33
|
(Story) => (
|
|
36
34
|
<ThemeProvider>
|
|
37
|
-
<QueryClientProvider client={new QueryClient()}>
|
|
38
|
-
<DndProvider backend={HTML5Backend}>{Story()}</DndProvider>
|
|
39
|
-
</QueryClientProvider>
|
|
35
|
+
<QueryClientProvider client={new QueryClient()}>{Story()}</QueryClientProvider>
|
|
40
36
|
</ThemeProvider>
|
|
41
37
|
)
|
|
42
38
|
]
|
package/src/utils/groupTable.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { GroupTableRowModel } from '../interfaces/groupTable.interface';
|
|
18
|
+
import type { GroupTableRowModel } from '../interfaces/groupTable.interface';
|
|
19
19
|
import cloneDeep from 'lodash.clonedeep';
|
|
20
20
|
|
|
21
21
|
export function reorderRows(
|