diff --git a/docs-site/package.json b/docs-site/package.json
index 72a9775c11..a8e2b65af2 100644
--- a/docs-site/package.json
+++ b/docs-site/package.json
@@ -16,14 +16,18 @@
},
"scripts": {
"start": "vite",
- "build": "vite build",
+ "build": "tsc && vite build",
"lint": "eslint .",
- "preview": "vite preview"
+ "preview": "vite preview",
+ "type-check": "tsc --noEmit"
},
"devDependencies": {
"@eslint/js": "^9.25.0",
+ "@types/lodash": "^4.17.11",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
+ "@typescript-eslint/eslint-plugin": "^7.0.0",
+ "@typescript-eslint/parser": "^7.0.0",
"@vitejs/plugin-react": "^4.4.1",
"eslint": "^9.25.0",
"eslint-plugin-react": "^7.37.5",
@@ -31,6 +35,7 @@
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"sass": "^1.86.3",
+ "typescript": "^5.3.3",
"vite": "^6.3.2"
},
"packageManager": "yarn@4.6.0"
diff --git a/docs-site/src/components/Example/index.jsx b/docs-site/src/components/Example/index.tsx
similarity index 61%
rename from docs-site/src/components/Example/index.jsx
rename to docs-site/src/components/Example/index.tsx
index f45a158f6c..74529ff556 100644
--- a/docs-site/src/components/Example/index.jsx
+++ b/docs-site/src/components/Example/index.tsx
@@ -12,16 +12,44 @@ import slugify from "slugify";
import range from "lodash/range";
import { themes } from "prism-react-renderer";
import editIcon from "./edit-regular.svg";
+import { IExampleConfig } from "../../types";
+
+type TState = {
+ activeTab: "js" | "ts";
+};
+
+type TProps = {
+ example: IExampleConfig;
+};
+
+export default class CodeExampleComponent extends React.Component<
+ TProps,
+ TState
+> {
+ state: TState = {
+ activeTab: "js",
+ };
-export default class CodeExampleComponent extends React.Component {
componentDidMount() {
registerLocale("fi", fi);
registerLocale("pt-BR", ptBR);
registerLocale("en-GB", enGB);
}
+ handleTabChange = (tab: TState["activeTab"]) => {
+ this.setState({ activeTab: tab });
+ };
+
render() {
- const { title, description, component } = this.props.example;
+ const { title, description, component, componentTS } = this.props.example;
+ const { activeTab } = this.state;
+
+ const jsCode = component.trim();
+ const tsCode = componentTS?.trim();
+
+ const code = activeTab === "js" ? jsCode : tsCode;
+ const isTS = activeTab === "ts";
+
return (
{title}
{description &&
{description}
}
+
+
+ {tsCode && (
+
+ )}
+
+ Full docs for the underlying library that manages the overlay used can
+ be found at{" "}
+
+ floating-ui.com
+
+
+ ),
+ componentTS: configureFloatingUIS,
+ },
+ {
+ title: "Custom input",
+ component: CustomInput,
+ componentTS: customInputTS,
+ },
+ {
+ title: "Custom header",
+ component: RenderCustomHeader,
+ componentTS: renderCustomHeaderTS,
+ },
+ {
+ title: "Custom header with two months displayed",
+ component: RenderCustomHeaderTwoMonths,
+ componentTS: renderCustomHeaderTwoMonthsTS,
+ },
+ {
+ title: "Custom Day",
+ component: RenderCustomDay,
+ componentTS: renderCustomDayTS,
+ },
+ {
+ title: "Custom Month",
+ component: RenderCustomMonth,
+ componentTS: renderCustomMonthTS,
+ },
+ {
+ title: "Custom Quarter",
+ component: RenderCustomQuarter,
+ componentTS: renderCustomQuarterTS,
+ },
+ {
+ title: "Custom Year",
+ component: RenderCustomYear,
+ componentTS: renderCustomYearTS,
+ },
+ {
+ title: "Custom calendar class name",
+ component: CustomCalendarClassName,
+ componentTS: customCalendarClassNameTS,
+ },
+ {
+ title: "Custom class name",
+ component: CustomClassName,
+ componentTS: customClassNameTS,
+ },
+ {
+ title: "Custom day class name",
+ component: CustomDayClassName,
+ componentTS: customDayClassNameTS,
+ },
+ {
+ title: "Custom date format",
+ component: CustomDateFormat,
+ componentTS: customDateFormatTS,
+ },
+ {
+ title: "Custom time class name",
+ component: CustomTimeClassName,
+ componentTS: customTimeClassNameTS,
+ },
+ {
+ title: "Custom time input",
+ component: CustomTimeInput,
+ componentTS: customTimeInputTS,
+ },
+ {
+ title: "Date Range",
+ component: DateRange,
+ componentTS: dateRangeTS,
+ },
+ {
+ title: "Date range for one datepicker",
+ component: SelectsRange,
+ componentTS: selectsRangeTS,
+ },
+ {
+ title: "Date range for one datepicker with disabled dates highlighted",
+ component: selectsRangeWithDisabledDates,
+ componentTS: selectsRangeWithDisabledDatesTS,
+ },
+ {
+ title: "Date Range with disabled navigation shown",
+ component: DateRangeWithShowDisabledNavigation,
+ componentTS: dateRangeWithShowDisabledNavigationTS,
+ },
+ {
+ title: "Date Range using input with clear button",
+ component: DateRangeInputWithClearButton,
+ componentTS: dateRangeInputWithClearButtonTS,
+ },
+ {
+ title: "Date Range with Portal",
+ component: DateRangeWithPortal,
+ componentTS: dateRangeWithPortalTS,
+ },
+ {
+ title: "Disable datepicker",
+ component: Disabled,
+ componentTS: disabledTS,
+ },
+ {
+ title: "Disable keyboard navigation",
+ component: DisabledKeyboardNavigation,
+ componentTS: disabledKeyboardNavigationTS,
+ },
+ {
+ title: "Display Week Numbers",
+ component: WeekNumbers,
+ componentTS: weekNumbersTS,
+ },
+ {
+ title: "Don't hide calendar on date selection",
+ component: DontCloseOnSelect,
+ componentTS: dontCloseOnSelectTS,
+ },
+ {
+ title: "Exclude dates",
+ component: ExcludeDates,
+ componentTS: excludeDatesTS,
+ },
+ {
+ title: "Exclude dates with message",
+ component: ExcludedWithMessage,
+ componentTS: excludeDatesWithMessageTS,
+ },
+ {
+ title: "Exclude date intervals",
+ component: ExcludeDateIntervals,
+ componentTS: excludeDateIntervalsTS,
+ },
+ {
+ title: "Exclude Months in Month Picker",
+ component: ExcludeDatesMonthPicker,
+ componentTS: excludeDatesMonthPickerTS,
+ },
+ {
+ title: "Exclude Months in Range Month Picker",
+ component: ExcludeDatesRangeMonthPicker,
+ componentTS: excludeDatesRangeMonthPickerTS,
+ },
+ {
+ title: "Exclude Times",
+ component: ExcludeTimes,
+ componentTS: excludeTimesTS,
+ },
+ {
+ title: "Filter dates",
+ component: FilterDates,
+ componentTS: filterDatesTS,
+ },
+ {
+ title: "Filter times",
+ component: FilterTimes,
+ componentTS: filterTimesTS,
+ },
+ {
+ title: "Fixed height of Calendar",
+ component: FixedCalendar,
+ componentTS: fixedCalendarTS,
+ },
+ {
+ title: "Get raw input value on change",
+ component: RawChange,
+ componentTS: rawChangeTS,
+ },
+ {
+ title: "Highlight dates",
+ component: HighlightDates,
+ componentTS: highlightDatesTS,
+ },
+ {
+ title: "Highlight dates with custom class names and ranges",
+ component: HighlightDatesRanges,
+ componentTS: highlightDatesRangesTS,
+ },
+ {
+ title: "Holiday dates",
+ component: HolidayDates,
+ componentTS: holidayDatesTS,
+ },
+ {
+ title: "Include dates",
+ component: IncludeDates,
+ componentTS: includeDatesTS,
+ },
+ {
+ title: "Include date intervals",
+ component: IncludeDateIntervals,
+ componentTS: includeDateIntervalsTS,
+ },
+ {
+ title: "Include Months in Month Picker",
+ component: IncludeDatesMonthPicker,
+ componentTS: includeDatesMonthPickerTS,
+ },
+ {
+ title: "Include Times",
+ component: IncludeTimes,
+ componentTS: includeTimesTS,
+ },
+ {
+ title: "Inject Specific Times",
+ component: InjectTimes,
+ componentTS: injectTimesTS,
+ },
+ {
+ title: "Inline version",
+ component: Inline,
+ componentTS: inlineTS,
+ },
+ {
+ title: "Button to show Inline version",
+ component: InlineVisible,
+ componentTS: inlineVisibleTS,
+ },
+ {
+ title: "Input time",
+ component: TimeInput,
+ componentTS: timeInputTS,
+ },
+ {
+ title: "Locale",
+ component: Locale,
+ componentTS: localeTS,
+ },
+ {
+ title: "Locale with time",
+ component: LocaleWithTime,
+ componentTS: localeWithTimeTS,
+ },
+ {
+ title: "Locale without global variables",
+ component: LocaleWithoutGlobalVariable,
+ componentTS: localeWithoutGlobalVariableTS,
+ },
+ {
+ title: "Min date",
+ component: MinDate,
+ componentTS: minDateTS,
+ },
+ {
+ title: "Max date",
+ component: MaxDate,
+ componentTS: maxDateTS,
+ },
+ {
+ title: "Month Picker",
+ component: MonthPicker,
+ componentTS: monthPickerTS,
+ },
+ {
+ title: "Month Picker with Full Name",
+ component: monthPickerFullName,
+ componentTS: monthPickerFullNameTS,
+ },
+ {
+ title: "Month Picker Two Columns Layout",
+ component: monthPickerTwoColumns,
+ componentTS: monthPickerTwoColumnsTS,
+ },
+ {
+ title: "Month Picker Four Columns Layout",
+ component: monthPickerFourColumns,
+ componentTS: monthPickerFourColumnsTS,
+ },
+ {
+ title: "Month dropdown",
+ component: MonthDropdown,
+ componentTS: monthDropdownTS,
+ },
+ {
+ title: "Month dropdown short month",
+ component: MonthDropdownShort,
+ componentTS: monthDropdownShortTS,
+ },
+ {
+ title: "MonthYear dropdown",
+ component: MonthYearDropdown,
+ componentTS: monthYearDropdownTS,
+ },
+ {
+ title: "Multiple months",
+ component: MultiMonth,
+ componentTS: multiMonthTS,
+ },
+ {
+ title: "Multiple months with year dropdown",
+ component: MultiMonthDropdown,
+ componentTS: multiMonthDropdownTS,
+ },
+ {
+ title: "Multiple months inline",
+ component: MultiMonthInline,
+ componentTS: multiMonthInlineTS,
+ },
+ {
+ title: "No Anchor Arrow",
+ component: NoAnchorArrow,
+ componentTS: noAnchorArrowTS,
+ },
+ {
+ title: "onBlur callbacks in console",
+ component: OnBlurCallbacks,
+ componentTS: onBlurCallbacksTS,
+ },
+ {
+ title: "Open to date",
+ component: OpenToDate,
+ componentTS: openToDateTS,
+ },
+ {
+ title: "Placeholder text",
+ component: PlaceholderText,
+ componentTS: placeholderTextTS,
+ },
+ {
+ title: "Portal version",
+ component: Portal,
+ componentTS: portalTS,
+ },
+ {
+ title: "Portal by id",
+ description:
+ "If the provided portalId cannot be found in the dom, one will be created by default with that id.",
+ component: PortalById,
+ componentTS: portalByIdTS,
+ },
+ {
+ title: "Portal version with portal by id",
+ description:
+ "If the provided portalId cannot be found in the dom, one will be created by default with that id.",
+ component: WithPortalById,
+ componentTS: withPortalByIdTS,
+ },
+ {
+ title: "Quarter Picker",
+ component: QuarterPicker,
+ componentTS: quarterPickerTS,
+ },
+ {
+ title: "Range Month Picker",
+ component: RangeMonthPicker,
+ componentTS: rangeMonthPickerTS,
+ },
+ {
+ title: "Range Month Picker for one month picker",
+ component: RangeMonthPickerSelectsRange,
+ componentTS: rangeMonthPickerSelectsRangeTS,
+ },
+ {
+ title: "Range Quarter Picker",
+ component: RangeQuarterPicker,
+ componentTS: rangeQuarterPickerTS,
+ },
+ {
+ title: "Range Quarter Picker for one quarter picker",
+ component: RangeQuarterPickerSelectsRange,
+ componentTS: rangeQuarterPickerSelectsRangeTS,
+ },
+ {
+ title: "Range Swap Range",
+ description:
+ "Swap the start and end date if the end date is before the start date in a pick sequence.",
+ component: RangeSwapRange,
+ componentTS: rangeSwapRangeTS,
+ },
+ {
+ title: "Read only datepicker",
+ component: ReadOnly,
+ componentTS: readOnlyTS,
+ },
+ {
+ title: "Select Time",
+ component: ShowTime,
+ componentTS: showTimeTS,
+ },
+ {
+ title: "Select Time Only",
+ component: ShowTimeOnly,
+ componentTS: showTimeOnlyTS,
+ },
+ {
+ title: "Hide Time Caption",
+ component: HideTimeCaption,
+ componentTS: hideTimeCaptionTS,
+ },
+ {
+ title: "Show previous months",
+ component: MultiMonthPrevious,
+ componentTS: multiMonthPreviousTS,
+ },
+ {
+ title: "Specific date range",
+ component: SpecificDateRange,
+ componentTS: specificDateRangeTS,
+ },
+ {
+ title: "Specific Time Range",
+ component: ExcludeTimePeriod,
+ componentTS: excludeTimePeriodTS,
+ },
+ {
+ title: "Select multiple dates",
+ component: SelectsMultiple,
+ componentTS: selectsMultipleTS,
+ },
+ {
+ title: "Select multiple months",
+ component: SelectsMultipleMonths,
+ componentTS: selectsMultipleMonthsTS,
+ },
+ {
+ title: "Strict parsing",
+ description:
+ "Enables strict format validation for manual date input. When this flag is activated, the component will only accept values that exactly match the specified date format (`dateFormat`).",
+ component: StrictParsing,
+ componentTS: strictParsingTS,
+ },
+ {
+ title: "TabIndex",
+ component: TabIndex,
+ componentTS: tabIndexTS,
+ },
+ {
+ title: "Today button",
+ component: Today,
+ componentTS: todayTS,
+ },
+ {
+ title: "Year Picker",
+ component: YearPicker,
+ componentTS: yearPickerTS,
+ },
+ {
+ title: "Range Year Picker",
+ component: RangeYearPicker,
+ componentTS: rangeYearPickerTS,
+ },
+ {
+ title: "Range Year Picker for one datepicker",
+ component: RangeYearPickerSelectsRange,
+ componentTS: rangeYearPickerSelectsRangeTS,
+ },
+ {
+ title: "Year dropdown",
+ component: YearDropdown,
+ componentTS: yearDropdownTS,
+ },
+ {
+ title: "Year select dropdown",
+ component: YearSelectDropdown,
+ componentTS: yearSelectDropdownTS,
+ },
+ {
+ title: "Year item number",
+ component: YearItemNumber,
+ componentTS: yearItemNumberTS,
+ },
+ {
+ title: "Calendar Start day",
+ component: CalendarStartDay,
+ componentTS: calendarStartDayTS,
+ },
+ {
+ title: "Week Picker",
+ component: WeekPicker,
+ componentTS: weekPickerTS,
+ },
+ {
+ title: "Exclude Weeks",
+ component: ExcludeWeeks,
+ componentTS: excludeWeeksTS,
+ },
+ {
+ title: "External Form",
+ component: ExternalForm,
+ componentTS: externalFormTS,
+ },
+];
diff --git a/docs-site/src/components/Examples/examples.scss b/docs-site/src/components/Examples/examples.scss
index 9c38c04cec..34f7081944 100644
--- a/docs-site/src/components/Examples/examples.scss
+++ b/docs-site/src/components/Examples/examples.scss
@@ -68,6 +68,30 @@
margin-bottom: 20px;
}
+ &__tabs {
+ display: flex;
+ }
+
+ &__tab {
+ font-family: "Open Sans", sans-serif;
+ box-sizing: border-box;
+ padding: 8px;
+ border: none;
+ border-bottom: 2px solid transparent;
+ background: none;
+ cursor: pointer;
+ font-size: 14px;
+ transition: all 0.2s ease;
+ }
+
+ &__tab:hover {
+ border-bottom: 2px solid #216ba5;
+ }
+
+ &__tab.active {
+ border-bottom: 2px solid #216ba5;
+ }
+
&__code {
position: relative;
background-color: #f5f8fb;
@@ -75,8 +99,7 @@
margin-left: -20px;
border-top: 1px solid #d8e4ef;
border-bottom: 1px solid #d8e4ef;
- overflow-x: auto;
- overflow-y: hidden;
+ overflow: auto hidden;
@include helpers.breakpoint(768px) {
width: 70%;
@@ -98,15 +121,19 @@
z-index: 10;
}
}
+
&__preview {
padding: 20px;
+
@include helpers.breakpoint(768px) {
width: 30%;
}
+
@media (max-width: 768px) {
padding-left: 0;
}
}
+
example-portal-by-id {
position: relative;
overflow: hidden;
@@ -121,9 +148,11 @@
.react-datepicker__week:nth-child(3n + 1) {
background-color: #215005;
}
+
.react-datepicker__week:nth-child(3n + 2) {
background-color: #eea429;
}
+
.react-datepicker__week:nth-child(3n + 3) {
background-color: #a82a15;
}
diff --git a/docs-site/src/components/Examples/hero.scss b/docs-site/src/components/Examples/hero.scss
index a9f34dd041..35ebc67aff 100644
--- a/docs-site/src/components/Examples/hero.scss
+++ b/docs-site/src/components/Examples/hero.scss
@@ -6,6 +6,7 @@
&__content {
@extend %container-styling;
+
text-align: center;
padding: 175px 0;
}
diff --git a/docs-site/src/components/Examples/index.jsx b/docs-site/src/components/Examples/index.jsx
deleted file mode 100644
index 0584f09c3a..0000000000
--- a/docs-site/src/components/Examples/index.jsx
+++ /dev/null
@@ -1,609 +0,0 @@
-import React from "react";
-import hljs from "highlight.js/lib/core";
-import hljsJavaScriptLanguage from "highlight.js/lib/languages/javascript";
-import slugify from "slugify";
-import CodeExampleComponent from "../Example/index.jsx";
-
-import Default from "../../examples/default?raw";
-import NoAnchorArrow from "../../examples/noAnchorArrow?raw";
-import ShowTime from "../../examples/showTime?raw";
-import ShowTimeOnly from "../../examples/showTimeOnly?raw";
-import HideTimeCaption from "../../examples/hideTimeCaption?raw";
-import ExcludeTimes from "../../examples/excludeTimes?raw";
-import IncludeTimes from "../../examples/includeTimes?raw";
-import InjectTimes from "../../examples/injectTimes?raw";
-import FilterTimes from "../../examples/filterTimes?raw";
-import ExcludeTimePeriod from "../../examples/excludeTimePeriod?raw";
-import CustomDateFormat from "../../examples/customDateFormat?raw";
-import CustomClassName from "../../examples/customClassName?raw";
-import CustomCalendarClassName from "../../examples/customCalendarClassName?raw";
-import CustomDayClassName from "../../examples/customDayClassName?raw";
-import CustomTimeClassName from "../../examples/customTimeClassName?raw";
-import Today from "../../examples/today?raw";
-import PlaceholderText from "../../examples/placeholderText?raw";
-import SpecificDateRange from "../../examples/specificDateRange?raw";
-import MinDate from "../../examples/minDate?raw";
-import MaxDate from "../../examples/maxDate?raw";
-import DateRangeWithShowDisabledNavigation from "../../examples/dateRangeWithShowDisabledNavigation?raw";
-import Locale from "../../examples/locale?raw";
-import LocaleWithTime from "../../examples/localeWithTime?raw";
-import LocaleWithoutGlobalVariable from "../../examples/localeWithoutGlobalVariable?raw";
-import ExcludeDates from "../../examples/excludeDates?raw";
-import ExcludedWithMessage from "../../examples/excludeDatesWithMessage?raw";
-import ExcludeDateIntervals from "../../examples/excludeDateIntervals?raw";
-import ExcludeDatesMonthPicker from "../../examples/excludeDatesMonthPicker?raw";
-import ExcludeDatesRangeMonthPicker from "../../examples/excludeDatesRangeMonthPicker?raw";
-import HighlightDates from "../../examples/highlightDates?raw";
-import HolidayDates from "../../examples/holidayDates?raw";
-import HighlightDatesRanges from "../../examples/highlightDatesRanges?raw";
-import IncludeDates from "../../examples/includeDates?raw";
-import IncludeDateIntervals from "../../examples/includeDateIntervals?raw";
-import IncludeDatesMonthPicker from "../../examples/includeDatesMonthPicker?raw";
-import FilterDates from "../../examples/filterDates?raw";
-import DateRange from "../../examples/dateRange?raw";
-import DateRangeInputWithClearButton from "../../examples/dateRangeInputWithClearButton?raw";
-import DateRangeWithPortal from "../../examples/dateRangeWithPortal?raw";
-import Disabled from "../../examples/disabled?raw";
-import DisabledKeyboardNavigation from "../../examples/disabledKeyboardNavigation?raw";
-import ReadOnly from "../../examples/readOnly?raw";
-import ClearInput from "../../examples/clearInput?raw";
-import OnBlurCallbacks from "../../examples/onBlurCallbacks?raw";
-import ConfigureFloatingUI from "../../examples/configureFloatingUI?raw";
-import Portal from "../../examples/portal?raw";
-import PortalById from "../../examples/portalById?raw";
-import WithPortalById from "../../examples/withPortalById?raw";
-import TabIndex from "../../examples/tabIndex?raw";
-import YearDropdown from "../../examples/yearDropdown?raw";
-import YearItemNumber from "../../examples/yearItemNumber?raw";
-import MonthDropdown from "../../examples/monthDropdown?raw";
-import MonthDropdownShort from "../../examples/monthDropdownShort?raw";
-import MonthYearDropdown from "../../examples/monthYearDropdown?raw";
-import YearSelectDropdown from "../../examples/yearSelectDropdown?raw";
-import Inline from "../../examples/inline?raw";
-import InlineVisible from "../../examples/inlineVisible?raw";
-import OpenToDate from "../../examples/openToDate?raw";
-import FixedCalendar from "../../examples/fixedCalendar?raw";
-import WeekNumbers from "../../examples/weekNumbers?raw";
-import CustomInput from "../../examples/customInput?raw";
-import MultiMonth from "../../examples/multiMonth?raw";
-import MultiMonthPrevious from "../../examples/multiMonthPrevious?raw";
-import MultiMonthDropdown from "../../examples/multiMonthDropdown?raw";
-import MultiMonthInline from "../../examples/multiMonthInline?raw";
-import Children from "../../examples/children?raw";
-import CalendarContainer from "../../examples/calendarContainer?raw";
-import RawChange from "../../examples/rawChange?raw";
-import DontCloseOnSelect from "../../examples/dontCloseOnSelect?raw";
-import RenderCustomHeader from "../../examples/renderCustomHeader?raw";
-import RenderCustomHeaderTwoMonths from "../../examples/renderCustomHeaderTwoMonths?raw";
-import RenderCustomDay from "../../examples/renderCustomDay?raw";
-import RenderCustomMonth from "../../examples/renderCustomMonth?raw";
-import RenderCustomQuarter from "../../examples/renderCustomQuarter?raw";
-import RenderCustomYear from "../../examples/renderCustomYear?raw";
-import TimeInput from "../../examples/timeInput?raw";
-import StrictParsing from "../../examples/strictParsing?raw";
-import MonthPicker from "../../examples/monthPicker?raw";
-import WeekPicker from "../../examples/weekPicker?raw";
-import ExcludeWeeks from "../../examples/excludeWeeks?raw";
-import monthPickerFullName from "../../examples/monthPickerFullName?raw";
-import monthPickerTwoColumns from "../../examples/monthPickerTwoColumns?raw";
-import monthPickerFourColumns from "../../examples/monthPickerFourColumns?raw";
-import RangeMonthPicker from "../../examples/rangeMonthPicker?raw";
-import RangeMonthPickerSelectsRange from "../../examples/rangeMonthPickerSelectsRange?raw";
-import QuarterPicker from "../../examples/quarterPicker?raw";
-import RangeQuarterPicker from "../../examples/rangeQuarterPicker?raw";
-import RangeQuarterPickerSelectsRange from "../../examples/rangeQuarterPickerSelectsRange?raw";
-import YearPicker from "../../examples/yearPicker?raw";
-import RangeYearPicker from "../../examples/rangeYearPicker?raw";
-import RangeYearPickerSelectsRange from "../../examples/rangeYearPickerSelectsRange?raw";
-import OnCalendarChangeStateCallbacks from "../../examples/onCalendarOpenStateCallbacks?raw";
-import CustomTimeInput from "../../examples/customTimeInput?raw";
-import CloseOnScroll from "../../examples/closeOnScroll?raw";
-import CloseOnScrollCallback from "../../examples/closeOnScrollCallback?raw";
-import SelectsRange from "../../examples/selectsRange?raw";
-import selectsRangeWithDisabledDates from "../../examples/selectsRangeWithDisabledDates?raw";
-import CalendarStartDay from "../../examples/calendarStartDay?raw";
-import ExternalForm from "../../examples/externalForm?raw";
-import CalendarIcon from "../../examples/calendarIcon?raw";
-import SelectsMultiple from "../../examples/selectsMultiple?raw";
-import SelectsMultipleMonths from "../../examples/selectsMultipleMonths?raw";
-import CalendarIconExternal from "../../examples/calendarIconExternal?raw";
-import CalendarIconSvgIcon from "../../examples/calendarIconSvgIcon?raw";
-import ToggleCalendarOnIconClick from "../../examples/toggleCalendarOnIconClick?raw";
-import SwapRange from "../../examples/rangeSwapRange?raw";
-
-import "./style.scss";
-import "react-datepicker/dist/react-datepicker.css";
-
-export default class exampleComponents extends React.Component {
- componentDidMount() {
- hljs.registerLanguage("javascript", hljsJavaScriptLanguage);
- hljs.highlightAll();
- }
-
- examples = [
- {
- title: "Default",
- component: Default,
- },
- {
- title: "Calendar Icon",
- component: CalendarIcon,
- },
- {
- title: "Calendar Icon using React Svg Component",
- component: CalendarIconSvgIcon,
- },
- {
- title: "Calendar Icon using External Lib",
- component: CalendarIconExternal,
- },
- {
- title: "Toggle Calendar open status on click of the calendar icon",
- component: ToggleCalendarOnIconClick,
- },
- {
- title: "Calendar container",
- component: CalendarContainer,
- },
- {
- title: "Calendar open state callbacks",
- component: OnCalendarChangeStateCallbacks,
- },
- {
- title: "Children",
- component: Children,
- },
- {
- title: "Clear datepicker input",
- component: ClearInput,
- },
- {
- title: "Close on scroll",
- component: CloseOnScroll,
- },
- {
- title: "Close on scroll callback",
- component: CloseOnScrollCallback,
- },
- {
- title: "Configure Floating UI Properties",
- component: ConfigureFloatingUI,
- description: (
-
- Full docs for the underlying library that manages the overlay used can
- be found at{" "}
-
- floating-ui.com
-
-
- ),
- },
- {
- title: "Custom input",
- component: CustomInput,
- },
- {
- title: "Custom header",
- component: RenderCustomHeader,
- },
- {
- title: "Custom header with two months displayed",
- component: RenderCustomHeaderTwoMonths,
- },
- {
- title: "Custom Day",
- component: RenderCustomDay,
- },
- {
- title: "Custom Month",
- component: RenderCustomMonth,
- },
- {
- title: "Custom Quarter",
- component: RenderCustomQuarter,
- },
- {
- title: "Custom Year",
- component: RenderCustomYear,
- },
- {
- title: "Custom calendar class name",
- component: CustomCalendarClassName,
- },
- {
- title: "Custom class name",
- component: CustomClassName,
- },
- {
- title: "Custom day class name",
- component: CustomDayClassName,
- },
- {
- title: "Custom date format",
- component: CustomDateFormat,
- },
- {
- title: "Custom time class name",
- component: CustomTimeClassName,
- },
- {
- title: "Custom time input",
- component: CustomTimeInput,
- },
- {
- title: "Date Range",
- component: DateRange,
- },
- {
- title: "Date range for one datepicker",
- component: SelectsRange,
- },
- {
- title: "Date range for one datepicker with disabled dates highlighted",
- component: selectsRangeWithDisabledDates,
- },
- {
- title: "Date Range with disabled navigation shown",
- component: DateRangeWithShowDisabledNavigation,
- },
- {
- title: "Date Range using input with clear button",
- component: DateRangeInputWithClearButton,
- },
- {
- title: "Date Range with Portal",
- component: DateRangeWithPortal,
- },
- {
- title: "Disable datepicker",
- component: Disabled,
- },
- {
- title: "Disable keyboard navigation",
- component: DisabledKeyboardNavigation,
- },
- {
- title: "Display Week Numbers",
- component: WeekNumbers,
- },
- {
- title: "Don't hide calendar on date selection",
- component: DontCloseOnSelect,
- },
- {
- title: "Exclude dates",
- component: ExcludeDates,
- },
- {
- title: "Exclude dates with message",
- component: ExcludedWithMessage,
- },
- {
- title: "Exclude date intervals",
- component: ExcludeDateIntervals,
- },
- {
- title: "Exclude Months in Month Picker",
- component: ExcludeDatesMonthPicker,
- },
- {
- title: "Exclude Months in Range Month Picker",
- component: ExcludeDatesRangeMonthPicker,
- },
- {
- title: "Exclude Times",
- component: ExcludeTimes,
- },
- {
- title: "Filter dates",
- component: FilterDates,
- },
- {
- title: "Filter times",
- component: FilterTimes,
- },
- {
- title: "Fixed height of Calendar",
- component: FixedCalendar,
- },
- {
- title: "Get raw input value on change",
- component: RawChange,
- },
- {
- title: "Highlight dates",
- component: HighlightDates,
- },
- {
- title: "Highlight dates with custom class names and ranges",
- component: HighlightDatesRanges,
- },
- {
- title: "Holiday dates",
- component: HolidayDates,
- },
- {
- title: "Include dates",
- component: IncludeDates,
- },
- {
- title: "Include date intervals",
- component: IncludeDateIntervals,
- },
- {
- title: "Include Months in Month Picker",
- component: IncludeDatesMonthPicker,
- },
- {
- title: "Include Times",
- component: IncludeTimes,
- },
- {
- title: "Inject Specific Times",
- component: InjectTimes,
- },
- {
- title: "Inline version",
- component: Inline,
- },
- {
- title: "Button to show Inline version",
- component: InlineVisible,
- },
- {
- title: "Input time",
- component: TimeInput,
- },
- {
- title: "Locale",
- component: Locale,
- },
- {
- title: "Locale with time",
- component: LocaleWithTime,
- },
- {
- title: "Locale without global variables",
- component: LocaleWithoutGlobalVariable,
- },
- {
- title: "Min date",
- component: MinDate,
- },
- {
- title: "Max date",
- component: MaxDate,
- },
- {
- title: "Month Picker",
- component: MonthPicker,
- },
- {
- title: "Month Picker with Full Name",
- component: monthPickerFullName,
- },
- {
- title: "Month Picker Two Columns Layout",
- component: monthPickerTwoColumns,
- },
- {
- title: "Month Picker Four Columns Layout",
- component: monthPickerFourColumns,
- },
- {
- title: "Month dropdown",
- component: MonthDropdown,
- },
- {
- title: "Month dropdown short month",
- component: MonthDropdownShort,
- },
- {
- title: "MonthYear dropdown",
- component: MonthYearDropdown,
- },
- {
- title: "Multiple months",
- component: MultiMonth,
- },
- {
- title: "Multiple months with year dropdown",
- component: MultiMonthDropdown,
- },
- {
- title: "Multiple months inline",
- component: MultiMonthInline,
- },
- {
- title: "No Anchor Arrow",
- component: NoAnchorArrow,
- },
- {
- title: "onBlur callbacks in console",
- component: OnBlurCallbacks,
- },
- {
- title: "Open to date",
- component: OpenToDate,
- },
- {
- title: "Placeholder text",
- component: PlaceholderText,
- },
- {
- title: "Portal version",
- component: Portal,
- },
- {
- title: "Portal by id",
- description:
- "If the provided portalId cannot be found in the dom, one will be created by default with that id.",
- component: PortalById,
- },
- {
- title: "Portal version with portal by id",
- description:
- "If the provided portalId cannot be found in the dom, one will be created by default with that id.",
- component: WithPortalById,
- },
- {
- title: "Quarter Picker",
- component: QuarterPicker,
- },
- {
- title: "Range Month Picker",
- component: RangeMonthPicker,
- },
- {
- title: "Range Month Picker for one month picker",
- component: RangeMonthPickerSelectsRange,
- },
- {
- title: "Range Quarter Picker",
- component: RangeQuarterPicker,
- },
- {
- title: "Range Quarter Picker for one quarter picker",
- component: RangeQuarterPickerSelectsRange,
- },
- {
- title: "Range Swap Range",
- description:
- "Swap the start and end date if the end date is before the start date in a pick sequence.",
- component: SwapRange,
- },
- {
- title: "Read only datepicker",
- component: ReadOnly,
- },
- {
- title: "Select Time",
- component: ShowTime,
- },
- {
- title: "Select Time Only",
- component: ShowTimeOnly,
- },
- {
- title: "Hide Time Caption",
- component: HideTimeCaption,
- },
- {
- title: "Show previous months",
- component: MultiMonthPrevious,
- },
- {
- title: "Specific date range",
- component: SpecificDateRange,
- },
- {
- title: "Specific Time Range",
- component: ExcludeTimePeriod,
- },
- {
- title: "Select multiple dates",
- component: SelectsMultiple,
- },
- {
- title: "Select multiple months",
- component: SelectsMultipleMonths,
- },
- {
- title: "Strict parsing",
- component: StrictParsing,
- },
- {
- title: "TabIndex",
- component: TabIndex,
- },
- {
- title: "Today button",
- component: Today,
- },
- {
- title: "Year Picker",
- component: YearPicker,
- },
- {
- title: "Range Year Picker",
- component: RangeYearPicker,
- },
- {
- title: "Range Year Picker for one datepicker",
- component: RangeYearPickerSelectsRange,
- },
- {
- title: "Year dropdown",
- component: YearDropdown,
- },
- {
- title: "Year select dropdown",
- component: YearSelectDropdown,
- },
- {
- title: "Year item number",
- component: YearItemNumber,
- },
- {
- title: "Calendar Start day",
- component: CalendarStartDay,
- },
- {
- title: "Week Picker",
- component: WeekPicker,
- },
- {
- title: "Exclude Weeks",
- component: ExcludeWeeks,
- },
- {
- title: "External Form",
- component: ExternalForm,
- },
- ];
-
- handleAnchorClick = (e, id) => {
- e.preventDefault();
- window.history.replaceState(null, document.title, `#${id}`);
- document
- .getElementById(id)
- .scrollIntoView({ behavior: "smooth", block: "start" });
- };
-
- render() {
- return (
- <>
-
Examples
-
-
- {this.examples.map((example) => (
-
- ))}
-
- >
- );
- }
-}
diff --git a/docs-site/src/components/Examples/index.tsx b/docs-site/src/components/Examples/index.tsx
new file mode 100644
index 0000000000..68f15f97e1
--- /dev/null
+++ b/docs-site/src/components/Examples/index.tsx
@@ -0,0 +1,57 @@
+import React from "react";
+import hljs from "highlight.js/lib/core";
+import hljsJavaScriptLanguage from "highlight.js/lib/languages/javascript";
+import slugify from "slugify";
+import CodeExampleComponent from "../Example/index.jsx";
+
+import "./style.scss";
+import "react-datepicker/dist/react-datepicker.css";
+import { EXAMPLE_CONFIG } from "./config.js";
+
+export default class exampleComponents extends React.Component {
+ componentDidMount() {
+ hljs.registerLanguage("javascript", hljsJavaScriptLanguage);
+ hljs.highlightAll();
+ }
+
+ handleAnchorClick = (e: React.MouseEvent, id: string): void => {
+ e.preventDefault();
+ window.history.replaceState(null, document.title, `#${id}`);
+ document
+ .getElementById(id)
+ ?.scrollIntoView({ behavior: "smooth", block: "start" });
+ };
+
+ render() {
+ return (
+ <>
+
Examples
+
+
+ {EXAMPLE_CONFIG.map((example) => (
+
+ ))}
+
+ >
+ );
+ }
+}
diff --git a/docs-site/src/components/Examples/reset.scss b/docs-site/src/components/Examples/reset.scss
index 04a683bf25..72f4a5c1ad 100644
--- a/docs-site/src/components/Examples/reset.scss
+++ b/docs-site/src/components/Examples/reset.scss
@@ -114,10 +114,10 @@ blockquote {
quotes: none;
}
-q:before,
-q:after,
-blockquote:before,
-blockquote:after {
+q::before,
+q::after,
+blockquote::before,
+blockquote::after {
content: "";
content: none;
}
diff --git a/docs-site/src/components/Examples/style.scss b/docs-site/src/components/Examples/style.scss
index cb7ad5e36c..9f3fa05280 100644
--- a/docs-site/src/components/Examples/style.scss
+++ b/docs-site/src/components/Examples/style.scss
@@ -67,6 +67,7 @@ strong {
.wrapper {
@extend %container-styling;
+
padding: 20px;
}
diff --git a/docs-site/src/examples/calendarContainer.js b/docs-site/src/examples/js/calendarContainer.js
similarity index 99%
rename from docs-site/src/examples/calendarContainer.js
rename to docs-site/src/examples/js/calendarContainer.js
index 5bb2563024..813d2fbc34 100644
--- a/docs-site/src/examples/calendarContainer.js
+++ b/docs-site/src/examples/js/calendarContainer.js
@@ -1,5 +1,6 @@
() => {
const [startDate, setStartDate] = useState(new Date());
+
const MyContainer = ({ className, children }) => {
return (
@@ -12,6 +13,7 @@
);
};
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
setStartDate(date)}>
Don't forget to check the weather!
diff --git a/docs-site/src/examples/clearInput.js b/docs-site/src/examples/js/clearInput.js
similarity index 99%
rename from docs-site/src/examples/clearInput.js
rename to docs-site/src/examples/js/clearInput.js
index 759304f4f6..3cd1393e3f 100644
--- a/docs-site/src/examples/clearInput.js
+++ b/docs-site/src/examples/js/clearInput.js
@@ -1,5 +1,6 @@
() => {
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
setStartDate(date)}
/>
diff --git a/docs-site/src/examples/closeOnScrollCallback.js b/docs-site/src/examples/js/closeOnScrollCallback.js
similarity index 99%
rename from docs-site/src/examples/closeOnScrollCallback.js
rename to docs-site/src/examples/js/closeOnScrollCallback.js
index d9a3576d34..fd740a1ba5 100644
--- a/docs-site/src/examples/closeOnScrollCallback.js
+++ b/docs-site/src/examples/js/closeOnScrollCallback.js
@@ -1,5 +1,6 @@
() => {
const [startDate, setStartDate] = useState(new Date());
+
return (
e.target === document}
diff --git a/docs-site/src/examples/configureFloatingUI.js b/docs-site/src/examples/js/configureFloatingUI.js
similarity index 99%
rename from docs-site/src/examples/configureFloatingUI.js
rename to docs-site/src/examples/js/configureFloatingUI.js
index eb8311fd73..b6e57b369e 100644
--- a/docs-site/src/examples/configureFloatingUI.js
+++ b/docs-site/src/examples/js/configureFloatingUI.js
@@ -1,5 +1,6 @@
() => {
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
const ExampleCustomInput = forwardRef(
({ value, onClick, className }, ref) => (
),
);
+
return (
{
const [startDate, setStartDate] = useState(new Date());
- let handleColor = (time) => {
+ const handleColor = (time) => {
return time.getHours() > 12 ? "text-success" : "text-error";
};
diff --git a/docs-site/src/examples/customTimeInput.js b/docs-site/src/examples/js/customTimeInput.js
similarity index 99%
rename from docs-site/src/examples/customTimeInput.js
rename to docs-site/src/examples/js/customTimeInput.js
index 4cb543ed05..8288b5f3aa 100644
--- a/docs-site/src/examples/customTimeInput.js
+++ b/docs-site/src/examples/js/customTimeInput.js
@@ -1,5 +1,6 @@
() => {
const [startDate, setStartDate] = useState(new Date());
+
const ExampleCustomTimeInput = ({ value, onChange }) => (
);
+
return (
{
const [startDate, setStartDate] = useState(new Date("2014/02/08"));
const [endDate, setEndDate] = useState(new Date("2014/02/10"));
+
return (
<>
{
const [dateRange, setDateRange] = useState([null, null]);
const [startDate, endDate] = dateRange;
+
return (
{
setDateRange(update);
}}
+ selectsRange
isClearable={true}
/>
);
diff --git a/docs-site/src/examples/dateRangeWithPortal.js b/docs-site/src/examples/js/dateRangeWithPortal.js
similarity index 91%
rename from docs-site/src/examples/dateRangeWithPortal.js
rename to docs-site/src/examples/js/dateRangeWithPortal.js
index fa7f5dbed5..22af3c5628 100644
--- a/docs-site/src/examples/dateRangeWithPortal.js
+++ b/docs-site/src/examples/js/dateRangeWithPortal.js
@@ -1,14 +1,15 @@
() => {
const [dateRange, setDateRange] = useState([null, null]);
const [startDate, endDate] = dateRange;
+
return (
{
setDateRange(update);
}}
+ selectsRange
withPortal
/>
);
diff --git a/docs-site/src/examples/dateRangeWithShowDisabledNavigation.js b/docs-site/src/examples/js/dateRangeWithShowDisabledNavigation.js
similarity index 99%
rename from docs-site/src/examples/dateRangeWithShowDisabledNavigation.js
rename to docs-site/src/examples/js/dateRangeWithShowDisabledNavigation.js
index 1f574fc8e0..f2cb355f45 100644
--- a/docs-site/src/examples/dateRangeWithShowDisabledNavigation.js
+++ b/docs-site/src/examples/js/dateRangeWithShowDisabledNavigation.js
@@ -1,11 +1,13 @@
() => {
const [startDate, setStartDate] = useState(new Date());
const [endDate, setEndDate] = useState(null);
+
const onChange = (dates) => {
const [start, end] = dates;
setStartDate(start);
setEndDate(end);
};
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
setStartDate(date)} />
);
diff --git a/docs-site/src/examples/disabled.js b/docs-site/src/examples/js/disabled.js
similarity index 99%
rename from docs-site/src/examples/disabled.js
rename to docs-site/src/examples/js/disabled.js
index 237316a241..91e23654d5 100644
--- a/docs-site/src/examples/disabled.js
+++ b/docs-site/src/examples/js/disabled.js
@@ -1,5 +1,6 @@
() => {
const [startDate, setStartDate] = useState(null);
+
return (
{
const [startDate, setStartDate] = useState(null);
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date("2024-08-01"));
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date("2021/02/22"));
+
return (
>
);
diff --git a/docs-site/src/examples/filterDates.js b/docs-site/src/examples/js/filterDates.js
similarity index 99%
rename from docs-site/src/examples/filterDates.js
rename to docs-site/src/examples/js/filterDates.js
index 9eb67a0084..89cbba8316 100644
--- a/docs-site/src/examples/filterDates.js
+++ b/docs-site/src/examples/js/filterDates.js
@@ -1,9 +1,11 @@
() => {
const [startDate, setStartDate] = useState(null);
+
const isWeekday = (date) => {
const day = getDay(date);
return day !== 0 && day !== 6;
};
+
return (
{
const currentDate = new Date();
const selectedDate = new Date(time);
return currentDate.getTime() < selectedDate.getTime();
};
+
return (
{
const [startDate, setStartDate] = useState(null);
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
const highlightWithRanges = [
{
"react-datepicker__day--highlighted-custom-1": [
@@ -18,6 +19,7 @@
],
},
];
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(null);
+
return (
{
const [startDate, setStartDate] = useState(null);
+
return (
{
const [startDate, setStartDate] = useState(1661990400000);
+
return (
{
const [startDate, setStartDate] = useState(new Date());
+
return (
{
const [startDate, setStartDate] = useState(new Date());
const [isOpen, setIsOpen] = useState(false);
+
const handleChange = (e) => {
setIsOpen(!isOpen);
setStartDate(e);
};
+
const handleClick = (e) => {
e.preventDefault();
setIsOpen(!isOpen);
};
+
return (
<>