{"version":3,"file":"DatePicker.mjs","names":[],"sources":["../../../src/date-picker/DatePicker.tsx"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\nimport { type Boundary, shift, size } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { format } from 'date-fns';\nimport { useCallback, useRef, useState } from 'react';\nimport ReactDatePicker, {\n  type ReactDatePickerCustomHeaderProps,\n} from 'react-datepicker';\n\nimport type { CommonProps, HtmlAttributes } from '../_common/types';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { Divider } from '../divider';\nimport { ArrowLeftIconOutline } from '../icons/generated/heroIcons/ArrowLeftIconOutline';\nimport { ArrowRightIconOutline } from '../icons/generated/heroIcons/ArrowRightIconOutline';\nimport { CalendarDaysIconOutline } from '../icons/generated/heroIcons/CalendarDaysIconOutline';\nimport { ChevronDownIconOutline } from '../icons/generated/heroIcons/ChevronDownIconOutline';\nimport { TextInput } from '../text-input';\nimport { NeedleTime, TimePicker, type TimePickerProps } from '../time-picker';\nimport { TimeZonePicker } from '../timezone-picker';\nimport { Typography } from '../typography';\nimport { daysInMonth, getYearsPeriodString } from './utils';\n\ntype DatePickerTextInputWrapperProps = React.ComponentProps<'input'> & {\n  textInputProps?: React.ComponentProps<typeof TextInput>;\n  isDisabled?: boolean;\n  isClearable?: boolean;\n  value?: string;\n  ariaLabel?: string;\n};\n\n// This wrapper is needed due to react-datepicker injecting html attributes\n// into the custom input component on root level, since we use htmlAttributes\n// we need to help spread them there instead of the root level\nconst DatePickerTextInputWrapper = ({\n  textInputProps,\n  isDisabled,\n  isClearable,\n  value,\n  placeholder,\n  ...restProps\n}: DatePickerTextInputWrapperProps) => {\n  // deconstruct textInputProps to avoid bugs with react-datepicker injecting props\n  const {\n    placeholder: textInputPlaceholder,\n    htmlAttributes: textInputHtmlAttributes,\n    onChange: textInputOnChange,\n    ref,\n    ...restTextInputProps\n  } = textInputProps ?? {};\n  const { onChange: injectedOnChange, ...restInjectedProps } = restProps;\n\n  const handleChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n    injectedOnChange?.(event);\n    textInputOnChange?.(event);\n  };\n\n  return (\n    <TextInput\n      ref={ref}\n      trailingElement={<CalendarDaysIconOutline />}\n      value={value}\n      placeholder={placeholder ?? textInputPlaceholder}\n      isDisabled={isDisabled}\n      isClearable={isClearable}\n      onChange={handleChange}\n      // react-datepicker injects html attributes into the custom input\n      htmlAttributes={{\n        ...textInputHtmlAttributes,\n        ...restInjectedProps,\n      }}\n      {...restTextInputProps}\n    />\n  );\n};\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype PickerType = 'day' | 'month' | 'year';\n\n// Define a more flexible type for onChange\ntype DatePickerChangeHandler = (\n  date: Date | null | [Date | null, Date | null] | Date[],\n  event?: React.SyntheticEvent | undefined,\n) => void;\n\n/**\n * @remarks\n * The `reactDatePickerProps` prop is forwarded to the underlying `react-datepicker` component. See the [react-datepicker documentation](https://reactdatepicker.com/) for more information.\n *\n * @remarks\n * Where `TextInputProps` is defined in the `TextInput` component and `TimePickerProps` is defined in the `TimePicker` component.\n */\ninterface DatePickerProps {\n  /** Props for the embedded `TextInput` component. */\n  // TODO: this forwards TextInput's props, so whatever happens to its\n  // inconsistently named ones lands here too and needs the same codemod.\n  textInputProps?: React.ComponentProps<typeof TextInput>;\n  /** Whether the date picker is disabled. */\n  isDisabled?: boolean;\n  /**\n   * Whether to show the clear button.\n   * @default false\n   */\n  isClearable?: boolean;\n  /** Props for the embedded `TimePicker` component. */\n  timePickerProps?: TimePickerProps;\n  /** Props for the embedded `TimeZonePicker` component. */\n  timeZonePickerProps?: React.ComponentProps<typeof TimeZonePicker>;\n  /** Props forwarded to underlying `react-datepicker` component. */\n  reactDatePickerProps: React.ComponentProps<typeof ReactDatePicker>;\n  /**\n   * WARNING: these attributes do not apply to the underlying input element currently. This will be fixed in a future version.\n   */\n  htmlAttributes?: HtmlAttributes<'div'>;\n}\n\nexport const DatePicker = ({\n  reactDatePickerProps,\n  textInputProps,\n  timePickerProps,\n  timeZonePickerProps,\n  isDisabled,\n  isClearable = false,\n  ref,\n  className,\n  style,\n  htmlAttributes,\n  ...restProps\n}: CommonProps<'div', DatePickerProps>) => {\n  const classes = classNames(`ndl-datepicker`, className, {});\n  const datetimeRef = useRef<ReactDatePicker>(null);\n  const shouldRestoreFocusAfterEscapeRef = useRef(false);\n  const [picker, setPicker] = useState<PickerType>('day');\n  const [preSelectedDate, setPreSelectedDate] = useState<Date | null>(\n    (reactDatePickerProps.selected as Date | null) ||\n      (reactDatePickerProps.startDate as Date | null),\n  );\n  const [selectedTimeZone, setSelectedTimeZone] = useState<string | undefined>(\n    timeZonePickerProps?.value,\n  );\n\n  const isInsideDialog = useIsInsideDialog();\n\n  // Inside a Dialog the popper is fixed and not portaled. A transformed\n  // ancestor (e.g. Popover) can make Floating UI under-measure available\n  // space, so use the viewport as the boundary instead.\n  const floatingBoundary: Boundary = isInsideDialog ? [] : 'clippingAncestors';\n\n  const headerAction = useCallback(\n    (action: PickerType) => {\n      setPicker(picker === action ? 'day' : action);\n    },\n    [picker],\n  );\n\n  const CustomHeader = useCallback(\n    (props: ReactDatePickerCustomHeaderProps) => {\n      const {\n        decreaseMonth,\n        increaseMonth,\n        increaseYear,\n        decreaseYear,\n        nextMonthButtonDisabled: isNextMonthButtonDisabled,\n        nextYearButtonDisabled: isNextYearButtonDisabled,\n        prevMonthButtonDisabled: isPrevMonthButtonDisabled,\n        prevYearButtonDisabled: isPrevYearButtonDisabled,\n      } = props;\n\n      const prevCallback = picker === 'year' ? decreaseYear : decreaseMonth;\n      const nextCallback = picker === 'year' ? increaseYear : increaseMonth;\n      const isPrevDisabled =\n        picker === 'year'\n          ? isPrevYearButtonDisabled\n          : isPrevMonthButtonDisabled;\n      const isNextDisabled =\n        picker === 'year'\n          ? isNextYearButtonDisabled\n          : isNextMonthButtonDisabled;\n\n      return (\n        <div className=\"ndl-datepicker-header\">\n          <div className=\"ndl-datepicker-selects\">\n            {picker !== 'year' && (\n              <button\n                type=\"button\"\n                aria-label={`${picker === 'month' ? 'Close' : 'Open'} month picker`}\n                aria-pressed={picker === 'month'}\n                onClick={() => headerAction('month')}\n              >\n                <div className=\"ndl-datepicker-select-content\">\n                  <Typography variant=\"subheading-small\">\n                    {format(props.date, 'MMM')}\n                  </Typography>\n                  <ChevronDownIconOutline\n                    className={classNames('ndl-datepicker-chevron', {\n                      'ndl-open': picker === 'month',\n                    })}\n                    aria-label=\"Chevron icon\"\n                  />\n                </div>\n              </button>\n            )}\n            {picker !== 'month' && (\n              <button\n                type=\"button\"\n                aria-label={`${picker === 'year' ? 'Close' : 'Open'} year picker`}\n                onClick={() => headerAction('year')}\n              >\n                <div className=\"ndl-datepicker-select-content\">\n                  <Typography variant=\"subheading-small\">\n                    {picker === 'year'\n                      ? getYearsPeriodString(\n                          props.date,\n                          reactDatePickerProps?.yearItemNumber,\n                        )\n                      : format(props.date, 'yyyy')}\n                  </Typography>\n                  <ChevronDownIconOutline\n                    className={classNames('ndl-datepicker-chevron', {\n                      'ndl-open': picker === 'year',\n                    })}\n                    aria-label=\"Chevron icon\"\n                  />\n                </div>\n              </button>\n            )}\n          </div>\n          {picker !== 'month' && (\n            <div className=\"ndl-datepicker-nav\">\n              <CleanIconButton\n                description={\n                  picker === 'year' ? 'Previous period' : 'Previous month'\n                }\n                onClick={prevCallback}\n                isDisabled={isPrevDisabled}\n                size=\"small\"\n              >\n                <ArrowLeftIconOutline />\n              </CleanIconButton>\n              <CleanIconButton\n                description={picker === 'year' ? 'Next period' : 'Next month'}\n                onClick={nextCallback}\n                isDisabled={isNextDisabled}\n                size=\"small\"\n              >\n                <ArrowRightIconOutline />\n              </CleanIconButton>\n            </div>\n          )}\n        </div>\n      );\n    },\n    [picker, headerAction, reactDatePickerProps?.yearItemNumber],\n  );\n\n  const handleTimeChange = (newTime: NeedleTime) => {\n    if (\n      reactDatePickerProps.selectsRange ||\n      reactDatePickerProps.selectsMultiple\n    ) {\n      // this is consistent with the behavior of react-datepicker\n      return;\n    }\n\n    if (!preSelectedDate) {\n      return;\n    }\n\n    const newDate = new Date(preSelectedDate);\n    newDate.setHours(newTime.hour, newTime.minute, 0, 0);\n    setPreSelectedDate(newDate);\n\n    if (reactDatePickerProps.onChange) {\n      // For single date selection\n      reactDatePickerProps.onChange(newDate, undefined);\n    }\n  };\n\n  const handleTimeZoneChange = (timezone: string) => {\n    setSelectedTimeZone(timezone);\n    if (timeZonePickerProps?.onChange) {\n      timeZonePickerProps.onChange(timezone);\n    }\n  };\n\n  /**\n   * Intercept onChange so we can work with\n   * Month and Year pickers\n   */\n  const interceptedChange: DatePickerChangeHandler = useCallback(\n    (\n      date: Date | null | [Date | null, Date | null] | Date[],\n      event?: React.SyntheticEvent,\n    ) => {\n      if (picker !== 'day') {\n        // setTimeout to prevent picker change before the handleMonthChange logic\n        setTimeout(() => {\n          setPicker('day');\n        });\n      } else if (picker === 'day') {\n        if (date instanceof Date) {\n          setPreSelectedDate(date);\n        } else if (\n          Array.isArray(date) &&\n          date.length > 0 &&\n          date[0] instanceof Date\n        ) {\n          setPreSelectedDate(date[0]);\n        } else if (date === null) {\n          setPreSelectedDate(null);\n        }\n\n        if (reactDatePickerProps.onChange && date !== null) {\n          (reactDatePickerProps.onChange as DatePickerChangeHandler)(\n            date,\n            event,\n          );\n        }\n      }\n    },\n    [picker, reactDatePickerProps],\n  );\n\n  const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n    // react-datepicker prevents Escape when it closes the calendar, but\n    // otherwise lets the event bubble and dismiss ancestor overlays.\n    if (event.key === 'Escape' && event.defaultPrevented) {\n      shouldRestoreFocusAfterEscapeRef.current = true;\n      event.stopPropagation();\n    }\n    htmlAttributes?.onKeyDown?.(event);\n  };\n\n  /** These intercepts are needed for webkit to ensure that focus is restored to the input when the calendar is closed. */\n  const interceptedOnBlur = useCallback(\n    (event: React.FocusEvent<HTMLElement>) => {\n      reactDatePickerProps.onBlur?.(event);\n\n      if (\n        !shouldRestoreFocusAfterEscapeRef.current ||\n        event.relatedTarget !== null\n      ) {\n        return;\n      }\n\n      const input = event.currentTarget;\n      queueMicrotask(() => {\n        if (\n          shouldRestoreFocusAfterEscapeRef.current &&\n          input.isConnected &&\n          document.activeElement === document.body\n        ) {\n          datetimeRef.current?.sendFocusBackToInput();\n        }\n        shouldRestoreFocusAfterEscapeRef.current = false;\n      });\n    },\n    [reactDatePickerProps],\n  );\n\n  const interceptedOnFocus = useCallback(\n    (event: React.FocusEvent<HTMLElement>) => {\n      reactDatePickerProps.onFocus?.(event);\n\n      if (!shouldRestoreFocusAfterEscapeRef.current) {\n        return;\n      }\n\n      // react-datepicker schedules both focus and blur while closing. If blur\n      // ran first, focus is now stable and the Escape marker can be cleared.\n      requestAnimationFrame(() => {\n        shouldRestoreFocusAfterEscapeRef.current = false;\n      });\n    },\n    [reactDatePickerProps],\n  );\n\n  /**\n   * Intercept onCalendarClose so we can\n   * switch to \"day\" picker if we close on \"month\" or \"year\"\n   * view\n   */\n  const interceptedOnCalendarClose = useCallback(() => {\n    if (picker !== 'day') {\n      setPicker('day');\n    }\n    reactDatePickerProps?.onCalendarClose?.();\n  }, [picker, reactDatePickerProps]);\n\n  const handleMonthChange = useCallback(\n    (date: Date) => {\n      if (picker === 'month') {\n        const selectedDay = preSelectedDate?.getDate() ?? 1;\n        const daysInNewMonth = daysInMonth(date.getMonth(), date.getFullYear());\n        date.setDate(Math.min(selectedDay, daysInNewMonth));\n        reactDatePickerProps?.onMonthChange?.(date);\n      } else if (picker === 'year') {\n        const selectedDay = preSelectedDate?.getDate() ?? 1;\n        const selectedMonth = preSelectedDate?.getMonth() ?? 0;\n        const daysInNewMonth = daysInMonth(selectedMonth, date.getFullYear());\n        date.setMonth(selectedMonth, Math.min(selectedDay, daysInNewMonth));\n        reactDatePickerProps?.onMonthChange?.(date);\n      }\n      setPreSelectedDate(date);\n    },\n    [picker, preSelectedDate, reactDatePickerProps],\n  );\n\n  /**\n   * Intercept onChangeRaw to handle clearing the input.\n   * An empty input clears a single date to null and a range to [null, null].\n   */\n  const interceptedOnChangeRaw = useCallback(\n    (\n      event?:\n        | React.KeyboardEvent<HTMLElement>\n        | React.MouseEvent<HTMLElement, MouseEvent>,\n    ) => {\n      const target = event?.target as HTMLInputElement | undefined;\n      if (target?.value === '') {\n        setPreSelectedDate(null);\n        if (reactDatePickerProps.onChange) {\n          // Range selection's onChange is typed as a tuple. Passing null\n          // makes controlled callers crash when they read start/end dates.\n          const clearedValue: Date | null | [Date | null, Date | null] =\n            reactDatePickerProps.selectsRange ? [null, null] : null;\n          (reactDatePickerProps.onChange as DatePickerChangeHandler)(\n            clearedValue,\n            event,\n          );\n        }\n      }\n      reactDatePickerProps?.onChangeRaw?.(event);\n    },\n    [reactDatePickerProps],\n  );\n\n  const datePickerProps = {\n    ...reactDatePickerProps,\n    onBlur: interceptedOnBlur,\n    onCalendarClose: interceptedOnCalendarClose,\n    onChange: interceptedChange,\n    onChangeRaw: interceptedOnChangeRaw,\n    onFocus: interceptedOnFocus,\n    onMonthChange: handleMonthChange,\n  };\n\n  return (\n    // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- the key handlers only stop Escape from propagating, they add no interaction\n    <div\n      className={classes}\n      ref={ref}\n      style={style}\n      {...restProps}\n      {...htmlAttributes}\n      onKeyDown={handleKeyDown}\n    >\n      <ReactDatePicker\n        ref={datetimeRef}\n        customInput={\n          <DatePickerTextInputWrapper\n            isDisabled={isDisabled}\n            isClearable={isClearable}\n            textInputProps={textInputProps}\n          />\n        }\n        customTimeInput={\n          <span className=\"ndl-time-picker-wrapper\">\n            <Divider />\n            <TimePicker\n              isFluid\n              value={\n                preSelectedDate\n                  ? new NeedleTime(\n                      preSelectedDate.getHours(),\n                      preSelectedDate.getMinutes(),\n                    )\n                  : undefined\n              }\n              onChange={handleTimeChange}\n              {...timePickerProps}\n              floatingStrategy=\"absolute\"\n              isPortaled={false}\n            />\n            {timeZonePickerProps && (\n              <TimeZonePicker\n                isFluid\n                value={selectedTimeZone}\n                onChange={handleTimeZoneChange}\n                referenceDate={preSelectedDate || undefined}\n                {...timeZonePickerProps}\n                floatingStrategy=\"absolute\"\n                isPortaled={false}\n              />\n            )}\n          </span>\n        }\n        disabled={isDisabled}\n        showPopperArrow={false}\n        showMonthYearPicker={picker === 'month'}\n        showYearPicker={picker === 'year'}\n        shouldCloseOnSelect={\n          picker === 'day' && !(reactDatePickerProps.showTimeInput ?? false)\n        }\n        dayClassName={() => 'ndl-datepicker-day'}\n        renderCustomHeader={CustomHeader}\n        {...datePickerProps}\n        isClearable={isClearable}\n        popperClassName={classNames(\n          'ndl-datepicker-popper',\n          reactDatePickerProps.popperClassName,\n        )}\n        popperModifiers={[\n          shift({ boundary: floatingBoundary, padding: 8 }),\n          size({\n            apply({ availableHeight, availableWidth, elements }) {\n              elements.floating.style.setProperty(\n                '--ndl-datepicker-available-height',\n                `${availableHeight}px`,\n              );\n              Object.assign(elements.floating.style, {\n                maxWidth: `${availableWidth}px`,\n              });\n            },\n            boundary: floatingBoundary,\n            padding: 8,\n          }),\n          ...(reactDatePickerProps.popperModifiers ?? []),\n        ]}\n        popperProps={{\n          strategy: isInsideDialog ? 'fixed' : 'absolute',\n          ...reactDatePickerProps.popperProps,\n        }}\n      />\n    </div>\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsDE;CACA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