/*
 * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import { Button } from "@base-ui/react/button";
import classnames from "classnames";
import React, { memo, useCallback } from "react";
import { DatePicker } from "../../../shared/calendar/index.js";
import styles from "./SingleDateInput.module.css";
function SingleDateInputInner({
  selectedDate,
  onChange,
  className,
  style,
  minDate,
  maxDate,
  placeholder,
  showClearButton = true,
  formatDate
}) {
  const handleClear = useCallback(() => {
    onChange(undefined);
  }, [onChange]);
  const handleChange = useCallback(value => {
    onChange(value ?? undefined);
  }, [onChange]);
  return /*#__PURE__*/React.createElement("div", {
    className: classnames(styles.singleDate, className),
    style: style
  }, /*#__PURE__*/React.createElement("div", {
    className: styles.dateContainer
  }, /*#__PURE__*/React.createElement(DatePicker, {
    value: selectedDate ?? null,
    onChange: handleChange,
    min: minDate,
    max: maxDate,
    placeholder: placeholder,
    ariaLabel: "Select date",
    modal: false,
    formatDate: formatDate
  }), showClearButton && selectedDate !== undefined && /*#__PURE__*/React.createElement(Button, {
    className: styles.clearButton,
    onClick: handleClear,
    "aria-label": "Clear date"
  }, "\xD7")));
}
export const SingleDateInput = /*#__PURE__*/memo(SingleDateInputInner);
//# sourceMappingURL=SingleDateInput.js.map