SearchActions.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. Copyright (C) 2025 QuantumNous
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial licensing, please contact support@quantumnous.com
  14. */
  15. import React, { memo, useCallback } from 'react';
  16. import { Input, Button } from '@douyinfe/semi-ui';
  17. import { IconSearch, IconCopy, IconFilter } from '@douyinfe/semi-icons';
  18. const SearchActions = memo(({
  19. selectedRowKeys = [],
  20. copyText,
  21. handleChange,
  22. handleCompositionStart,
  23. handleCompositionEnd,
  24. isMobile = false,
  25. searchValue = '',
  26. setShowFilterModal,
  27. t
  28. }) => {
  29. const handleCopyClick = useCallback(() => {
  30. if (copyText && selectedRowKeys.length > 0) {
  31. copyText(selectedRowKeys);
  32. }
  33. }, [copyText, selectedRowKeys]);
  34. const handleFilterClick = useCallback(() => {
  35. setShowFilterModal?.(true);
  36. }, [setShowFilterModal]);
  37. return (
  38. <div className="flex items-center gap-2 w-full">
  39. <div className="flex-1">
  40. <Input
  41. prefix={<IconSearch />}
  42. placeholder={t('模糊搜索模型名称')}
  43. value={searchValue}
  44. onCompositionStart={handleCompositionStart}
  45. onCompositionEnd={handleCompositionEnd}
  46. onChange={handleChange}
  47. showClear
  48. />
  49. </div>
  50. <Button
  51. theme="outline"
  52. type="primary"
  53. icon={<IconCopy />}
  54. onClick={handleCopyClick}
  55. disabled={selectedRowKeys.length === 0}
  56. className="!bg-blue-500 hover:!bg-blue-600 !text-white disabled:!bg-gray-300 disabled:!text-gray-500"
  57. >
  58. {t('复制')}
  59. </Button>
  60. {isMobile && (
  61. <Button
  62. theme="outline"
  63. type="tertiary"
  64. icon={<IconFilter />}
  65. onClick={handleFilterClick}
  66. >
  67. {t('筛选')}
  68. </Button>
  69. )}
  70. </div>
  71. );
  72. });
  73. SearchActions.displayName = 'SearchActions';
  74. export default SearchActions;