hypeserver / react-date-range

A React component for choosing dates and date ranges.
MIT License
2.59k stars 672 forks source link

feat: InputDateRange label as a Component #389

Closed Spyna closed 3 years ago

Spyna commented 4 years ago

Added the possibility to add the label prop as a Component

Types of changes

What types of changes does your code introduce?

Put an x in the boxes that apply

Description

In order to have the possibility to use a Component as the label of InputRangeField, I'm proposing this change:

PropTypes.oneOfType([PropTypes.element, PropTypes.node]).isRequired,

So that you can use something like this:

const defaultInputRanges = [
  {
    label: <MyFancyReactComponent />,
    ...
  }
]

thank you :+1:

Spyna commented 4 years ago

By the way, it already works, but it gives a warning

VM2980:37 Warning: Failed prop type: Invalid prop `label` of type `object` supplied to `InputRangeField`, expected `string`.
    in InputRangeField (created by DefinedRange)
    in DefinedRange (created by DateRangePicker)
    in div (created by DateRangePicker)
kamyar commented 3 years ago

@Spyna I also added you as a collaborator. Given you have already opened a PR to contribute, in case you would be interested in getting involved more. 🚀 Obviously if you can not allocate time for the project feel free to decline the invite. :)