import type { PropsPlugin } from '../../../../types/component-plugin';
import type { SelectUIProps } from '../types';

export function createSelectPlaceholderPlugin(placeholder: string): PropsPlugin<SelectUIProps> {
  return (props) => ({
    ...props,
    placeholder,
  });
}

export function createSelectSortPlugin(): PropsPlugin<SelectUIProps> {
  return (props) => ({
    ...props,
    data: [...props.data].sort((left, right) => left.value.localeCompare(right.value)),
  });
}
