Skip to main content
Glama
deleonio
by deleonio
NativeSelect.tsx1.77 kB
import { h, type FunctionalComponent as FC } from '@stencil/core'; import type { JSXBase } from '@stencil/core/internal'; import clsx from 'clsx'; import { checkHasMsg, type MsgPropType, type Stringified } from '../../../schema'; import { getDefaultProps } from '../_helpers/getDefaultProps'; import type { DefaultInputProps } from '../_types'; import NativeOptionListFc, { type NativeOptionListProps } from '../NativeOptionList'; type SelectAttributes = JSXBase.SelectHTMLAttributes<HTMLSelectElement>; export type SelectProps = DefaultInputProps<SelectAttributes> & NativeOptionListProps & { touched?: boolean; msg?: Stringified<MsgPropType>; } & { [key: `aria-${string}`]: unknown; [key: `data-${string}`]: unknown; }; const NativeSelectFc: FC<SelectProps> = (props) => { const { class: classNames, msg, touched, disabled, required, options, value, OptionProps, OptionGroupProps, ariaDescribedBy, hideLabel, label, ...other } = props; const showMsg = checkHasMsg(msg, touched); const msgType = typeof msg === 'string' ? 'error' : msg?._type; const stateCssClasses = { ['kol-select--disabled']: Boolean(disabled), ['kol-select--required']: Boolean(required), ['kol-select--touched']: Boolean(touched), [`kol-select--${msgType || 'error'}`]: showMsg, }; const inputProps: SelectAttributes = { class: clsx('kol-select', stateCssClasses, classNames), required: required, disabled: disabled, ...getDefaultProps({ ariaDescribedBy, hideLabel, label }), ...other, }; return ( <select {...inputProps}> <NativeOptionListFc baseClassName="kol-select" options={options} value={value} OptionGroupProps={OptionGroupProps} OptionProps={OptionProps} /> </select> ); }; export default NativeSelectFc;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/deleonio/public-ui-kolibri'

If you have feedback or need assistance with the MCP directory API, please join our Discord server