import * as React from 'react';
import { InputProps } from '../Input';
import { PopoverCommonProps } from '../common';
import { SupportedWixLocales } from '@wix/design-systems-locale-utils';

export type TimeInputProps = {
  /** Specifies a CSS class name to be appended to the component’s root element.
   * @internal
   */
  className?: string;
  /** Applies a data-hook HTML attribute that can be used in the tests */
  dataHook?: string;
  /** Specifies whether component is disabled */
  disabled?: InputProps['disabled'];
  /** Control the border style of input */
  border?: InputProps['border'];
  /** Defines a callback function which is called on every time value changes */
  onChange?({ date }: { date: Date | null }): void;
  /** Defines a callback function which is called on cases when invalid time is typed or confirmed with an action.
   * - return {{ validationType: 'formatError' | 'outOfBoundsError', value: string }}
   * - `validationType` - type 'formatError'is set when value is in the wrong time format
   *                    - type 'outOfBoundsError' is set when `excludePastTimes` or `filterTime` is used and value does not match the filters
   * - `value` - is set to current input value
   */
  onInvalid?(): void;
  /** Sets a placeholder message to display */
  placeholder?: InputProps['placeholder'];
  /** Pass a component you want to show as the prefix of the input, e.g., text, icon */
  prefix?: InputProps['prefix'];
  /** Specifies whether input is read only */
  readOnly?: InputProps['readOnly'];
  /** Controls the size of the input */
  size?: InputProps['size'];
  /** Specify the status of a field */
  status?: InputProps['status'];
  /** Defines the message to display on status icon hover. If not given or empty there will be no tooltip. */
  statusMessage?: InputProps['statusMessage'];
  /** Enables internal validation and defines a message to display when user types invalid time value */
  invalidMessage?: string;
  /** Specifies the interval between time values shown in dropdown
   * @default 15
   */
  step?: number;
  /** Pass a component you want to show as the suffix of the input, e.g., text, icon */
  suffix?: InputProps['suffix'];
  /** Sets locale and formats time according to it */
  locale?: SupportedWixLocales;
  /** Specifies what time formatting style to use when calling `format()` */
  timeStyle?: 'long' | 'short';
  /** Specifies the current value of the input */
  value?: Date | null;
  /** Controls the width of the component. `auto` will resize the input to match width of its contents, while `100%` will take up the full parent container width. */
  width?: React.CSSProperties['width'];
  /** Allows to pass all common popover props. */
  popoverProps?: PopoverCommonProps;
  /** Defines a standard input `onFocus` callback */
  onFocus?: InputProps['onFocus'];
  /** Defines a standard input `onBlur` callback */
  onBlur?: InputProps['onBlur'];
  /** Specifies whether input is auto selected on focus */
  autoSelect?: InputProps['autoSelect'];
  /** Specify whether past time slots should be shown or not */
  excludePastTimes?: boolean;
  /**
   * Specify selectable time slots:
   *  * `param` {Date} `value` - a time to check
   *  * `return` {boolean} - true if `value` should be shown in time slots dropdown, false otherwise
   */
  filterTime?: (time: Date) => boolean;
  disableKeyboardType?: boolean;
  /** Specifies whether status suffix is hidden. */
  hideStatusSuffix?: boolean;
};

export type TimeInputImperativeActions = {
  focus(): void;
  blur(): void;
  clear(): void;
};

declare const TimeInput: React.ForwardRefExoticComponent<
  TimeInputProps & React.RefAttributes<TimeInputImperativeActions>
>;

export default TimeInput;
