Skip to content

Commit 3a70fb8

Browse files
authored
Merge pull request #933 from 4Efficiency-Services/master
2 parents d076261 + d9386b2 commit 3a70fb8

File tree

15 files changed

+98
-66
lines changed

15 files changed

+98
-66
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres (more or less) to [Semantic Versioning](http://semver.o
77

88
## Unreleased
99

10+
## 0.30.0 (unreleased)
11+
* full rewrite to typescript
12+
* uses Vite as bundler
13+
* Updates dependencies to latest versions
14+
* Updates react usage to 18+
15+
* REMOVED enzyme for tests --> testing does not work atm
16+
1017

1118
## 0.28.0
1219

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# fork from react-calendar-timeline
2-
# React Calendar Timeline docs here may not be relevant
1+
# ⚠️⚠️⚠️⚠️ HELP WANTED
2+
please email me [[email protected]](mailto:[email protected]) and we will setup some time to speak and see if you can help maintain this library.
3+
4+
# React Calendar Timeline
35

46
A modern and responsive React timeline component.
57

demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"packageManager": "[email protected]",
1919
"resolutions": {
20-
"react-calendar-timeline-4ef": "../src/index.ts"
20+
"react-calendar-timeline": "../src/index.ts"
2121
},
2222
"devDependencies": {
2323
"@types/randomcolor": "^0.5.9",

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './dist/react-calendar-timeline-4ef.es.js'
1+
export * from './dist/react-calendar-timeline.es.js'

package.json

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "react-calendar-timeline-4ef",
3-
"version": "1.0.18",
4-
"description": "fork form react-calendar-timeline with TS latest react and other improvements",
2+
"name": "react-calendar-timeline",
3+
"version": "0.30.0",
4+
"description": "react-calendar-timeline",
55
"packageManager": "[email protected]",
66
"scripts": {
77
"build": "tsc && vite build",
@@ -10,16 +10,16 @@
1010
"test": "jest",
1111
"test:watch": "jest --watch"
1212
},
13-
"main": "./dist/react-calendar-timeline-4ef.umd.js",
14-
"module": "./dist/react-calendar-timeline-4ef.es.js",
13+
"main": "./dist/react-calendar-timeline.umd.js",
14+
"module": "./dist/react-calendar-timeline.es.js",
1515
"exports": {
1616
"./styles.css": "./dist/styles.css",
1717
".": {
1818
"types": [
1919
"./dist/index.d.ts"
2020
],
21-
"import": "./dist/react-calendar-timeline-4ef.es.js",
22-
"require": "./dist/react-calendar-timeline-4ef.umd.js"
21+
"import": "./dist/react-calendar-timeline.es.js",
22+
"require": "./dist/react-calendar-timeline.umd.js"
2323
}
2424
},
2525
"types": "./dist/index.d.ts",
@@ -32,7 +32,44 @@
3232
"url": "https://github.com/namespace-ee/react-calendar-timeline.git"
3333
},
3434
"private": false,
35-
"author": "4EF",
35+
"author": "Marius Andra <[email protected]>",
36+
"contributors": [
37+
{
38+
"name": "Stanisław Chmiela",
39+
"email": "[email protected]"
40+
},
41+
{
42+
"name": "Mike Joyce",
43+
"url": "https://github.com/mcMickJuice"
44+
},
45+
{
46+
"name": "Samuel Rossetti"
47+
},
48+
{
49+
"name": "amakhrov",
50+
"url": "https://github.com/amakhrov"
51+
},
52+
{
53+
"name": "Ahmad Ilaiwi",
54+
"url": "https://github.com/Ilaiwi"
55+
},
56+
{
57+
"name": "dkarnutsch",
58+
"url": "https://github.com/dkarnutsch"
59+
},
60+
{
61+
"name": "Alex Maclean",
62+
"url": "https://github.com/acemac"
63+
},
64+
{
65+
"name": "Kevin Mann",
66+
"url": "https://github.com/kevinmanncito"
67+
},
68+
{
69+
"name": "Remco Blumink",
70+
"url": ""
71+
}
72+
],
3673
"license": "MIT",
3774
"keywords": [
3875
"react",

src/lib/Timeline.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ export default class ReactCalendarTimeline<
264264
this.hasSelectedItem = this.hasSelectedItem.bind(this)
265265
this.isItemSelected = this.isItemSelected.bind(this)
266266

267-
let visibleTimeStart = null
268-
let visibleTimeEnd = null
267+
let visibleTimeStart: number | null = null
268+
let visibleTimeEnd: number | null = null
269269

270270
if (this.props.defaultTimeStart && this.props.defaultTimeEnd) {
271271
visibleTimeStart = this.props.defaultTimeStart //.valueOf()

src/lib/headers/CustomDateHeader.tsx

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@ import Interval from './Interval'
33
import { Interval as IntervalType, IntervalRenderer } from '../types/main'
44
import { Dayjs } from 'dayjs'
55
import { SelectUnits } from '../utility/calendar'
6+
import { GetIntervalPropsType } from './types'
7+
68
export interface CustomDateHeaderProps<Data> {
79
headerContext: {
810
intervals: IntervalType[]
911
unit: SelectUnits
1012
}
1113
getRootProps: (props?: any) => any
12-
getIntervalProps: (props?: any) => any
14+
getIntervalProps: GetIntervalPropsType
1315
showPeriod: (start: Dayjs, end: Dayjs) => void
1416
data: {
1517
style: React.CSSProperties
1618
intervalRenderer: (props: IntervalRenderer<Data>) => React.ReactNode
1719
className?: string
18-
getLabelFormat: (
19-
interval: [Dayjs, Dayjs],
20-
unit: string,
21-
labelWidth: number,
22-
) => string
20+
getLabelFormat: (interval: [Dayjs, Dayjs], unit: string, labelWidth: number) => string
2321
unitProp?: 'primaryHeader'
2422
headerData?: Data
2523
}
@@ -30,27 +28,12 @@ export function CustomDateHeader<Data>({
3028
getRootProps,
3129
getIntervalProps,
3230
showPeriod,
33-
data: {
34-
style,
35-
intervalRenderer,
36-
className,
37-
getLabelFormat,
38-
unitProp,
39-
headerData,
40-
},
31+
data: { style, intervalRenderer, className, getLabelFormat, unitProp, headerData },
4132
}: CustomDateHeaderProps<Data>) {
4233
return (
43-
<div
44-
data-testid={`dateHeader`}
45-
className={className}
46-
{...getRootProps({ style })}
47-
>
34+
<div data-testid={`dateHeader`} className={className} {...getRootProps({ style })}>
4835
{intervals.map((interval) => {
49-
const intervalText = getLabelFormat(
50-
[interval.startTime, interval.endTime],
51-
unit,
52-
interval.labelWidth,
53-
)
36+
const intervalText = getLabelFormat([interval.startTime, interval.endTime], unit, interval.labelWidth)
5437
return (
5538
<Interval
5639
key={`label-${interval.startTime.valueOf()}`}

src/lib/headers/CustomHeader.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Interval, TimelineTimeSteps } from '../types/main'
66
import { Dayjs } from 'dayjs'
77
import { CustomDateHeaderProps } from './CustomDateHeader'
88
import isEqual from 'lodash/isEqual'
9+
import { GetIntervalPropsType } from './types'
910

1011
export type CustomHeaderProps<Data> = {
1112
children: (p: CustomDateHeaderProps<Data>) => ReactNode
@@ -55,6 +56,10 @@ class CustomHeader<Data> extends React.Component<CustomHeaderProps<Data>, State>
5556
}
5657
}
5758

59+
static defaultProps = {
60+
height: 30,
61+
}
62+
5863
/*shouldComponentUpdate(nextProps: CustomHeaderProps<Data>) {
5964
if (
6065
nextProps.canvasTimeStart !== this.props.canvasTimeStart ||
@@ -127,7 +132,7 @@ class CustomHeader<Data> extends React.Component<CustomHeaderProps<Data>, State>
127132
}
128133
}
129134

130-
getIntervalProps = (props: { interval?: Interval; style?: CSSProperties } = {}) => {
135+
getIntervalProps: GetIntervalPropsType = (props: { interval?: Interval; style?: CSSProperties } = {}) => {
131136
const { interval, style } = props
132137
if (!interval) throw new Error('you should provide interval to the prop getter')
133138
const { startTime, labelWidth, left } = interval
@@ -185,7 +190,7 @@ export type CustomHeaderWrapperProps<Data> = {
185190
children: (p: CustomDateHeaderProps<Data>) => ReactNode
186191
unit?: keyof TimelineTimeSteps
187192
headerData?: Data
188-
height: number
193+
height?: number | undefined
189194
}
190195

191196
function CustomHeaderWrapper<Data>({ children, unit, headerData, height }: CustomHeaderWrapperProps<Data>) {
@@ -206,8 +211,4 @@ function CustomHeaderWrapper<Data>({ children, unit, headerData, height }: Custo
206211
)
207212
}
208213

209-
CustomHeaderWrapper.defaultProps = {
210-
height: 30,
211-
}
212-
213214
export default CustomHeaderWrapper

src/lib/headers/Interval.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { getNextUnit, SelectUnits } from '../utility/calendar'
33
import { composeEvents } from '../utility/events'
44
import { Dayjs } from 'dayjs'
55
import { IntervalRenderer, Interval as IntervalType, GetIntervalProps } from '../types/main'
6-
7-
type GetIntervalPropsParams = {
8-
interval: IntervalType
9-
} & HTMLAttributes<HTMLDivElement>
6+
import { GetIntervalPropsType } from './types'
107

118
export type IntervalProps<Data> = {
129
intervalRenderer: (p: IntervalRenderer<Data>) => ReactNode
@@ -15,7 +12,7 @@ export type IntervalProps<Data> = {
1512
showPeriod: (startTime: Dayjs, endTime: Dayjs) => void
1613
intervalText: string
1714
primaryHeader: boolean
18-
getIntervalProps: (props?: GetIntervalPropsParams) => HTMLAttributes<HTMLDivElement>
15+
getIntervalProps: GetIntervalPropsType
1916

2017
headerData?: Data
2118
}
@@ -33,7 +30,7 @@ class Interval<Data> extends React.PureComponent<IntervalProps<Data>> {
3330
}
3431
}
3532

36-
getIntervalProps = (props: GetIntervalProps = {}): HTMLAttributes<HTMLDivElement> => {
33+
getIntervalProps = (props: GetIntervalProps = {}): HTMLAttributes<HTMLDivElement> & { key: string } => {
3734
return {
3835
...this.props.getIntervalProps({
3936
interval: this.props.interval,
@@ -58,11 +55,12 @@ class Interval<Data> extends React.PureComponent<IntervalProps<Data>> {
5855
/>
5956
)
6057
}
61-
58+
const { key, ...rest } = this.getIntervalProps()
6259
return (
6360
<div
6461
data-testid="dateHeaderInterval"
65-
{...this.getIntervalProps()}
62+
{...rest}
63+
key={key}
6664
className={`rct-dateHeader ${this.props.primaryHeader ? 'rct-dateHeader-primary' : ''}`}
6765
>
6866
<span>{intervalText}</span>

src/lib/headers/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { HTMLAttributes } from 'react'
2+
import { Interval } from '../types/main'
3+
4+
export type GetIntervalPropsParams = {
5+
interval: Interval
6+
} & HTMLAttributes<HTMLDivElement>
7+
export type GetIntervalPropsType = (props?: GetIntervalPropsParams) => HTMLAttributes<HTMLDivElement> & {
8+
key: string
9+
}

0 commit comments

Comments
 (0)