dgz-ui
Version:
Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript
40 lines • 1.72 kB
TypeScript
import { ComponentPropsWithoutRef, JSX, ReactNode } from 'react';
import { GroupBase } from 'react-select';
import { CreatableProps } from 'react-select/creatable';
import { ElementDataType } from '../../types';
/**
* Option shape for ReactSelect component.
*
* @property {ReactNode} label - Rendered label.
* @property {string|number} value - Primitive value emitted on selection.
*/
export type Option = {
label: ReactNode;
value: string | number;
};
/**
* Props for ReactSelect component.
* Based on react-select CreatableProps but simplified to always accept Option[] for options.
* Extends standard div props for the container.
*
* @property {Option[]} options - List of available options.
* @property {ReactNode} [label] - Optional label to render externally.
* @property {boolean} [error] - When true, applies error styles.
* @property {boolean} [canAddItem=false] - If true, allows creating new options inline.
*/
export interface ReactSelectProps extends Omit<CreatableProps<Option | Option['value'], boolean, GroupBase<Option | Option['value']>>, 'options'> {
options: Option[];
label?: ReactNode;
error?: boolean;
canAddItem?: boolean;
containerProps?: ComponentPropsWithoutRef<'div'> & ElementDataType;
}
/**
* Enhanced select input built on react-select with optional creatable mode and tailored styles.
*
* @component
* @param {ReactSelectProps} props - Props to configure behavior and appearance.
* @returns {JSX.Element}
*/
export declare const ReactSelect: ({ options, label, required, error, className, onChange, placeholder, canAddItem, containerProps, ...computedProps }: ReactSelectProps) => JSX.Element;
//# sourceMappingURL=react-select.d.ts.map