search-input.blade.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. {{-- resources/views/components/ui/search-input.blade.php --}}
  2. @props([
  3. 'action',
  4. 'value' => '',
  5. 'placeholder' => '搜索…',
  6. 'buttonText' => '搜索',
  7. 'size' => 'md',
  8. 'hiddenFields' => [],
  9. 'autofocus' => false,
  10. ])
  11. <form action="{{ $action }}" method="GET" class="search-input-form position-relative">
  12. <div class="input-group {{ $size === 'lg' ? 'input-group-lg' : '' }}">
  13. {{-- 🔍 图标输入框 --}}
  14. <div class="input-icon flex-grow-1">
  15. <span class="input-icon-addon">
  16. {{-- Tabler 搜索图标 --}}
  17. <svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24"
  18. viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
  19. fill="none" stroke-linecap="round" stroke-linejoin="round">
  20. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  21. <circle cx="10" cy="10" r="7" />
  22. <line x1="21" y1="21" x2="15" y2="15" />
  23. </svg>
  24. </span>
  25. <input
  26. type="text"
  27. name="q"
  28. class="form-control search-input"
  29. value="{{ $value }}"
  30. placeholder="{{ $placeholder }}"
  31. autocomplete="off"
  32. data-suggest-url="/api/v3/search-suggest"
  33. {{ $autofocus ? 'autofocus' : '' }} />
  34. </div>
  35. {{-- 隐藏字段 --}}
  36. @foreach ($hiddenFields as $name => $val)
  37. @if ($val)
  38. <input type="hidden" name="{{ $name }}" value="{{ $val }}">
  39. @endif
  40. @endforeach
  41. {{-- 按钮 --}}
  42. <button class="btn btn-primary" type="submit">
  43. {{ $buttonText }}
  44. </button>
  45. </div>
  46. {{-- 自动补全下拉 --}}
  47. <div class="search-suggest-dropdown dropdown-menu w-100"></div>
  48. </form>