File size: 1,081 Bytes
3201ca6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React from "react";
import { useTranslation } from "react-i18next";
import { cn } from "#/utils/utils";
import { I18nKey } from "#/i18n/declaration";

interface ClearButtonProps {
  disabled: boolean;
  onClear: () => void;
  testId?: string;
}

export function ClearButton({
  disabled,
  onClear,
  testId = "dropdown-clear",
}: ClearButtonProps) {
  const { t } = useTranslation("openhands");

  return (
    <button
      onClick={(e) => {
        e.stopPropagation();
        onClear();
      }}
      disabled={disabled}
      className={cn(
        "p-1 text-[#fff]",
        "cursor-pointer disabled:cursor-not-allowed disabled:opacity-60",
      )}
      type="button"
      aria-label={t(I18nKey.COMMON$CLEAR_SELECTION)}
      data-testid={testId}
    >
      <svg
        className="w-4 h-4"
        fill="none"
        stroke="currentColor"
        viewBox="0 0 24 24"
      >
        <path
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth={2}
          d="M6 18L18 6M6 6l12 12"
        />
      </svg>
    </button>
  );
}