react-date-range icon indicating copy to clipboard operation
react-date-range copied to clipboard

Question: Is it possible to edit the left panel of DateRangePicker

Open Breigner01 opened this issue 3 years ago • 9 comments

Subject of the issue

So, I want to implement DateRangePicker on my website, the only issue is that the left panel (circled in red) doesn't have the presets that I need: image So my question is, can I somehow edit it through props? If so, how can I do it? I didn't seem to find how to do it.

Thanks in advance

[BUG] Bug Reproduce Steps

use a DateRangePicker component

[BUG] Expected behaviour

I'd like to be able to set these quick ranges to custom ones.

Environment

Package Version: 1.4.0 React version: 17.0.2 Node version: 17.3.0 Browser: Firefox Developer Edition 97.0b9

Breigner01 avatar Feb 03 '22 21:02 Breigner01

I have the same problem

stylder avatar Feb 06 '22 02:02 stylder

same

Multi-Thinker avatar Mar 01 '22 19:03 Multi-Thinker

Same problem. I want to remove that container

ArtNous avatar Mar 10 '22 17:03 ArtNous

To simply hide the container altogether, you can use CSS:

'.rdrDefinedRangesWrapper': {
  display: isMobile ? 'none' : 'block',
},

To edit what is inside the left panel, pass a new collection of static ranges:

const staticRanges = createStaticRanges([
  {
    label: 'Today',
    range: () => ({
      startDate: definedTimes.startOfToday,
      endDate: definedTimes.endOfToday,
    }),
  },
  {
    label: 'This Month',
    range: () => ({
      startDate: definedTimes.startOfMonth,
      endDate: definedTimes.endOfMonth,
    }),
  },
  {
    label: 'Last Month',
    range: () => ({
      startDate: definedTimes.startOfLastMonth,
      endDate: definedTimes.endOfLastMonth,
    }),
  },
  {
    label: 'Last 6 Months',
    range: () => ({
      startDate: definedTimes.startOfLastSixMonths,
      endDate: definedTimes.endOfMonth,
    }),
  },
]);

<DateRangePicker
  ...
  staticRanges={staticRanges}
/>

benjamincharity avatar Apr 13 '22 11:04 benjamincharity

staticRanges={[]}

With this, I have removed left panel but blank white space is still there of left panel.

React.useEffect(() => { document.getElementsByClassName('rdrDefinedRangesWrapper')[0].style.display = 'none'; }, []);

I have added this and removed white space also.

muskanjain16 avatar Apr 26 '22 11:04 muskanjain16

To simply hide the container altogether, you can use CSS:

'.rdrDefinedRangesWrapper': {
  display: isMobile ? 'none' : 'block',
},

To edit what is inside the left panel, pass a new collection of static ranges:

const staticRanges = createStaticRanges([
  {
    label: 'Today',
    range: () => ({
      startDate: definedTimes.startOfToday,
      endDate: definedTimes.endOfToday,
    }),
  },
  {
    label: 'This Month',
    range: () => ({
      startDate: definedTimes.startOfMonth,
      endDate: definedTimes.endOfMonth,
    }),
  },
  {
    label: 'Last Month',
    range: () => ({
      startDate: definedTimes.startOfLastMonth,
      endDate: definedTimes.endOfLastMonth,
    }),
  },
  {
    label: 'Last 6 Months',
    range: () => ({
      startDate: definedTimes.startOfLastSixMonths,
      endDate: definedTimes.endOfMonth,
    }),
  },
]);

<DateRangePicker
  ...
  staticRanges={staticRanges}
/>

is there a possibility to disable the selection of all dates when i click on particular date range For example , if i click on past year , i want the dates of last year not to be highlited but being selected in background

Sailokeshg avatar Jun 16 '22 06:06 Sailokeshg

Is there a possibility to disable the selection of all dates when i click on particular date range ? For example , if i click on past year , i want the dates of last year not to be highlited but being selected in background

Sailokeshg avatar Jun 16 '22 06:06 Sailokeshg

@benjamincharity Where definedTimes coming from?

bexoss avatar Aug 22 '22 01:08 bexoss

@benjamincharity Where definedTimes coming from?

@bexoss I took the base from this repo and edited it for my needs. See here: https://github.com/hypeserver/react-date-range/blob/master/src/defaultRanges.js

benjamincharity avatar Aug 23 '22 02:08 benjamincharity