Coder Social home page Coder Social logo

react-daterange-picker's People

Contributors

alanfoster avatar alistairjcbrown avatar andrewingram avatar balazsorban44 avatar blankmaker avatar chadnickbok avatar ckald avatar eliseumds avatar jkimbo avatar jontelm avatar josephmg avatar louy avatar maullerz avatar maxim-filimonov avatar moimikey avatar nicolassenechal avatar rolyatmax avatar stephen avatar stuartleigh avatar szubtsovskiy avatar walkerburgin avatar wmertens avatar yacinehmito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-daterange-picker's Issues

Updating both minimumDate and maximumDate fails to set new limits

Updating both minimumDate and maximumDate props fails to set new limits. Updating only one or other works as expected.

I added in some debug console.logs into componentWillReceiveProps function,

console.log('this.state.enabledRange', this.state.enabledRange.toString());
console.log('nextEnabledRange', nextEnabledRange.toString());
console.log('Immutable.is', _immutable2['default'].is(this.state.enabledRange, nextEnabledRange));
console.log('range.isSame', this.state.enabledRange.isSame(nextEnabledRange));

Console output

this.state.enabledRange 2015-06-29T00:00:00+01:00/2015-07-13T00:00:00+01:00
nextEnabledRange 2015-07-06T00:00:00+01:00/2015-07-20T00:00:00+01:00
Immutable.is true
range.isSame false

It looks like Immutable.is is giving a false positive that these two objects are the same - it can be seen that the date ranges are different. Given that this is comparing moment-range objects, rather than objects created by Immutable itself, is this working as expected?

Instead, would it be better to rely on the isSame function from the moment-range to compare the two?
Changing from Immutable.is to enabledRange.isSame solves the problem for me.

Release 1.0.0

