@dcl/react-ecs
Version:
Decentraland ECS
50 lines (49 loc) • 1.35 kB
JavaScript
import { parseProps } from '../utils';
import { ReactEcs } from '../../react-ecs';
import { getTextAlign, getFont, getFontSize } from '../Label/utils';
function parseUiInput(props) {
const { textAlign, font, fontSize, ...otherProps } = props;
return {
disabled: false,
placeholder: '',
...otherProps,
...getTextAlign(textAlign),
...getFont(font),
...getFontSize(fontSize)
};
}
/**
* @public
* Input component
*
* An Input is a field used to obtain a response from a user.
*
* @example
<Input
placeholder="Please enter your email"
onChange={(value) => {
email = value
}}
onSubmit={(value) => {
email = value
}}
uiBackground={{ color: Color4.Red() }}
uiTransform={{ width: 200, height: 36 }}
value={textValue}
/>
*
* @category Component
*/ /* @__PURE__ */
export function Input(props) {
const { uiTransform, uiBackground, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, ...otherProps } = props;
const inputProps = parseUiInput(otherProps);
const commonProps = parseProps({
uiTransform,
uiBackground,
onMouseDown,
onMouseUp,
onMouseEnter,
onMouseLeave
});
return ReactEcs.createElement("entity", { ...commonProps, uiInput: inputProps });
}