Back to Pinpoint

🍝 Rich Datetime Picker

web-frontend/src/main/v3/packages/datetime-picker/README.md

3.0.513.9 KB
Original Source

🍝 Rich Datetime Picker

Installation

How to use

tsx
import 'rich-datetime-picker/dist/rich-datetime-picker.css';
import { RichDatetimePicker } from 'rich-datetime-picker';

/** if you want to override style via cssModule */
import css from './RichDatetimePicker.module.scss';
import classNames from 'classnames/bind';

const cx = classNames.bind(css);


const now = new Date();
const [startDate, setStartDate] = React.useState<Date | null>(subMinutes(now, 5));
const [endDate, setEndDate] = React.useState<Date | null>(now);

const handleChange = (params: DateRange) => {
  setStartDate(params[0]);
  setEndDate(params[1]);
};

return (
   <RichDatetimePicker
    /** if you want to override style via cssModule */
    className={cx('datePickerContainer')}
    triggerClassName={cx('datePickerTrigger')}
    startDate={startDate}
    endDate={endDate}
    onChange={handleChange}
  />;
)

Props

PropsTypeDefaultDescription
startDateDate | nullDate of start
endDateDate | nullDate of end
classNamestringClassName of container
inputClassNamestringClassName of input
triggerClassNamestringClassName of trigger
panelClassNamestringClassName of panel
datePickerClassNamestringClassName of react-datepicker
displayedInputstringSet the displayed Input value directly.
minDateDateMinimum date that the user can select.
maxDateDateMax date that the user can select.
localeKey'en' | 'ko''en'Key of locale that should be used by the datetime picker and the calendar.
timeZonestring (IANA time zone information)Intl.DateTimeFormat().resolved.timeZoneKey of locale that should be used by the datetime picker and the calendar.
dateFormatstring'MMM do, hh:mm a'Input format based on Unicode tokens
seamTokenstring'-'Token connecting between dates
disablebooleanDisable input trigger
defaultOpenbooleanDetermining whether to open or not initially
hideCalendarYearButtonbooleanfalseHide/display year change buttons
timeUnitsTimeUnitFormat[]['5m', '20m', '1h', '3h', '6h', '12h', '1d', '2d']Time units for setting the time quickly
children((props: RichDatetimePickerListItemProps[]) => React.ReactNode) | React.ReactNode;Content to be included in the Panel of time units. You can freely include a variety of elements
customTimeViewReact.ReactNodeContent to be included in the CustomTimView. You can freely include a variety of elements
customTimeViewDirection'right' | 'left'Direction of CustomTimeView
customTimes[key: string]: string[]Relative: ['45m', '12hours', '10d', '2 weeks', 'last month', 'yesterday', 'today']
Fixed: ['Sep 1', 'Sep 1 - Sep 2', '9/1', '9/1 - 9/2', '09:00 AM - 05:00 PM']
Unix timestamps: 1693728134007 - 1693728434007Rendering to standardized specifications. The key becomes the subheader, and the array becomes the tag.
formatTag(ms: number) => string;Format time unit tag
formatListItemName(ms: number) => string;Format name of the quick list item
onChange(params: DateRange, text: string, timeUnit?: string) => void;Function called when the user picks a valid datetime or enter a valid datestring.
validateDatePickerRange(params: DateRange) => boolean;() => trueCheck date range validation in calendar
getPanelContainer() => HTMLElement | null;Renders the panel to the specified element.