@ltht-react/timeline 2.0.62 → 2.0.64
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 +19 -19
- package/lib/atoms/time-element.d.ts +11 -0
- package/lib/atoms/time-element.js +50 -0
- package/lib/atoms/time-element.js.map +1 -0
- package/lib/atoms/timeline-author.d.ts +8 -0
- package/lib/atoms/timeline-author.js +88 -0
- package/lib/atoms/timeline-author.js.map +1 -0
- package/lib/atoms/timeline-button.d.ts +7 -0
- package/lib/atoms/timeline-button.js +26 -0
- package/lib/atoms/timeline-button.js.map +1 -0
- package/lib/atoms/timeline-description.d.ts +8 -0
- package/lib/atoms/timeline-description.js +67 -0
- package/lib/atoms/timeline-description.js.map +1 -0
- package/lib/atoms/timeline-time.d.ts +11 -0
- package/lib/atoms/timeline-time.js +66 -0
- package/lib/atoms/timeline-time.js.map +1 -0
- package/lib/atoms/timeline-title-redacted.d.ts +3 -0
- package/lib/atoms/timeline-title-redacted.js +28 -0
- package/lib/atoms/timeline-title-redacted.js.map +1 -0
- package/lib/atoms/timeline-title.d.ts +8 -0
- package/lib/atoms/timeline-title.js +55 -0
- package/lib/atoms/timeline-title.js.map +1 -0
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js +5 -0
- package/lib/constants.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/molecules/timeline-item-redacted.d.ts +3 -0
- package/lib/molecules/timeline-item-redacted.js +32 -0
- package/lib/molecules/timeline-item-redacted.js.map +1 -0
- package/lib/molecules/timeline-item.d.ts +16 -0
- package/lib/molecules/timeline-item.js +49 -0
- package/lib/molecules/timeline-item.js.map +1 -0
- package/lib/organisms/timeline.d.ts +19 -0
- package/lib/organisms/timeline.js +207 -0
- package/lib/organisms/timeline.js.map +1 -0
- package/package.json +10 -10
- package/src/atoms/time-element.tsx +52 -52
- package/src/atoms/timeline-author.tsx +88 -88
- package/src/atoms/timeline-button.tsx +44 -44
- package/src/atoms/timeline-description.tsx +52 -52
- package/src/atoms/timeline-time.tsx +69 -69
- package/src/atoms/timeline-title-redacted.tsx +13 -13
- package/src/atoms/timeline-title.tsx +41 -41
- package/src/constants.ts +3 -3
- package/src/index.tsx +6 -6
- package/src/molecules/timeline-item-redacted.tsx +47 -47
- package/src/molecules/timeline-item.tsx +130 -130
- package/src/organisms/timeline.tsx +419 -419
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react'
|
|
2
|
-
import Icon from '@ltht-react/icon'
|
|
3
|
-
import styled from '@emotion/styled'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
AuditEvent,
|
|
7
|
-
DocumentReference,
|
|
8
|
-
Maybe,
|
|
9
|
-
QuestionnaireResponse,
|
|
10
|
-
TimelineDomainResourceType,
|
|
11
|
-
} from '@ltht-react/types'
|
|
12
|
-
import PRIMARY_AUTHOR from '../constants'
|
|
13
|
-
|
|
14
|
-
const StyledTimelineItemLeft = styled.div`
|
|
15
|
-
flex-grow: 1;
|
|
16
|
-
`
|
|
17
|
-
|
|
18
|
-
const TimelineAuthor: FC<Props> = ({ domainResource, domainResourceType, ...rest }) => {
|
|
19
|
-
if (!domainResource) return <></>
|
|
20
|
-
|
|
21
|
-
switch (domainResourceType) {
|
|
22
|
-
case TimelineDomainResourceType.QuestionnaireResponse: {
|
|
23
|
-
const qr = domainResource as QuestionnaireResponse
|
|
24
|
-
if (!qr?.author) {
|
|
25
|
-
return <></>
|
|
26
|
-
}
|
|
27
|
-
return (
|
|
28
|
-
<StyledTimelineItemLeft {...rest}>
|
|
29
|
-
<Icon type="user" size="medium" color="grey" /> by {qr?.author?.display}
|
|
30
|
-
</StyledTimelineItemLeft>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
case TimelineDomainResourceType.DocumentReference: {
|
|
34
|
-
const docRef = domainResource as DocumentReference
|
|
35
|
-
const authorList: string[] = []
|
|
36
|
-
|
|
37
|
-
if (docRef?.author == null) {
|
|
38
|
-
return <></>
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
docRef.author.forEach((auth) => {
|
|
42
|
-
if (auth) {
|
|
43
|
-
authorList.push(auth.specialty ? `${auth.fullName} (${auth.specialty})` : `${auth.fullName}`)
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
if (authorList.length === 0) {
|
|
48
|
-
return <></>
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<StyledTimelineItemLeft {...rest}>
|
|
53
|
-
<Icon type="user" size="medium" color="grey" /> by {authorList.join(', ')}
|
|
54
|
-
</StyledTimelineItemLeft>
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
case TimelineDomainResourceType.AuditEvent: {
|
|
58
|
-
const audit = domainResource as AuditEvent
|
|
59
|
-
let authorName = ''
|
|
60
|
-
|
|
61
|
-
audit.agent.forEach((agent) => {
|
|
62
|
-
agent?.role?.forEach((role) => {
|
|
63
|
-
const isPrimaryAuthor = !!role?.coding?.find((x) => x?.code === PRIMARY_AUTHOR)
|
|
64
|
-
!authorName && isPrimaryAuthor && (authorName = agent.who?.display || '')
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
if (!authorName) {
|
|
69
|
-
return <></>
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<StyledTimelineItemLeft {...rest}>
|
|
74
|
-
<Icon type="user" size="medium" color="grey" /> by {authorName}
|
|
75
|
-
</StyledTimelineItemLeft>
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return <></>
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
84
|
-
domainResource?: Maybe<AuditEvent | QuestionnaireResponse | DocumentReference>
|
|
85
|
-
domainResourceType: TimelineDomainResourceType
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export default TimelineAuthor
|
|
1
|
+
import { FC, HTMLAttributes } from 'react'
|
|
2
|
+
import Icon from '@ltht-react/icon'
|
|
3
|
+
import styled from '@emotion/styled'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
AuditEvent,
|
|
7
|
+
DocumentReference,
|
|
8
|
+
Maybe,
|
|
9
|
+
QuestionnaireResponse,
|
|
10
|
+
TimelineDomainResourceType,
|
|
11
|
+
} from '@ltht-react/types'
|
|
12
|
+
import PRIMARY_AUTHOR from '../constants'
|
|
13
|
+
|
|
14
|
+
const StyledTimelineItemLeft = styled.div`
|
|
15
|
+
flex-grow: 1;
|
|
16
|
+
`
|
|
17
|
+
|
|
18
|
+
const TimelineAuthor: FC<Props> = ({ domainResource, domainResourceType, ...rest }) => {
|
|
19
|
+
if (!domainResource) return <></>
|
|
20
|
+
|
|
21
|
+
switch (domainResourceType) {
|
|
22
|
+
case TimelineDomainResourceType.QuestionnaireResponse: {
|
|
23
|
+
const qr = domainResource as QuestionnaireResponse
|
|
24
|
+
if (!qr?.author) {
|
|
25
|
+
return <></>
|
|
26
|
+
}
|
|
27
|
+
return (
|
|
28
|
+
<StyledTimelineItemLeft {...rest}>
|
|
29
|
+
<Icon type="user" size="medium" color="grey" /> by {qr?.author?.display}
|
|
30
|
+
</StyledTimelineItemLeft>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
case TimelineDomainResourceType.DocumentReference: {
|
|
34
|
+
const docRef = domainResource as DocumentReference
|
|
35
|
+
const authorList: string[] = []
|
|
36
|
+
|
|
37
|
+
if (docRef?.author == null) {
|
|
38
|
+
return <></>
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
docRef.author.forEach((auth) => {
|
|
42
|
+
if (auth) {
|
|
43
|
+
authorList.push(auth.specialty ? `${auth.fullName} (${auth.specialty})` : `${auth.fullName}`)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
if (authorList.length === 0) {
|
|
48
|
+
return <></>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<StyledTimelineItemLeft {...rest}>
|
|
53
|
+
<Icon type="user" size="medium" color="grey" /> by {authorList.join(', ')}
|
|
54
|
+
</StyledTimelineItemLeft>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
case TimelineDomainResourceType.AuditEvent: {
|
|
58
|
+
const audit = domainResource as AuditEvent
|
|
59
|
+
let authorName = ''
|
|
60
|
+
|
|
61
|
+
audit.agent.forEach((agent) => {
|
|
62
|
+
agent?.role?.forEach((role) => {
|
|
63
|
+
const isPrimaryAuthor = !!role?.coding?.find((x) => x?.code === PRIMARY_AUTHOR)
|
|
64
|
+
!authorName && isPrimaryAuthor && (authorName = agent.who?.display || '')
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
if (!authorName) {
|
|
69
|
+
return <></>
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<StyledTimelineItemLeft {...rest}>
|
|
74
|
+
<Icon type="user" size="medium" color="grey" /> by {authorName}
|
|
75
|
+
</StyledTimelineItemLeft>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return <></>
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
84
|
+
domainResource?: Maybe<AuditEvent | QuestionnaireResponse | DocumentReference>
|
|
85
|
+
domainResourceType: TimelineDomainResourceType
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default TimelineAuthor
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { ButtonBanner } from '@ltht-react/banner'
|
|
2
|
-
import Icon from '@ltht-react/icon'
|
|
3
|
-
import { FC, HTMLAttributes } from 'react'
|
|
4
|
-
import { ITimelineItem } from '../molecules/timeline-item'
|
|
5
|
-
|
|
6
|
-
const TimelineButton: FC<Props> = ({ timelineItem, className }) => {
|
|
7
|
-
const { itemClickHandler, buttonState, buttonText } = timelineItem
|
|
8
|
-
|
|
9
|
-
switch (buttonState) {
|
|
10
|
-
case 'no-button':
|
|
11
|
-
return <></>
|
|
12
|
-
case 'permission-denied-button':
|
|
13
|
-
return (
|
|
14
|
-
<ButtonBanner className={className} type="warning" disabled>
|
|
15
|
-
{buttonText ?? 'Insufficient privileges to view this item'}
|
|
16
|
-
</ButtonBanner>
|
|
17
|
-
)
|
|
18
|
-
case 'selectable-button':
|
|
19
|
-
return (
|
|
20
|
-
<ButtonBanner className={className} type="info" onClick={itemClickHandler}>
|
|
21
|
-
{buttonText ?? ''}
|
|
22
|
-
</ButtonBanner>
|
|
23
|
-
)
|
|
24
|
-
case 'selected-button':
|
|
25
|
-
return (
|
|
26
|
-
<ButtonBanner
|
|
27
|
-
className={className}
|
|
28
|
-
type="highlight"
|
|
29
|
-
icon={<Icon type="info-circle" color="info-blue" size="medium" />}
|
|
30
|
-
onClick={itemClickHandler}
|
|
31
|
-
>
|
|
32
|
-
{buttonText ?? ''}
|
|
33
|
-
</ButtonBanner>
|
|
34
|
-
)
|
|
35
|
-
default:
|
|
36
|
-
throw new Error('ButtonState must be a valid value.')
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
41
|
-
timelineItem: ITimelineItem
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default TimelineButton
|
|
1
|
+
import { ButtonBanner } from '@ltht-react/banner'
|
|
2
|
+
import Icon from '@ltht-react/icon'
|
|
3
|
+
import { FC, HTMLAttributes } from 'react'
|
|
4
|
+
import { ITimelineItem } from '../molecules/timeline-item'
|
|
5
|
+
|
|
6
|
+
const TimelineButton: FC<Props> = ({ timelineItem, className }) => {
|
|
7
|
+
const { itemClickHandler, buttonState, buttonText } = timelineItem
|
|
8
|
+
|
|
9
|
+
switch (buttonState) {
|
|
10
|
+
case 'no-button':
|
|
11
|
+
return <></>
|
|
12
|
+
case 'permission-denied-button':
|
|
13
|
+
return (
|
|
14
|
+
<ButtonBanner className={className} type="warning" disabled>
|
|
15
|
+
{buttonText ?? 'Insufficient privileges to view this item'}
|
|
16
|
+
</ButtonBanner>
|
|
17
|
+
)
|
|
18
|
+
case 'selectable-button':
|
|
19
|
+
return (
|
|
20
|
+
<ButtonBanner className={className} type="info" onClick={itemClickHandler}>
|
|
21
|
+
{buttonText ?? ''}
|
|
22
|
+
</ButtonBanner>
|
|
23
|
+
)
|
|
24
|
+
case 'selected-button':
|
|
25
|
+
return (
|
|
26
|
+
<ButtonBanner
|
|
27
|
+
className={className}
|
|
28
|
+
type="highlight"
|
|
29
|
+
icon={<Icon type="info-circle" color="info-blue" size="medium" />}
|
|
30
|
+
onClick={itemClickHandler}
|
|
31
|
+
>
|
|
32
|
+
{buttonText ?? ''}
|
|
33
|
+
</ButtonBanner>
|
|
34
|
+
)
|
|
35
|
+
default:
|
|
36
|
+
throw new Error('ButtonState must be a valid value.')
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
41
|
+
timelineItem: ITimelineItem
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default TimelineButton
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
AuditEvent,
|
|
4
|
-
DocumentReference,
|
|
5
|
-
Maybe,
|
|
6
|
-
QuestionnaireResponse,
|
|
7
|
-
TimelineDomainResourceType,
|
|
8
|
-
} from '@ltht-react/types'
|
|
9
|
-
import parseHtml from 'html-react-parser'
|
|
10
|
-
import styled from '@emotion/styled'
|
|
11
|
-
|
|
12
|
-
const StyledDescription = styled.div`
|
|
13
|
-
p {
|
|
14
|
-
margin: 0 0.2rem;
|
|
15
|
-
display: inline;
|
|
16
|
-
}
|
|
17
|
-
`
|
|
18
|
-
|
|
19
|
-
const TimelineDescription: FC<Props> = ({ domainResource, domainResourceType, ...rest }) => {
|
|
20
|
-
if (!domainResource) return <></>
|
|
21
|
-
|
|
22
|
-
switch (domainResourceType) {
|
|
23
|
-
case TimelineDomainResourceType.QuestionnaireResponse: {
|
|
24
|
-
const qr = domainResource as QuestionnaireResponse
|
|
25
|
-
if (!qr.questionnaire?.description) {
|
|
26
|
-
return <></>
|
|
27
|
-
}
|
|
28
|
-
return <StyledDescription {...rest}>{parseHtml(qr.questionnaire?.description)}</StyledDescription>
|
|
29
|
-
}
|
|
30
|
-
case TimelineDomainResourceType.DocumentReference: {
|
|
31
|
-
const docRef = domainResource as DocumentReference
|
|
32
|
-
return docRef.description ? <>{docRef.description}</> : <></>
|
|
33
|
-
}
|
|
34
|
-
case TimelineDomainResourceType.AuditEvent: {
|
|
35
|
-
const audit = domainResource as AuditEvent
|
|
36
|
-
if (!audit.outcomeDesc) {
|
|
37
|
-
return <></>
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return <StyledDescription {...rest}>{parseHtml(audit.outcomeDesc)}</StyledDescription>
|
|
41
|
-
}
|
|
42
|
-
default:
|
|
43
|
-
return <></>
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
48
|
-
domainResource?: Maybe<AuditEvent | QuestionnaireResponse | DocumentReference>
|
|
49
|
-
domainResourceType: TimelineDomainResourceType
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default TimelineDescription
|
|
1
|
+
import { FC, HTMLAttributes } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
AuditEvent,
|
|
4
|
+
DocumentReference,
|
|
5
|
+
Maybe,
|
|
6
|
+
QuestionnaireResponse,
|
|
7
|
+
TimelineDomainResourceType,
|
|
8
|
+
} from '@ltht-react/types'
|
|
9
|
+
import parseHtml from 'html-react-parser'
|
|
10
|
+
import styled from '@emotion/styled'
|
|
11
|
+
|
|
12
|
+
const StyledDescription = styled.div`
|
|
13
|
+
p {
|
|
14
|
+
margin: 0 0.2rem;
|
|
15
|
+
display: inline;
|
|
16
|
+
}
|
|
17
|
+
`
|
|
18
|
+
|
|
19
|
+
const TimelineDescription: FC<Props> = ({ domainResource, domainResourceType, ...rest }) => {
|
|
20
|
+
if (!domainResource) return <></>
|
|
21
|
+
|
|
22
|
+
switch (domainResourceType) {
|
|
23
|
+
case TimelineDomainResourceType.QuestionnaireResponse: {
|
|
24
|
+
const qr = domainResource as QuestionnaireResponse
|
|
25
|
+
if (!qr.questionnaire?.description) {
|
|
26
|
+
return <></>
|
|
27
|
+
}
|
|
28
|
+
return <StyledDescription {...rest}>{parseHtml(qr.questionnaire?.description)}</StyledDescription>
|
|
29
|
+
}
|
|
30
|
+
case TimelineDomainResourceType.DocumentReference: {
|
|
31
|
+
const docRef = domainResource as DocumentReference
|
|
32
|
+
return docRef.description ? <>{docRef.description}</> : <></>
|
|
33
|
+
}
|
|
34
|
+
case TimelineDomainResourceType.AuditEvent: {
|
|
35
|
+
const audit = domainResource as AuditEvent
|
|
36
|
+
if (!audit.outcomeDesc) {
|
|
37
|
+
return <></>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return <StyledDescription {...rest}>{parseHtml(audit.outcomeDesc)}</StyledDescription>
|
|
41
|
+
}
|
|
42
|
+
default:
|
|
43
|
+
return <></>
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
48
|
+
domainResource?: Maybe<AuditEvent | QuestionnaireResponse | DocumentReference>
|
|
49
|
+
domainResourceType: TimelineDomainResourceType
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default TimelineDescription
|
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
AuditEvent,
|
|
4
|
-
DocumentReference,
|
|
5
|
-
Maybe,
|
|
6
|
-
QuestionnaireResponse,
|
|
7
|
-
TimelineDomainResourceType,
|
|
8
|
-
} from '@ltht-react/types'
|
|
9
|
-
import TimeElement, { Orientation } from './time-element'
|
|
10
|
-
|
|
11
|
-
const TimelineTime: FC<Props> = ({
|
|
12
|
-
domainResource,
|
|
13
|
-
domainResourceType,
|
|
14
|
-
orientation,
|
|
15
|
-
pointInTimeClickHandler,
|
|
16
|
-
...rest
|
|
17
|
-
}) => {
|
|
18
|
-
if (!domainResource) return <></>
|
|
19
|
-
|
|
20
|
-
switch (domainResourceType) {
|
|
21
|
-
case TimelineDomainResourceType.QuestionnaireResponse: {
|
|
22
|
-
const qr = domainResource as QuestionnaireResponse
|
|
23
|
-
if (!qr?.authored?.value) {
|
|
24
|
-
return null
|
|
25
|
-
}
|
|
26
|
-
const date = new Date(qr?.authored.value)
|
|
27
|
-
return (
|
|
28
|
-
<div {...rest}>
|
|
29
|
-
<TimeElement orientation={orientation} date={date} pointInTimeClicked={pointInTimeClickHandler} />
|
|
30
|
-
</div>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
case TimelineDomainResourceType.DocumentReference: {
|
|
34
|
-
const docRef = domainResource as DocumentReference
|
|
35
|
-
if (docRef && docRef?.created?.value) {
|
|
36
|
-
const date = new Date(docRef.created.value)
|
|
37
|
-
return (
|
|
38
|
-
<div {...rest}>
|
|
39
|
-
<TimeElement orientation={orientation} date={date} pointInTimeClicked={pointInTimeClickHandler} />
|
|
40
|
-
</div>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
return null
|
|
44
|
-
}
|
|
45
|
-
case TimelineDomainResourceType.AuditEvent: {
|
|
46
|
-
const audit = domainResource as AuditEvent
|
|
47
|
-
if (audit && audit?.recorded?.value) {
|
|
48
|
-
const date = new Date(audit.recorded.value)
|
|
49
|
-
return (
|
|
50
|
-
<div {...rest}>
|
|
51
|
-
<TimeElement orientation={orientation} date={date} pointInTimeClicked={pointInTimeClickHandler} />
|
|
52
|
-
</div>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
return null
|
|
56
|
-
}
|
|
57
|
-
default:
|
|
58
|
-
return null
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
63
|
-
domainResource?: Maybe<AuditEvent | QuestionnaireResponse | DocumentReference>
|
|
64
|
-
domainResourceType: TimelineDomainResourceType
|
|
65
|
-
orientation?: Orientation
|
|
66
|
-
pointInTimeClickHandler?: (date: Date) => void
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export default TimelineTime
|
|
1
|
+
import { FC, HTMLAttributes } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
AuditEvent,
|
|
4
|
+
DocumentReference,
|
|
5
|
+
Maybe,
|
|
6
|
+
QuestionnaireResponse,
|
|
7
|
+
TimelineDomainResourceType,
|
|
8
|
+
} from '@ltht-react/types'
|
|
9
|
+
import TimeElement, { Orientation } from './time-element'
|
|
10
|
+
|
|
11
|
+
const TimelineTime: FC<Props> = ({
|
|
12
|
+
domainResource,
|
|
13
|
+
domainResourceType,
|
|
14
|
+
orientation,
|
|
15
|
+
pointInTimeClickHandler,
|
|
16
|
+
...rest
|
|
17
|
+
}) => {
|
|
18
|
+
if (!domainResource) return <></>
|
|
19
|
+
|
|
20
|
+
switch (domainResourceType) {
|
|
21
|
+
case TimelineDomainResourceType.QuestionnaireResponse: {
|
|
22
|
+
const qr = domainResource as QuestionnaireResponse
|
|
23
|
+
if (!qr?.authored?.value) {
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
const date = new Date(qr?.authored.value)
|
|
27
|
+
return (
|
|
28
|
+
<div {...rest}>
|
|
29
|
+
<TimeElement orientation={orientation} date={date} pointInTimeClicked={pointInTimeClickHandler} />
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
case TimelineDomainResourceType.DocumentReference: {
|
|
34
|
+
const docRef = domainResource as DocumentReference
|
|
35
|
+
if (docRef && docRef?.created?.value) {
|
|
36
|
+
const date = new Date(docRef.created.value)
|
|
37
|
+
return (
|
|
38
|
+
<div {...rest}>
|
|
39
|
+
<TimeElement orientation={orientation} date={date} pointInTimeClicked={pointInTimeClickHandler} />
|
|
40
|
+
</div>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
return null
|
|
44
|
+
}
|
|
45
|
+
case TimelineDomainResourceType.AuditEvent: {
|
|
46
|
+
const audit = domainResource as AuditEvent
|
|
47
|
+
if (audit && audit?.recorded?.value) {
|
|
48
|
+
const date = new Date(audit.recorded.value)
|
|
49
|
+
return (
|
|
50
|
+
<div {...rest}>
|
|
51
|
+
<TimeElement orientation={orientation} date={date} pointInTimeClicked={pointInTimeClickHandler} />
|
|
52
|
+
</div>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
return null
|
|
56
|
+
}
|
|
57
|
+
default:
|
|
58
|
+
return null
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
63
|
+
domainResource?: Maybe<AuditEvent | QuestionnaireResponse | DocumentReference>
|
|
64
|
+
domainResourceType: TimelineDomainResourceType
|
|
65
|
+
orientation?: Orientation
|
|
66
|
+
pointInTimeClickHandler?: (date: Date) => void
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default TimelineTime
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react'
|
|
2
|
-
import { TEXT_COLOURS } from '@ltht-react/styles'
|
|
3
|
-
import styled from '@emotion/styled'
|
|
4
|
-
|
|
5
|
-
const StyledRedactedMessage = styled.div`
|
|
6
|
-
color: ${TEXT_COLOURS.SECONDARY.VALUE};
|
|
7
|
-
`
|
|
8
|
-
|
|
9
|
-
const TimelineTitleRedacted: FC<HTMLAttributes<HTMLDivElement>> = (props) => (
|
|
10
|
-
<StyledRedactedMessage {...props}>Insufficient Privileges</StyledRedactedMessage>
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
export default TimelineTitleRedacted
|
|
1
|
+
import { FC, HTMLAttributes } from 'react'
|
|
2
|
+
import { TEXT_COLOURS } from '@ltht-react/styles'
|
|
3
|
+
import styled from '@emotion/styled'
|
|
4
|
+
|
|
5
|
+
const StyledRedactedMessage = styled.div`
|
|
6
|
+
color: ${TEXT_COLOURS.SECONDARY.VALUE};
|
|
7
|
+
`
|
|
8
|
+
|
|
9
|
+
const TimelineTitleRedacted: FC<HTMLAttributes<HTMLDivElement>> = (props) => (
|
|
10
|
+
<StyledRedactedMessage {...props}>Insufficient Privileges</StyledRedactedMessage>
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
export default TimelineTitleRedacted
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
AuditEvent,
|
|
4
|
-
DocumentReference,
|
|
5
|
-
Maybe,
|
|
6
|
-
QuestionnaireResponse,
|
|
7
|
-
TimelineDomainResourceType,
|
|
8
|
-
} from '@ltht-react/types'
|
|
9
|
-
|
|
10
|
-
const TimelineTitle: FC<Props> = ({ domainResource, domainResourceType, ...rest }) => {
|
|
11
|
-
if (!domainResource) return <></>
|
|
12
|
-
|
|
13
|
-
switch (domainResourceType) {
|
|
14
|
-
case TimelineDomainResourceType.QuestionnaireResponse: {
|
|
15
|
-
const qr = domainResource as QuestionnaireResponse
|
|
16
|
-
const questionnaireTitle = qr.metadata.isRedacted
|
|
17
|
-
? 'Insufficient privileges'
|
|
18
|
-
: qr.text?.text ?? qr.questionnaire?.title
|
|
19
|
-
return <div {...rest}>{questionnaireTitle}</div>
|
|
20
|
-
}
|
|
21
|
-
case TimelineDomainResourceType.DocumentReference: {
|
|
22
|
-
const docRef = domainResource as DocumentReference
|
|
23
|
-
const docTitle = docRef.metadata.isRedacted ? 'Insufficient privileges' : docRef.text?.text
|
|
24
|
-
return <div {...rest}>{docTitle}</div>
|
|
25
|
-
}
|
|
26
|
-
case TimelineDomainResourceType.AuditEvent: {
|
|
27
|
-
const audit = domainResource as AuditEvent
|
|
28
|
-
const auditTitle = audit.metadata.isRedacted ? 'Insufficient privileges' : audit.text?.text
|
|
29
|
-
return <div {...rest}>{auditTitle}</div>
|
|
30
|
-
}
|
|
31
|
-
default:
|
|
32
|
-
return <></>
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
37
|
-
domainResource?: Maybe<AuditEvent | QuestionnaireResponse | DocumentReference>
|
|
38
|
-
domainResourceType: TimelineDomainResourceType
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default TimelineTitle
|
|
1
|
+
import { FC, HTMLAttributes } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
AuditEvent,
|
|
4
|
+
DocumentReference,
|
|
5
|
+
Maybe,
|
|
6
|
+
QuestionnaireResponse,
|
|
7
|
+
TimelineDomainResourceType,
|
|
8
|
+
} from '@ltht-react/types'
|
|
9
|
+
|
|
10
|
+
const TimelineTitle: FC<Props> = ({ domainResource, domainResourceType, ...rest }) => {
|
|
11
|
+
if (!domainResource) return <></>
|
|
12
|
+
|
|
13
|
+
switch (domainResourceType) {
|
|
14
|
+
case TimelineDomainResourceType.QuestionnaireResponse: {
|
|
15
|
+
const qr = domainResource as QuestionnaireResponse
|
|
16
|
+
const questionnaireTitle = qr.metadata.isRedacted
|
|
17
|
+
? 'Insufficient privileges'
|
|
18
|
+
: qr.text?.text ?? qr.questionnaire?.title
|
|
19
|
+
return <div {...rest}>{questionnaireTitle}</div>
|
|
20
|
+
}
|
|
21
|
+
case TimelineDomainResourceType.DocumentReference: {
|
|
22
|
+
const docRef = domainResource as DocumentReference
|
|
23
|
+
const docTitle = docRef.metadata.isRedacted ? 'Insufficient privileges' : docRef.text?.text
|
|
24
|
+
return <div {...rest}>{docTitle}</div>
|
|
25
|
+
}
|
|
26
|
+
case TimelineDomainResourceType.AuditEvent: {
|
|
27
|
+
const audit = domainResource as AuditEvent
|
|
28
|
+
const auditTitle = audit.metadata.isRedacted ? 'Insufficient privileges' : audit.text?.text
|
|
29
|
+
return <div {...rest}>{auditTitle}</div>
|
|
30
|
+
}
|
|
31
|
+
default:
|
|
32
|
+
return <></>
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
37
|
+
domainResource?: Maybe<AuditEvent | QuestionnaireResponse | DocumentReference>
|
|
38
|
+
domainResourceType: TimelineDomainResourceType
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default TimelineTitle
|
package/src/constants.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const PRIMARY_AUTHOR = 'PRIMAUTH'
|
|
2
|
-
|
|
3
|
-
export default PRIMARY_AUTHOR
|
|
1
|
+
const PRIMARY_AUTHOR = 'PRIMAUTH'
|
|
2
|
+
|
|
3
|
+
export default PRIMARY_AUTHOR
|
package/src/index.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Timeline, { ITimelineFilter, ITimelineFilterOption } from './organisms/timeline'
|
|
2
|
-
import { ITimelineItem } from './molecules/timeline-item'
|
|
3
|
-
import PRIMARY_AUTHOR from './constants'
|
|
4
|
-
|
|
5
|
-
export default Timeline
|
|
6
|
-
export { ITimelineItem, ITimelineFilter, ITimelineFilterOption, PRIMARY_AUTHOR }
|
|
1
|
+
import Timeline, { ITimelineFilter, ITimelineFilterOption } from './organisms/timeline'
|
|
2
|
+
import { ITimelineItem } from './molecules/timeline-item'
|
|
3
|
+
import PRIMARY_AUTHOR from './constants'
|
|
4
|
+
|
|
5
|
+
export default Timeline
|
|
6
|
+
export { ITimelineItem, ITimelineFilter, ITimelineFilterOption, PRIMARY_AUTHOR }
|