@ltht-react/timeline 2.0.190 → 2.0.192

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 CHANGED
@@ -1,19 +1,19 @@
1
- # Timeline
2
-
3
- ### Import
4
-
5
- ```js
6
- import Timeline from '@ltht-react/timeline'
7
- ```
8
-
9
- ### Usage
10
-
11
- ```jsx
12
- <Timeline auditTrail={auditTrail} />
13
- ```
14
-
15
- ### Properties
16
-
17
- | Prop | Required | Default | Type | Description |
18
- | :----------- | :------- | :------ | :-------------------- | :----------------- |
19
- | `auditTrail` | Yes | | `Maybe<AuditEvent>[]` | Timeline of events |
1
+ # Timeline
2
+
3
+ ### Import
4
+
5
+ ```js
6
+ import Timeline from '@ltht-react/timeline'
7
+ ```
8
+
9
+ ### Usage
10
+
11
+ ```jsx
12
+ <Timeline auditTrail={auditTrail} />
13
+ ```
14
+
15
+ ### Properties
16
+
17
+ | Prop | Required | Default | Type | Description |
18
+ | :----------- | :------- | :------ | :-------------------- | :----------------- |
19
+ | `auditTrail` | Yes | | `Maybe<AuditEvent>[]` | Timeline of events |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ltht-react/timeline",
3
- "version": "2.0.190",
3
+ "version": "2.0.192",
4
4
  "description": "> TODO: description",
5
5
  "author": "Jonny Dyson",
6
6
  "homepage": "",
@@ -24,16 +24,16 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@emotion/styled": "^11.0.0",
27
- "@ltht-react/banner": "^2.0.190",
28
- "@ltht-react/button": "^2.0.190",
29
- "@ltht-react/hooks": "^2.0.190",
30
- "@ltht-react/icon": "^2.0.190",
31
- "@ltht-react/select": "^2.0.190",
32
- "@ltht-react/styles": "^2.0.190",
33
- "@ltht-react/types": "^2.0.190",
34
- "@ltht-react/utils": "^2.0.190",
27
+ "@ltht-react/banner": "^2.0.192",
28
+ "@ltht-react/button": "^2.0.192",
29
+ "@ltht-react/hooks": "^2.0.192",
30
+ "@ltht-react/icon": "^2.0.192",
31
+ "@ltht-react/select": "^2.0.192",
32
+ "@ltht-react/styles": "^2.0.192",
33
+ "@ltht-react/types": "^2.0.192",
34
+ "@ltht-react/utils": "^2.0.192",
35
35
  "html-react-parser": "^5.0.6",
36
36
  "react": "^18.2.0"
37
37
  },
38
- "gitHead": "1773d375fb0701642bad343c40dd946a7637f2e0"
38
+ "gitHead": "d97c241ba79c5e28edb4dec124e156cda6e9af66"
39
39
  }
@@ -1,52 +1,52 @@
1
- import { FC } from 'react'
2
- import Icon from '@ltht-react/icon'
3
- import styled from '@emotion/styled'
4
- import { formatDateTime, formatTime } from '@ltht-react/utils'
5
- import { Button } from '@ltht-react/button'
6
-
7
- const StyledButton = styled(Button)`
8
- width: auto;
9
- `
10
-
11
- const StyledTimelineTime = styled.div<OrientationProps>`
12
- margin-top: -0.65rem;
13
- display: flex;
14
-
15
- ${(props) => (props.orientation === 'left' ? `justify-content: right` : `justify-content: left`)}
16
- `
17
-
18
- const TimeElement: FC<Props> = ({ date, orientation, pointInTimeClicked, ...rest }) => {
19
- const time = formatTime(date)
20
-
21
- if (!orientation || !pointInTimeClicked) {
22
- return <>{time}</>
23
- }
24
-
25
- const buttonTitle = `Show the dashboard as it was at ${formatDateTime(date)}`
26
-
27
- return (
28
- <StyledTimelineTime orientation={orientation} {...rest}>
29
- <StyledButton
30
- title={buttonTitle}
31
- styling={{ buttonStyle: 'clear' }}
32
- iconColour="black"
33
- icon={<Icon type="clock-rotate-left" size="medium" color="link-blue" />}
34
- onClick={() => pointInTimeClicked(date)}
35
- value={time}
36
- />
37
- </StyledTimelineTime>
38
- )
39
- }
40
-
41
- export type Orientation = 'left' | 'right'
42
-
43
- interface OrientationProps {
44
- orientation?: Orientation
45
- }
46
-
47
- interface Props extends OrientationProps {
48
- date: Date
49
- pointInTimeClicked?: (date: Date) => void
50
- }
51
-
52
- export default TimeElement
1
+ import { FC } from 'react'
2
+ import Icon from '@ltht-react/icon'
3
+ import styled from '@emotion/styled'
4
+ import { formatDateTime, formatTime } from '@ltht-react/utils'
5
+ import { Button } from '@ltht-react/button'
6
+
7
+ const StyledButton = styled(Button)`
8
+ width: auto;
9
+ `
10
+
11
+ const StyledTimelineTime = styled.div<OrientationProps>`
12
+ margin-top: -0.65rem;
13
+ display: flex;
14
+
15
+ ${(props) => (props.orientation === 'left' ? `justify-content: right` : `justify-content: left`)}
16
+ `
17
+
18
+ const TimeElement: FC<Props> = ({ date, orientation, pointInTimeClicked, ...rest }) => {
19
+ const time = formatTime(date)
20
+
21
+ if (!orientation || !pointInTimeClicked) {
22
+ return <>{time}</>
23
+ }
24
+
25
+ const buttonTitle = `Show the dashboard as it was at ${formatDateTime(date)}`
26
+
27
+ return (
28
+ <StyledTimelineTime orientation={orientation} {...rest}>
29
+ <StyledButton
30
+ title={buttonTitle}
31
+ styling={{ buttonStyle: 'clear' }}
32
+ iconColour="black"
33
+ icon={<Icon type="clock-rotate-left" size="medium" color="link-blue" />}
34
+ onClick={() => pointInTimeClicked(date)}
35
+ value={time}
36
+ />
37
+ </StyledTimelineTime>
38
+ )
39
+ }
40
+
41
+ export type Orientation = 'left' | 'right'
42
+
43
+ interface OrientationProps {
44
+ orientation?: Orientation
45
+ }
46
+
47
+ interface Props extends OrientationProps {
48
+ date: Date
49
+ pointInTimeClicked?: (date: Date) => void
50
+ }
51
+
52
+ export default TimeElement
@@ -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