SearchQueryBox.jsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use client";
  2. import React from "react";
  3. import { Search } from "lucide-react";
  4. import { Button } from "@/components/ui/button";
  5. import { Input } from "@/components/ui/input";
  6. import { Label } from "@/components/ui/label";
  7. export default function SearchQueryBox({
  8. qDraft,
  9. onQDraftChange,
  10. onSubmit,
  11. currentQuery,
  12. isSubmitting,
  13. canSearch,
  14. }) {
  15. return (
  16. // Important for flex layouts:
  17. // - w-full ensures the box fills its container width.
  18. // - min-w-0 allows the input row to shrink without overflow.
  19. <div className="grid w-full min-w-0 gap-2">
  20. <Label htmlFor="q">Suchbegriff</Label>
  21. <div className="flex w-full min-w-0 flex-col gap-2 sm:flex-row sm:items-center">
  22. <Input
  23. id="q"
  24. name="q"
  25. value={qDraft}
  26. onChange={(e) => onQDraftChange(e.target.value)}
  27. placeholder="z. B. Bridgestone, Rechnung, Kundennummer…"
  28. disabled={isSubmitting}
  29. // Make the input take the remaining space next to the button.
  30. className="flex-1 min-w-0"
  31. />
  32. <Button
  33. type="submit"
  34. disabled={!canSearch || isSubmitting}
  35. className="shrink-0"
  36. >
  37. <Search className="h-4 w-4" />
  38. Suchen
  39. </Button>
  40. </div>
  41. {currentQuery ? (
  42. <div className="text-xs text-muted-foreground">
  43. Aktuelle Suche:{" "}
  44. <span className="ml-1 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground">
  45. {currentQuery}
  46. </span>
  47. </div>
  48. ) : (
  49. <div className="text-xs text-muted-foreground">
  50. Tipp: Die Suche ist URL-basiert und kann als Link geteilt werden.
  51. </div>
  52. )}
  53. </div>
  54. );
  55. }