@ltht-react/table 2.0.190 → 2.0.191
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/README.md +15 -15
- package/package.json +8 -8
- package/src/atoms/questionnaire-withdrawn-table-cell.tsx +15 -15
- package/src/index.tsx +8 -8
- package/src/molecules/table-cell.tsx +111 -111
- package/src/molecules/table-component.tsx +123 -123
- package/src/molecules/table-header.tsx +38 -38
- package/src/molecules/table-methods.tsx +238 -238
- package/src/molecules/table-styled-components.tsx +249 -249
- package/src/molecules/table.tsx +166 -166
- package/src/molecules/useDimensionRef.tsx +37 -37
- package/src/molecules/useScrollRef.tsx +40 -40
- package/src/organisms/generic-table.tsx +34 -34
- package/src/organisms/questionnaire-table-methods.tsx +351 -351
- package/src/organisms/questionnaire-table.tsx +56 -56
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { QuestionnaireResponse, Questionnaire } from '@ltht-react/types'
|
|
2
|
-
import { FC, useMemo } from 'react'
|
|
3
|
-
import Icon from '@ltht-react/icon'
|
|
4
|
-
import Table, { IPaginationProps, ITableDimensionProps, ITableConfig } from '../molecules/table'
|
|
5
|
-
import mapQuestionnaireDefinitionAndResponsesToTableData, {
|
|
6
|
-
AdminActionsForQuestionnaire,
|
|
7
|
-
} from './questionnaire-table-methods'
|
|
8
|
-
|
|
9
|
-
const QuestionnaireTable: FC<IProps> = ({
|
|
10
|
-
definition,
|
|
11
|
-
records,
|
|
12
|
-
headerAxis = 'y',
|
|
13
|
-
staticColumns = 0,
|
|
14
|
-
adminActions,
|
|
15
|
-
pageSize = 10,
|
|
16
|
-
currentPage = 1,
|
|
17
|
-
keepPreviousData = true,
|
|
18
|
-
...props
|
|
19
|
-
}) => {
|
|
20
|
-
const tableData = useMemo(
|
|
21
|
-
() => mapQuestionnaireDefinitionAndResponsesToTableData(definition, records, headerAxis, adminActions),
|
|
22
|
-
[headerAxis, definition, records, adminActions]
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
// TODO: Replace this fragment with a properly styled error component.
|
|
26
|
-
// Maybe this could be a re-usable atom?
|
|
27
|
-
if (!tableData) {
|
|
28
|
-
return (
|
|
29
|
-
<>
|
|
30
|
-
<Icon type="exclamation" size="large" color="red" />
|
|
31
|
-
<div>An error occurred whilst loading this table.</div>
|
|
32
|
-
</>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<Table
|
|
38
|
-
tableData={tableData}
|
|
39
|
-
staticColumns={staticColumns}
|
|
40
|
-
headerAxis={headerAxis}
|
|
41
|
-
pageSize={pageSize}
|
|
42
|
-
currentPage={currentPage}
|
|
43
|
-
keepPreviousData={keepPreviousData}
|
|
44
|
-
{...props}
|
|
45
|
-
/>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface IProps extends ITableConfig, IPaginationProps, ITableDimensionProps {
|
|
50
|
-
id?: string
|
|
51
|
-
definition: Questionnaire
|
|
52
|
-
records: QuestionnaireResponse[]
|
|
53
|
-
adminActions?: AdminActionsForQuestionnaire[]
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default QuestionnaireTable
|
|
1
|
+
import { QuestionnaireResponse, Questionnaire } from '@ltht-react/types'
|
|
2
|
+
import { FC, useMemo } from 'react'
|
|
3
|
+
import Icon from '@ltht-react/icon'
|
|
4
|
+
import Table, { IPaginationProps, ITableDimensionProps, ITableConfig } from '../molecules/table'
|
|
5
|
+
import mapQuestionnaireDefinitionAndResponsesToTableData, {
|
|
6
|
+
AdminActionsForQuestionnaire,
|
|
7
|
+
} from './questionnaire-table-methods'
|
|
8
|
+
|
|
9
|
+
const QuestionnaireTable: FC<IProps> = ({
|
|
10
|
+
definition,
|
|
11
|
+
records,
|
|
12
|
+
headerAxis = 'y',
|
|
13
|
+
staticColumns = 0,
|
|
14
|
+
adminActions,
|
|
15
|
+
pageSize = 10,
|
|
16
|
+
currentPage = 1,
|
|
17
|
+
keepPreviousData = true,
|
|
18
|
+
...props
|
|
19
|
+
}) => {
|
|
20
|
+
const tableData = useMemo(
|
|
21
|
+
() => mapQuestionnaireDefinitionAndResponsesToTableData(definition, records, headerAxis, adminActions),
|
|
22
|
+
[headerAxis, definition, records, adminActions]
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// TODO: Replace this fragment with a properly styled error component.
|
|
26
|
+
// Maybe this could be a re-usable atom?
|
|
27
|
+
if (!tableData) {
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<Icon type="exclamation" size="large" color="red" />
|
|
31
|
+
<div>An error occurred whilst loading this table.</div>
|
|
32
|
+
</>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Table
|
|
38
|
+
tableData={tableData}
|
|
39
|
+
staticColumns={staticColumns}
|
|
40
|
+
headerAxis={headerAxis}
|
|
41
|
+
pageSize={pageSize}
|
|
42
|
+
currentPage={currentPage}
|
|
43
|
+
keepPreviousData={keepPreviousData}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface IProps extends ITableConfig, IPaginationProps, ITableDimensionProps {
|
|
50
|
+
id?: string
|
|
51
|
+
definition: Questionnaire
|
|
52
|
+
records: QuestionnaireResponse[]
|
|
53
|
+
adminActions?: AdminActionsForQuestionnaire[]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default QuestionnaireTable
|