# react-video-timelines-slider

> Time Slider component for React

Latest version **1.1.8** (published 2023-11-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-video-timelines-slider
pnpm add react-video-timelines-slider
yarn add react-video-timelines-slider
bun add react-video-timelines-slider
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.8 |
| Published | 2023-11-10 |
| First published | 2022-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 116.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Prakhar Shukla |
| Maintainers | prakhar144 |
| Keywords | react-component, react, slider, component, time-picker, react-slider, range-slider, range |

## Links

- npm: https://www.npmjs.com/package/react-video-timelines-slider
- Repository: https://github.com/prakhars144/react-video-timelines-slider
- Issues: https://github.com/prakhars144/react-video-timelines-slider/issues
- npm.io page: https://npm.io/package/react-video-timelines-slider

## Dependencies (5)

- [sass](https://npm.io/package/sass.md) ^1.56.1
- [d3-scale](https://npm.io/package/d3-scale.md) ^4.0.2
- [date-fns](https://npm.io/package/date-fns.md) ^2.19.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [react-compound-slider](https://npm.io/package/react-compound-slider.md) ^3.3.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.8 (latest) — 2023-11-10
- 1.1.7 — 2022-12-07
- 1.1.6 — 2022-12-07
- 1.1.5 — 2022-12-05
- 1.1.4 — 2022-12-01
- 1.1.3 — 2022-12-01
- 1.1.2 — 2022-11-30
- 1.1.1 — 2022-11-30
- 1.1.0 — 2022-11-30
- 1.0.3 — 2022-11-30
- 1.0.2 — 2022-11-30
- 1.0.1 — 2022-11-30
- 1.0.0 — 2022-11-30

## README

### react-video-timelines-slider
This project is forked from **react-timeline-range-slider** by [lizashkod](https://github.com/lizashkod) and it adds more functionality and security updates. The additional functionality includes support for
tooltips, tooltip format, enabling-disabling tooltip and hiding timeline error if gap is selected.

### Live demo
[codesandbox-demo](https://codesandbox.io/s/react-video-timelines-slider-0skcll?file=/src/App.js)

### Installation-steps

     npm i react-video-timelines-slider
### Props

| Prop | Type | Default | Description|
|--|--|--|--|
| timelineInterval | array |[startOfToday(), endOfToday()]|Interval to display|
|selectedInterval|array|[new Date(), addHours(new Date(), 1)]|Selected interval inside the timeline|
|disabledIntervals|array|[]|Array of disabled intervals inside the timeline|
|containerClassName|string||ClassName of the wrapping container|
|step|number|1800000|Number of milliseconds between steps (the default value is 30 minutes)|
|ticksNumber|number|48|Number of steps on the timeline (the default value is 30 minutes). Note that this is just a hint and actual tick might vary slightly|
|error|bool|false|Is the selected interval is not valid|
|mode|int/function|3|The interaction mode. Value of 1 will allow handles to cross each other. Value of 2 will keep the sliders from crossing and separated by a step. Value of 3 will make the handles pushable and keep them a step apart. ADVANCED: You can also supply a function that will be passed the current values and the incoming update. Your function should return what the state should be set as.|
|formatTick|function|ms => format(new Date(ms), 'HH:mm')|Function that determines the format in which the date will be displayed|
|formatTooltip|function|ms => format(new Date(ms), 'HH:mm:ss')|Function that determines the format in which the tooltip will be displayed|
|showTooltip|bool|true|enable-disable the tooltip|
|tooltipTag|string|"Value:"|Tag to appear before tooltip text|
|showTimelineError|bool|false|Turn timeline red if range with gap is selected|
|onUpdateCallback|function|||
|onChangeCallback|function|||

```javascript
import React from 'react'  
import { endOfToday, set } from 'date-fns' 
import TimeRange from 'react-video-timelines-slider'  

const now = new Date()
const getTodayAtSpecificHour = (hour = 12) =>
	set(now, { hours: hour, minutes: 0, seconds: 0, milliseconds: 0 })

const selectedStart = getTodayAtSpecificHour()
const selectedEnd = getTodayAtSpecificHour(14)

const startTime = getTodayAtSpecificHour(7)
const endTime = endOfToday()

const disabledIntervals = [
  { start: getTodayAtSpecificHour(16), end: getTodayAtSpecificHour(17) },
  { start: getTodayAtSpecificHour(7), end: getTodayAtSpecificHour(12) },
  { start: getTodayAtSpecificHour(20), end: getTodayAtSpecificHour(24) }
]

class App extends React.Component {  
  state = {  
    error: false,  
    selectedInterval: [selectedStart, selectedEnd],  
  }
	
  errorHandler = ({ error }) => this.setState({ error })  

  onChangeCallback = selectedInterval => this.setState({ selectedInterval })  

  render() {  
    const { selectedInterval, error } = this.state  
      return (  
        <TimeRange
          error={error}  
          ticksNumber={20}  
          step={1}
          selectedInterval={selectedInterval}  
          timelineInterval={[startTime, endTime]}  
          onUpdateCallback={this.errorHandler}  
          onChangeCallback={this.onChangeCallback}
          disabledIntervals={disabledIntervals} 
          formatTick={(ms) => format(new Date(ms), 'HH:mm:ss')} 
          formatTooltip={(ms) => format(new Date(ms), 'HH:mm:ss.SSS')}
          showTooltip={true}
          showTimelineError={false}
        />
      )  
  }  
}  

export default App
```

---
_Source: https://npm.io/package/react-video-timelines-slider · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
