React Big Calendar Add Date Picker Instead Of Today Button - reactjs

I want to add a date picker instead of "Today" button. How can I make this?
If it is with only "Custom Toolbar" can you guys link a demo for that?
If it can't be happen I want to do this out of the calendar. When I choose a date it has to navigate. How can I do this?
Thanks

You can do this by providing a custom Toolbar component.
const { Navigate } from 'react-big-calendar';
export default function CustomToolbar({ date, view, views, label, onView, onNavigate, localizer }) {
// this only works if `newDate` is a true JS Date
const onPickerChange = (newDate) => onNavigate(Navigate.DATE, newDate);
// ... the rest of your Toolbar display
}
Then
<Calendar components={{toolbar: CustomToolbar}} />

If you don't want to provide your own Toolbar, you can add your own component for date picker (for example MUI) and use the onNavigate prop as mentioned in the docs https://jquense.github.io/react-big-calendar/examples/index.html?path=/docs/props--on-navigate

Related

Modify Ant Design (antd) time picker footer text

Is there any way to modify the text from the "Now" and "Ok" button in Ant Design Time Picker? Either using react or antd.
Thanks in advance.
You can control the text of the "Now" and "Ok" buttons by using the locale prop. You must provide a complete locale configuration, not just the lang.now and lang.ok properties. So you can import one of the standard language configs and merge them.
import { TimePicker } from "antd";
import "antd/dist/antd.css";
import locale from "antd/es/date-picker/locale/de_DE";
console.log(locale);
export default () => (
<TimePicker
locale={{
...locale,
lang: {
...locale.lang,
now: "Current Time",
ok: "Submit",
}
}}
/>
);
You can also set sitewide labels using a ConfigProvider.
I was looking at props if something is available to modify the footer, the only prop I found relevant to footer was 'renderExtraFooter', seems like there is nothing from ant that we can use to replace the text of these buttons.
However, there is a CSS way to replace the text using ::after selector like below.
a.ant-picker-now-btn {
font-size: 0;
}
a.ant-picker-now-btn:after {
content: "ABC";
font-size: 16px; /* original font size */
}
Sharing the codesandbox below -
https://codesandbox.io/s/basic-antd4150-forked-pyd95?file=/index.css

How to focus input date field in react?

Could you please tell me How to focus input date field in react?I am using a plugin of semantic
https://www.npmjs.com/package/semantic-ui-calendar-react
I want to focus date input field on button click here is my code.
here is my code
https://codesandbox.io/s/3l414mno5
focus = () => {
console.log(this.a);
this.a[0].onFocus();
// this.inputRef.focus()
};
the focus is not coming in input field why?
any update ?
To enable a focus on button click, you need to set a ref like this :
this.logButton = React.createRef();
ref={this.logButton}
and access it in button click like below:
focus = e => {
this.logButton.current.openPopup();
};
openPopup() - is a fucntion to open the calendar popup, the plugin your using, has code like this, check here
demo and In multiple data fields, use dynamic refs. Hope it helps.

How to create CallBack method to get value from another JS?

I have create CustomDatePicker.JS file for datePicker, for Android use the DatePickerAndroid and for ios use DatePickerIOS, and its use in my another Profile.js file. I use like below.
<CustomDatePicker ref='modal'></CustomDatePicker>
Now whenever will select the date, CustomDatePicker.JS class get the value but I want to the date value in Profile.js. So how can get date value in profile.
CustomDatePicker.JS : Here Will get date and time log.
Profile.js : Want to date which is selected on CustomDatePicker.
I hope, You are underStand...
Thanks.
In your Profile.js, i.e Profile component you can pass some callback fn as props like,
<CustomDatePicker
mode="date"
onDateChange={date => this.onDateChange(date)}
ref='modal'>
</CustomDatePicker>
In you CustomDatePicker.js, i.e CustomDatePicker component where you have defined DatePickerIOS, you can use those props.
<DatePickerIOS
{...this.props}
/>

How to get the selected dates? in react calendar

I downloaded react-native-material-calandarview inside my project.
They just give some piece of code to get calendar.
https://github.com/NuclleaR/react-native-material-calendarview.
I used that inside my render().
selectedDates={this.state.dates}......{this.state.dates} it gives undefined.
I need the selected dates array,but i cant get that.
where i get the selected dates???
Help me ASAP.Thanks in advance
The calendar expose you an event function onDateChange, you have just to setState in this event like that:
<Calendar
selectedDates={this.state.dates}
onDateChange={data => {
// Add the data to your state here
// for example:
this.setState(state => { dates: state.dates.push(data.date) });
}}
/>

Render selected item outside of input box for multi select of react-select library

How can we display the selected value just below the input box.
Use Case:
We are using multiple select of react-select , when we select the value from the select box , it comes inside the input box as selected. Can we have a method or something to get the selected values outside the input box (just below it)
Thanks in Advance!
I had a similar problem and I solved it creating a wrapper of react-select component and adding a state to my custom component. When the react-select changes I added the selected items to my component state and I show the in a custom div below, there you can add the styles that you want. Here an example of my approach: https://codesandbox.io/s/2kyy4998y
Hope this helps you.
Regards
I recently had to do this for a project I'm working on and wrote up how I did it here. The gist is that you need a wrapper component
// SelectWrapper.js
import ReactSelect from 'react-select'
const SelectWrapper = (props) => {
const { isMulti, value } = props;
return (
<div>
{isMulti ? value.map((val) => <span>{val.label}</span>) : null}
<Select {...props} controlShouldRenderValue={!isMulti} />
</div>
)
}
The very important part here is the controlShouldRenderValue prop which we disable when isMulti is true so the select dosn't show any selected values instead letting us take care of that

Resources