tulsiojha / nepali-datepicker-react

Nepali Datepicker React is a lightweight, highly customizable, and feature-rich datepicker component, specifically designed for handling Nepali dates in React.js applications. It offers seamless integration, intuitive user experience, and extensive configuration options.
https://nepali-datepicker-react.ojhabikash.com.np/
MIT License
1 stars 0 forks source link

(feature): NepaliDatePicker component should be able to display formatted date. #10

Open dipbazz opened 4 days ago

dipbazz commented 4 days ago

As of now NepaliDatePicker component displays the date in YYYY-MM-DD format only, but if there is an option to display a formatted date it would be a great enhancement.

Current behavior.

import NepaliDatePicker from '@zener/nepali-datepicker-react';
import '@zener/nepali-datepicker-react/index.css';

const App = () => {
  const [value, setValue] = useState()
  return (
    <NepaliDatePicker
      value={value}
      onChange={(e) => {
        setValue(e);
      }}
      placeholder="Select date"
    />
  );
};

Output image

Expected behavior.

import NepaliDatePicker from '@zener/nepali-datepicker-react';
import '@zener/nepali-datepicker-react/index.css';

const App = () => {
  const [value, setValue] = useState()
  return (
    <NepaliDatePicker
      value={value}
      onChange={(e) => {
        setValue(e);
      }}
      placeholder="Select date"
      format="MMMM DD, YYYY"  // add a format props that will format the date in component.
    />
  );
};

Output image

tulsiojha commented 4 days ago

Hi @dipbazz, I can enable custom format for Datepicker component but then we will lose the ability to set date by typing in the text field.

dipbazz commented 4 days ago

Hi @tulsiojha, I was not aware about the ability to set date by typing. But is it required because most of the time people will use the picker options in my opinion. If you are concerned about the screen reader then may be the component should have some property to identify as screen reader where user can type the date only on the specified format. Can this be a solution? Or else based on the format the option to be able to type the date can be preserved or maybe there can be a flag specifies about the date that can be set with typing. Let me hear about your opinion.

tulsiojha commented 3 days ago

@dipbazz, I agree with you. Users would likely prefer selecting a date rather than typing it in manually. I will remove manual typing in and add format prop for input box.