Once 0.12.2 is released (#91) we should merge #79 and support React 0.14.x.
I feel that as part of this release we should update our version to 1.0.0, following semver semantics.

/cc @AndrewIngram @jkimbo Could you please review, merge and release as appropriate, as I do not have the permissions to do so.

Release 0.12.2

Current master (e8e7f86) reflects the work involved in a 0.12.2 release.

The main change involved in this release is locking down our peer dependency version of react to ^0.12.0 || ^0.13.0

/cc @AndrewIngram @jkimbo Could you please review and release as appropriate, as I do not have the permissions to do so.

On month or year change event

Is there an event to listen to changes made by user in range picker's UI?
For example I would like to know when user changes month - I want to render some additional info related with that month.

And I'm not talking about selection - this happens before user selects anything.
I checked the source code and I don't see that event but maybe I'm missing something.

Change locale

I am trying to change the locale, but I can't figure it out.

In my own code:

var moment = require('moment');
require('moment/locale/de');
moment.locale('de');

works just fine for my own moment() code. However, this never affects the datepicker.

When I go into a debugger in CalenderMonth.js, moment.locale() always returns "en". Changing it to "de" right there has no effect either; I am wondering if there is some confusion about "moment" and "moment-range", and that my "de" locale is never available in the right place.

Any ideas?

Allow Both Single and Range Selection

It would be great if you could allow both single and range selection. Based on the examples, they seem to be mutually exclusive right now. Is that true?

Cannot build

This is what I get on "gulp build-example-js":

ERROR in ./example/js/index.js
Module build failed: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (1:0)
at Parser.pp.raise

Date highlighted ranges display breaks if earlier date inserted in array after later date.

Initial data and result

screen shot 2015-08-09 at 6 28 41 pm

dateRanges: [{
        state: "enquire",
        range: moment.range(
            moment().add(2, "weeks").subtract(5, "days"),
            moment().add(2, "weeks").add(6, "days")
        )
    },
    {
        state: "unavailable",
        range: moment.range(
            moment().add(3, "weeks"),
            moment().add(3, "weeks").add(5, "days")
        )
    }
  ]

Data and result after modification

screen shot 2015-08-09 at 6 30 06 pm

dateRanges: [{
        state: "enquire",
        range: moment.range(
            moment().add(2, "weeks").subtract(5, "days"),
            moment().add(2, "weeks").add(6, "days")
        )
    },
    {
        state: "unavailable",
        range: moment.range(
            moment().add(3, "weeks"),
            moment().add(3, "weeks").add(5, "days")
        )
    },
    {
        state: "unavailable",
        range: moment.range(
            moment().add(3, "days"),
            moment().add(5, "days")
        )
    }
  ]

Im getting error

TypeError: undefined is not a function
    at [object Object].getEnabledRange (/src/node_modules/react-daterange-picker/dist/DateRangePicker.js:183:32)
    at [object Object].getInitialState (/src/node_modules/react-daterange-picker/dist/DateRangePicker.js:174:26)
    at new Constructor (/src/node_modules/react/lib/ReactClass.js:853:54)
    at [object Object].ReactCompositeComponentMixin.mountComponent (/src/node_modules/react/lib/ReactCompositeComponent.js:135:16)
    at Object.ReactReconciler.mountComponent (/src/node_modules/react/lib/ReactReconciler.js:38:35)
    at ReactDOMComponent.ReactMultiChild.Mixin.mountChildren (/src/node_modules/react/lib/ReactMultiChild.js:192:44)
    at ReactDOMComponent.Mixin._createContentMarkup (/src/node_modules/react/lib/ReactDOMComponent.js:289:32)
    at ReactDOMComponent.Mixin.mountComponent (/src/node_modules/react/lib/ReactDOMComponent.js:199:12)
    at Object.ReactReconciler.mountComponent (/src/node_modules/react/lib/ReactReconciler.js:38:35)
    at [object Object].ReactCompositeComponentMixin.mountComponent (/src/node_modules/react/lib/ReactCompositeComponent.js:247:34)

Im getting this error , on my production , server .
Env
Running on Ubunut 14 Docker Ubuntu 14.
Node ver 12.4
React 13 .
NODE_ENV=production ,
NODE_PATH=./src.
babbel.js

i have no clue , what is the problem. some how moment-range module doesn't have .range fn .

 inside getEnabledRange() , moment obj doesnt have .range fn 

on my dev machine everything works as expected

Object assign is undefined

I am getting an error Object.assign is undefined from BemMixin.js. I am using it in my code by doing an npm install and then bundling it using webpack. Am I missing something here? My chrome version is Version 41.0.2272.89 (64-bit)

screen shot 2015-03-21 at 7 40 59 pm

End date not highlighted when it is the first cell on a calendar's grid

To recreate:

  • Open demo page and go to the first example (where Sunday is the first day of the week, which is key to recreating the bug)
  • Page through the calendars so that Oct 2015 is the first calendar
  • Pick any date in Oct as the start date
  • Drag the range until you are hovering over Nov 1 (should be the first day on the second calendar's grid)

The date doesn't get any highlighting. If you click it as the end date, it correctly recognizes it but the CSS is never applied. Same thing happens under similar circumstances. See, for example, Jan-Feb 2016 on the first calendar on the demo page (where Mon is the start of the week).

demo is broken

Uncaught Error: Invariant Violation: You're trying to render a component to the document using server rendering but the checksum was invalid. This usually means you rendered a different component type or props on the client from the one on the server, or your render() methods are impure. React cannot handle this case due to cross-browser quirks by rendering at the document root. You should look for environment dependent code in your components and ensure the props are the same client and server side.

Fix Windows Mobile

Annoyingly, Windows Mobile triggers both touch and mouse events which kinda messes everything up. It's possible that devices like the Microsoft Surface have similar issues. Not sure if this is just a browserstack issue, it might be triggering both types of events to cover all bases.

If anyone has access to a Windows Mobile device and would like to check, that'd be great

Equal height months

A month can have a range of weeks, from 4-6 depending on start date. It can be a little jarring that the height of the calendar table can vary as your paginate. Instead we should (optionally?) pad out all months to 6 weeks so that the heights remain the same.

Multi date picker?

Is it possible to select multiple dates (not a range) with the date picker?

Last date of the month is not selected if it's also the last day of the week.

Examples:
May 31th, 2014

{
    firstOfWeek: 0
    value: moment.range(moment(1401483600000).startOf("day"), moment(1401483600000).add(2, "days"))
}

November 30th, 2014

{
    firstOfWeek: 1
    value: moment.range(moment(1412024400000).startOf("day"), moment(1412024400000).add(2, "days"))
}

Looking into the code, moment ranges do not overlap in these cases despite month.end.valueOf() == value.start.valueOf().
See moment.range issue

Pull request with a fix is coming soon

Not supported with react 13.0

This plugin doesn't work with react 13.0. I need the latest version for some updated mixins, but cannot use this component

half day range select possible?

I'm working on something to allow user to select date ranges including half days, for example, an employee can choose on vacation from afternoon, or asking for leave for a half day, is that possible?

Enable Travis

Once #72 is merged, we should have Travis running as our CI. This will also help provide the certainty that the React 0.14.x upgrade is working as expected too

Unfortunately I don't have Admin rights for this currently; Could we enable this please -

image

/cc @AndrewIngram @jkimbo

Documentation

Loving the library, but a bit frustrated with the lack of docs in a 1.0.0 release. I'll be happy to help, but I'm new to the library and its going to take a while to pick through the code and figure out how everything works.

To focus a particular month

Is there a way to focus (display by default) a particular month? I tried the initialDate and initialMonth prop and it does not seem to work. I am not sure whether I am doing it the right way. Is there any known issue?

Update moment-range dependency

moment-range is now on v2.x - but react-daterange-picker is capped at ^1.2.0

It would be good to upgrade this dependency

Warning: owner-based and parent-based contexts differ

I'm trying to set up DatePicker but I'm getting tons of warnings in console

Warning: owner-based and parent-based contexts differ (values: `undefined` vs `DateRangePicker`) for key (bemBlock) while mounting PaginationArrow
Warning: owner-based and parent-based contexts differ (values: `undefined` vs `null`) for key (bemNamespace) while mounting PaginationArrow

I figured out that problem is in BemMixin
Somehow context wasn't transferred to child components

Add a target for paging whilst dragging

At the moment we have a hidden feature where dragging a selection over the next/previous arrows will trigger pagination. We need to make this more obvious, and pretty.

Uncaught TypeError: Cannot read property 'add' of undefined using the provided snippet

Having the following component I get Uncaught TypeError: Cannot read property 'add' of undefined which points to moment().add(2, 'weeks').subtract(5, 'days')

import React from 'react/addons';
import DateRangePicker from 'react-daterange-picker';
import moment from 'moment-range';
import mui from 'material-ui';
import injectTapEventPlugin from 'react-tap-event-plugin';

// Get mui Components
let ThemeManager = new mui.Styles.ThemeManager();
const stateDefinitions = {
  available: {
    color: null,
    label: 'Available',
  },
  enquire: {
    color: '#ffd200',
    label: 'Enquire',
  },
  unavailable: {
    selectable: false,
    color: '#78818b',
    label: 'Unavailable',
  },
};

const dateRanges = [
  {
    state: 'enquire',
    range: moment.range(
      moment().add(2, 'weeks').subtract(5, 'days'),
      moment().add(2, 'weeks').add(6, 'days')
    ),
  },
  {
    state: 'unavailable',
    range: moment.range(
      moment().add(3, 'weeks'),
      moment().add(3, 'weeks').add(5, 'days')
    ),
  },
];
class Appointments extends React.Component {

    /*static willTransitionTo(transition) {
        //go to login page
        transition.redirect('/login');
    }*/

    constructor(props) {
        super(props);
        this.state = {value: null };
    }

    handleSelect(range, states) {
        // range is a moment-range object
        this.setState({
            value: range,
            states: states,
        });
    }

    render() {

        return (
            <DateRangePicker
                firstOfWeek={1}
                numberOfCalendars={2}
                selectionType='range'
                earliestDate={new Date()}
                stateDefinitions={stateDefinitions}
                dateStates={dateRanges}
                defaultState="available"
                showLegend={true}
                value={this.state.value}
                onSelect={this.handleSelect} />
                );
    }

}

 Appointments.childContextTypes = {
  muiTheme: React.PropTypes.object
};


Appointments.contextTypes = {
  router: React.PropTypes.func
};

export default Appointments;

Performance improvements

There should be some quick wins here by implementing shouldComponentUpdate on the Date components so that only the affected date needs to re-render.

Related: #31

Selecting a single day

Could it be possible to select a single day ?
Perhaps by clicking on a day, and then clicking on the same day to end the selection ?

What do you think ?

Anyway, thanks for this awesome picker !

Not require selectedLabel and hide if empty

Hi,

Can we make it possible to hide selectedLabel? When I using the calendar just to show dates available / unavailable and set selectable to false, I still get the selectedLabel.

Here is a fix. (I'm new to contributing to repos and had problems to run "npm run lint" and "npm run test")

bookingbricks@cc3aa61

Thanks for a nice component btw, exactly what I looking for.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.