-
Notifications
You must be signed in to change notification settings - Fork 831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Ability to select a date range #364
Comments
I have think about that. We are now a little bit stack with a new features. So I will do it ASAP. |
Any chance this will be implemented soon? |
+1 |
+1, eagerly waiting for this |
@dmtrKovalenko Not to be a bother, but any chance you'll get to implementing this soon? |
+1 i need this |
+1 This feature will be much valued |
+1 |
2 similar comments
+1 |
+1 |
+100 |
I've written a quick and dirty wrapper making use of
|
I like it! |
I've put up a gist to share any changes I make. Gist |
Great to see the power of the community here! Kudos for @RedHatter! Sad to see that the repo owner rejected PR #508 |
I will start work on this issue in a few days 🔥🔥🔥 |
@dmtrKovalenko When we can take result of this feature? |
@dmtrKovalenko Thanks for the amazing component, when can we have this feature |
I suppose 1-2 weeks |
@dmtrKovalenko That's great news!! |
@dmtrKovalenko thanks for the great work you've done so far.. we are eagerly waiting for this feature... |
@RedHatter can you please fix your code to work in new version while we are waiting for this feature? |
so far i have this import React, {useContext, useState} from "react";
import PropTypes from "prop-types";
import {DateTimePicker, MuiPickersContext} from "@material-ui/pickers";
import classNames from "classnames";
import {FormattedMessage} from "react-intl";
import {checkInTime, checkOutTime, dateTimeFormat} from "holymotors-constants-date";
import {useStyles as useOriginalStyles} from "@material-ui/pickers/DatePicker/components/Day";
import useStyles from "./styles";
function DateRangeWrapper({value, onChange, labelFunc, format, emptyLabel, onClose, ...props}) {
const [begin, setBegin] = useState(value[0]);
const [end, setEnd] = useState(value[1]);
const [hover, setHover] = useState(undefined);
const originalClasses = useOriginalStyles();
const classes = useStyles();
const utils = useContext(MuiPickersContext);
const min = Math.min(begin, end || hover);
const max = Math.max(begin, end || hover);
function renderDay(day, selectedDate, dayInCurrentMonth, dayComponent) {
return React.cloneElement(dayComponent, {
onClick: e => {
e.stopPropagation();
if (!begin) setBegin(day);
else if (!end) {
setEnd(day);
} else {
setBegin(day);
setEnd(undefined);
}
},
onMouseEnter: e => setHover(day),
className: classNames(originalClasses.day, classes.day, {
[originalClasses.hidden]: dayComponent.props.hidden,
[originalClasses.current]: dayComponent.props.current,
[originalClasses.dayDisabled]: dayComponent.props.disabled,
[originalClasses.daySelected]: utils.isSameDay(day, min) || utils.isSameDay(day, max) || (day >= min && day <= max),
[classes.beginCap]: utils.isSameDay(day, min),
[classes.endCap]: utils.isSameDay(day, max),
}),
});
}
const formatDate = date => utils.format(date, dateTimeFormat);
return (
<DateTimePicker
{...props}
fullWidth
value={begin}
renderDay={renderDay}
onClose={onClose}
onChange={date => {
onChange([begin, end].sort((a, b) => a - b));
}}
onClear={() => {
setBegin(undefined);
setEnd(undefined);
setHover(undefined);
onChange([]);
}}
labelFunc={(date, invalid) =>
labelFunc
? labelFunc([begin, end].sort((a, b) => a - b), invalid)
: date && begin && end
? [begin, end].sort((a, b) => a - b).map(formatDate).join(" - ")
: emptyLabel || ""
}
/>
);
}
DateRangeWrapper.propTypes = {
value: PropTypes.array,
onChange: PropTypes.func,
labelFunc: PropTypes.func,
format: PropTypes.string,
emptyLabel: PropTypes.string,
onClose: PropTypes.func,
};
export default DateRangeWrapper; import {makeStyles} from "@material-ui/styles";
export default makeStyles(() => ({
day: {
margin: 0,
width: 40,
borderRadius: 0,
},
beginCap: {
borderTopLeftRadius: "50%",
borderBottomLeftRadius: "50%",
},
endCap: {
borderTopRightRadius: "50%",
borderBottomRightRadius: "50%",
},
}), {name: "DateRangeWrapper"}); |
@dmtrKovalenko this looks good, but i think we will want to be able to see all the dates highlighted after the user clicks. i.e. once the range is chosen, the dates in the range should all show up as green rather than just the last selected single date |
@dmtrKovalenko i see, it works but i have to click both text fields first in order for it to show up |
ideally, you would just be able to
If the first date picked is before the second date, the first date picked is the start date |
⬆️ this is how it is working now in chrome @jakeleventhal could you please record a video how it works for you? Thanks to you I just found a bug in safari |
it was tricky to get it working |
@jakeleventhal in your case it is a problem just because for now we have a prefilled date range for the first example. The initial value is This must be more obvious in the second example :) Yeah I will change examples and docs structure
|
@dmtrKovalenko : I have a list of suggestions, the problem and if I wrote them here they would be lost among all the comments, so if I wrote them then what you think are valid would you consider them? |
Yes please, I’d like to hear anything :) |
Is there a release timeline? Trying to get a sense of when this will be available so I can let our PO know. Thanks! |
@jvdownie first betas in Q2, stable maybe in v5, Q4. |
Hey bro, it's all right? (CANCEL) (APPLY) Thanks! |
@dmtrKovalenko https://dev.material-ui-pickers.dev/demo/daterangepicker work like charm! One feature request though, is it possible to select same date to make one day range? It currently gives validation error... |
@kirill-konshin Could you open a new issue about the same day range? |
@oliviertassinari #1759 done |
I have added the |
Does this mean that selecting a date range won't be free? Just curious. |
@balazsorban44 the high-level strategy is as follow:
Regarding the pricing, that would likely be approachable and come with a bunch of advances features spread among all the components, e.g tree view drag and drop, data grid virtualization, etc. |
This comment has been minimized.
This comment has been minimized.
Is there a blog post or something about which material-ui features will only be available in the enterprise version? |
@bbigras So far, advanced data grid, date range picker. Then likely, advanced scheduler, advanced tree view, advanced charting, advanced layouts (like in jupyterlab) |
Thank you very much. |
Thank you for this amazing component. Your work and contributions are very much appreciated.
It would be amazing if this component could also work to select a date range (similar to https://ipiz.herokuapp.com/md-date-range-picker-demo/index.html).
The text was updated successfully, but these errors were encountered: