Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

index.tsx 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. 'use client'
  2. import { RiCloseLine, RiSearchLine } from '@remixicon/react'
  3. import TagsFilter from './tags-filter'
  4. import ActionButton from '@/app/components/base/action-button'
  5. import cn from '@/utils/classnames'
  6. import { RiAddLine } from '@remixicon/react'
  7. type SearchBoxProps = {
  8. search: string
  9. onSearchChange: (search: string) => void
  10. inputClassName?: string
  11. tags: string[]
  12. onTagsChange: (tags: string[]) => void
  13. size?: 'small' | 'large'
  14. placeholder?: string
  15. locale?: string
  16. supportAddCustomTool?: boolean
  17. onShowAddCustomCollectionModal?: () => void
  18. onAddedCustomTool?: () => void
  19. }
  20. const SearchBox = ({
  21. search,
  22. onSearchChange,
  23. inputClassName,
  24. tags,
  25. onTagsChange,
  26. size = 'small',
  27. placeholder = '',
  28. locale,
  29. supportAddCustomTool,
  30. onShowAddCustomCollectionModal,
  31. }: SearchBoxProps) => {
  32. return (
  33. <div
  34. className='z-[11] flex items-center'
  35. >
  36. <div className={
  37. cn('flex items-center',
  38. size === 'large' && 'rounded-xl border border-components-chat-input-border bg-components-panel-bg-blur p-1.5 shadow-md',
  39. size === 'small' && 'rounded-lg bg-components-input-bg-normal p-0.5',
  40. inputClassName,
  41. )
  42. }>
  43. <div className='relative flex grow items-center p-1 pl-2'>
  44. <div className='mr-2 flex w-full items-center'>
  45. <RiSearchLine className='mr-1.5 size-4 text-text-placeholder' />
  46. <input
  47. className={cn(
  48. 'body-md-medium block grow appearance-none bg-transparent text-text-secondary outline-none',
  49. )}
  50. value={search}
  51. onChange={(e) => {
  52. onSearchChange(e.target.value)
  53. }}
  54. placeholder={placeholder}
  55. />
  56. {
  57. search && (
  58. <div className='absolute right-2 top-1/2 -translate-y-1/2'>
  59. <ActionButton onClick={() => onSearchChange('')}>
  60. <RiCloseLine className='h-4 w-4' />
  61. </ActionButton>
  62. </div>
  63. )
  64. }
  65. </div>
  66. </div>
  67. <div className='mx-1 h-3.5 w-[1px] bg-divider-regular'></div>
  68. <TagsFilter
  69. tags={tags}
  70. onTagsChange={onTagsChange}
  71. size={size}
  72. locale={locale}
  73. />
  74. </div>
  75. {supportAddCustomTool && (
  76. <div className='flex shrink-0 items-center'>
  77. <ActionButton
  78. className='ml-2 rounded-full bg-components-button-primary-bg text-components-button-primary-text hover:bg-components-button-primary-bg hover:text-components-button-primary-text'
  79. onClick={onShowAddCustomCollectionModal}
  80. >
  81. <RiAddLine className='h-4 w-4' />
  82. </ActionButton>
  83. </div>
  84. )}
  85. </div>
  86. )
  87. }
  88. export default SearchBox