Skip to main content
Glama
deleonio
by deleonio
InputContainer.tsx2.26 kB
import { h, type FunctionalComponent as FC } from '@stencil/core'; import type { JSXBase, VNode } from '@stencil/core/internal'; import clsx from 'clsx'; import { checkHasMsg, type MsgPropType, type Stringified } from '../../schema'; import InputAdornment from '../InputAdornment'; type InputAdornmentType = VNode | VNode[] | null; export type InputContainerProps = JSXBase.HTMLAttributes & { startAdornment?: InputAdornmentType; endAdornment?: InputAdornmentType; disabled?: boolean; msg?: Stringified<MsgPropType>; touched?: boolean; containerProps?: JSXBase.HTMLAttributes<HTMLDivElement>; startAdornmentProps?: JSXBase.HTMLAttributes<HTMLDivElement>; endAdornmentProps?: JSXBase.HTMLAttributes<HTMLDivElement>; }; function hasItems(items?: InputAdornmentType): boolean { if (!items) { return false; } return Array.isArray(items) ? items.length > 0 : Boolean(items); } const Container: FC<JSXBase.HTMLAttributes<HTMLDivElement>> = ({ class: className, ...other }, children) => { return ( <div class={clsx('kol-input-container__container', className)} {...other}> {children} </div> ); }; const KolInputContainerFc: FC<InputContainerProps> = (props, children) => { const { class: classNames, startAdornment, endAdornment, disabled, msg, touched, containerProps, startAdornmentProps, endAdornmentProps, ...other } = props; const showMsg = checkHasMsg(msg, touched); const msgType = typeof msg === 'string' ? 'error' : msg?._type; const stateCssClasses = { ['kol-input-container--disabled']: disabled, [`kol-input-container--${msgType || 'error'}`]: showMsg, }; const baseProps: JSXBase.HTMLAttributes<HTMLDivElement> = { class: clsx('kol-input-container', stateCssClasses, classNames), ...other, }; if (!hasItems(startAdornment) && !hasItems(endAdornment)) { return ( <div {...baseProps}> <Container {...containerProps}>{children}</Container> </div> ); } return ( <div {...baseProps}> <InputAdornment {...startAdornmentProps} position="start"> {startAdornment} </InputAdornment> <Container {...containerProps}>{children}</Container> <InputAdornment {...endAdornmentProps} position="end"> {endAdornment} </InputAdornment> </div> ); }; export default KolInputContainerFc;

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