CipherSuitesSelect.tsx 1014 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Select } from 'antd';
  2. import type { SelectProps } from 'antd';
  3. import { TLS_CIPHER_OPTION } from '@/schemas/primitives';
  4. const CIPHER_SUITE_OPTIONS = Object.values(TLS_CIPHER_OPTION).map((v) => ({ value: v, label: v }));
  5. type CipherSuitesSelectProps = Omit<
  6. SelectProps<string[]>,
  7. 'value' | 'onChange' | 'mode' | 'options'
  8. > & {
  9. // Injected by FormField:
  10. value?: string;
  11. onChange?: (value: string) => void;
  12. };
  13. // xray splits cipherSuites on ':' into a list, so the picker edits tags while
  14. // the stored value stays the single colon-joined string xray reads.
  15. export default function CipherSuitesSelect({
  16. value = '',
  17. onChange,
  18. ...rest
  19. }: CipherSuitesSelectProps) {
  20. const suites = value
  21. .split(':')
  22. .map((s) => s.trim())
  23. .filter(Boolean);
  24. return (
  25. <Select
  26. allowClear
  27. tokenSeparators={[':', ',']}
  28. {...rest}
  29. mode="tags"
  30. options={CIPHER_SUITE_OPTIONS}
  31. value={suites}
  32. onChange={(next) => onChange?.(next.join(':'))}
  33. />
  34. );
  35. }