@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.
@@ -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