diff --git a/pkgs/webview-ui/app/src/components/inputBase/index.tsx b/pkgs/webview-ui/app/src/components/inputBase/index.tsx index 728a72451..b9608da1f 100644 --- a/pkgs/webview-ui/app/src/components/inputBase/index.tsx +++ b/pkgs/webview-ui/app/src/components/inputBase/index.tsx @@ -1,7 +1,7 @@ import cx from "classnames"; -import { createEffect, JSX, splitProps } from "solid-js"; +import { JSX, Ref, Show, splitProps } from "solid-js"; import Icon, { IconVariant } from "../icon"; -import { Typography } from "../Typography"; +import { Typography, TypographyProps } from "../Typography"; type Variants = "outlined" | "ghost"; interface InputBaseProps { @@ -17,6 +17,9 @@ interface InputBaseProps { readonly?: boolean; error?: boolean; icon?: IconVariant; + /** Overrides the input element */ + inputElem?: JSX.Element; + divRef?: Ref; } const variantBorder: Record = { @@ -27,11 +30,7 @@ const variantBorder: Record = { const fgStateClasses = cx("aria-disabled:fg-def-4 aria-readonly:fg-def-3"); export const InputBase = (props: InputBaseProps) => { - const [, inputProps] = splitProps(props, ["class"]); - - createEffect(() => { - console.log("InputBase", props.value, props.variant); - }); + const [internal, inputProps] = splitProps(props, ["class", "divRef"]); return (
{ // Cursor "aria-readonly:cursor-no-drop", - props.class, + props.class )} classList={{ [cx("!border !border-semantic-1 !outline-semantic-1")]: !!props.error, @@ -66,6 +65,7 @@ export const InputBase = (props: InputBaseProps) => { aria-readonly={props.readonly} tabIndex={0} role="textbox" + ref={internal.divRef} > {props.icon && ( { )} - + + +
); }; -interface InputLabelProps extends JSX.LabelHTMLAttributes { +export interface InputLabelProps + extends JSX.LabelHTMLAttributes { description?: string; required?: boolean; error?: boolean; help?: string; + labelAction?: JSX.Element; } export const InputLabel = (props: InputLabelProps) => { - const [labelProps, forwardProps] = splitProps(props, ["class"]); + const [labelProps, forwardProps] = splitProps(props, [ + "class", + "labelAction", + ]); return ( ); }; + +interface InputErrorProps { + error: string; + typographyProps?: TypographyProps; +} +export const InputError = (props: InputErrorProps) => { + const [typoClasses, rest] = splitProps( + props.typographyProps || { class: "" }, + ["class"] + ); + return ( + + {props.error} + + ); +};