2.0.0 β€’ Published 10 months ago

thaidatepicker-react v2.0.0

Weekly downloads
21
License
MIT
Repository
github
Last release
10 months ago

thaidatepicker-react

NPM NPM CodeQL Downloads


πŸŽ‰ RELEASE v2 πŸŽ‰

Thank you to everyone who used my little side project. I appreciate all you guys. Hope to keep it active.


πŸ“˜ About

The thaidatepicker-react is a component for ReactJS that likes other DatePicker library but all we need is Buddhist Year (25XX – aka Thai Year) come with the right render day on "Leap" year (example: Sat, 29 Feb 2020 must be equal to Sat, 29 Feb 2563) so I wish this component will be a useful thing to you :D. Happy Coding.

βš™ Install

npm install thaidatepicker-react
# or just `yarn add thaidatepicker-react`

πŸ“Œ Example Usage

import React, { useState } from "react";
import { ThaiDatePicker } from "thaidatepicker-react";

const App = () => {
  const [selectedDate, setSelectedDate] = useState("2024-02-29");
  const [selectedThaiDate, setSelectedThaiDate] = useState("2567-02-29");

  const handleDatePickerChange = (christDate, buddhistDate) => {
    console.log(christDate);
    console.log(buddhistDate);
    setSelectedDate(christDate);
    setSelectedThaiDate(buddhistDate);
  };

  return (
    <>
      <ThaiDatePicker
        value={selectedDate}
        onChange={handleDatePickerChange}
      />
      <div>christDate: {selectedDate}</div>
      <div>thaiDate: {selectedThaiDate}</div>
    </>
  );
};

export default App;

πŸ“‹ Properties

PropertyDescriptionTypeDefaultVersion
childrenthe children element inside like {children} by default you don't need to defined as props.React.ReactNode | nullnull
id#id for container elementstring"thdpk-container"
valueA christ date value with fixed dayjs format (YYYY-MM-DD)string""
onChangeHandle function with maximum 2 parameters, christDate and thaiDate(christDate: string, thaiDate: string) => void(_christDate: string, _thaiDate: string) => null
disabledDisabled property for inputbooleanfalse
readOnlyReadOnly property for inputbooleanfalse
clearableClear the value (please note clearable will work smoothly with onChange props)booleantrue
placeholderPlaceholder property for inputstring""
headerAn object for setting up header component. To change button icon use prevButtonIcon and nextButtonIcon. To change className of button and select use prevButtonClassName, nextButtonClassName, monthSelectClassName, and yearSelectClassNameObject { prevButtonIcon?: React.ReactNode; nextButtonIcon?: React.ReactNode; prevButtonClassName?: string; nextButtonClassName?: string; monthSelectClassName?: string; yearSelectClassName?: string; } | null }{}
yearBoundaryA config boundary Β±Year (e.g. yearBoundary = 2; it means currentYear Β± 2.)number99
inputPropsAn override input properties.(any & { displayFormat?: string; }) | nullnull
reactDatePickerPropsAn override react-datepicker properties. See more (https://reactdatepicker.com/ or https://github.com/Hacker0x01/react-datepicker/blob/master/docs/datepicker.md)React.ComponentProps{}
minDateA config minimum selectable date. To use, you can provide the string like 2023-01-31. (Note: It's will depend on yearBoundary too.)Date | stringundefined
maxDateA config maximum selectable date. To use, you can provide the string like 2023-12-31. (Note: It's will depend on yearBoundary too.)Date | stringundefined
highlightDatesA highlight selected date. To use, you can provide an array of Date like [new Date()](Date | HighlightDate)[]GetHighlightByDate()
customInputA config for using custom input element. To use, you can provide a name of element like InputReact.ComponentType | nullnull
noIntegratedStyleA config for define to exclude integrated css Note: if you using 2 components, which the first one contain noIntegratedStyle props but the second is not. It will import css and then it apply to them allbooleanfalsev2.0.0

πŸ“ Need More Example?

I made a couple difference stack demos. Try looking at the examples of "Vite" projects on ./example.

Changelog

Please see more CHANGELOG.md

License

MIT Β© buildingwatsize

βš’ Thanks a lot

2.0.0

10 months ago

1.3.6

11 months ago

1.3.5

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.0

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.3

2 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.0

5 years ago

0.1.1

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago