From 7b1ca1044d754d45b16f182a8fc6330d871162cf Mon Sep 17 00:00:00 2001 From: Myles Scolnick Date: Tue, 12 Sep 2023 16:15:39 -0400 Subject: [PATCH 1/4] enhancement: add min-length, max-length, disabled to text and text_area --- frontend/src/components/ui/input.tsx | 9 +++- frontend/src/components/ui/textarea.tsx | 28 ++++++++---- frontend/src/plugins/impl/TextAreaPlugin.tsx | 16 +++++++ frontend/src/plugins/impl/TextInputPlugin.tsx | 16 +++++++ marimo/_plugins/ui/_impl/input.py | 18 ++++++++ marimo/_smoke_tests/inputs.py | 45 +++++++++++++++++++ 6 files changed, 122 insertions(+), 10 deletions(-) create mode 100644 marimo/_smoke_tests/inputs.py diff --git a/frontend/src/components/ui/input.tsx b/frontend/src/components/ui/input.tsx index f6cd79cea25..4289cebc3a5 100644 --- a/frontend/src/components/ui/input.tsx +++ b/frontend/src/components/ui/input.tsx @@ -5,10 +5,11 @@ import { cn } from "@/lib/utils"; export type InputProps = React.InputHTMLAttributes & { icon?: React.ReactNode; + endAdornment?: React.ReactNode; }; const Input = React.forwardRef( - ({ className, type, ...props }, ref) => { + ({ className, type, endAdornment, ...props }, ref) => { const icon = props.icon; return ( @@ -23,11 +24,17 @@ const Input = React.forwardRef( className={cn( "flex h-6 w-full mb-1 rounded-sm shadow-xsSolid border border-input bg-transparent px-1.5 py-1 text-sm font-code ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground hover:shadow-smSolid focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:border-primary focus-visible:shadow-mdSolid disabled:cursor-not-allowed disabled:opacity-50", icon && "pl-7", + endAdornment && "pr-10", className )} ref={ref} {...props} /> + {endAdornment && ( +
+ {endAdornment} +
+ )} ); } diff --git a/frontend/src/components/ui/textarea.tsx b/frontend/src/components/ui/textarea.tsx index 19a49165be5..aefef2f70e1 100644 --- a/frontend/src/components/ui/textarea.tsx +++ b/frontend/src/components/ui/textarea.tsx @@ -3,19 +3,29 @@ import * as React from "react"; import { cn } from "@/lib/utils"; -export type TextareaProps = React.TextareaHTMLAttributes; +export interface TextareaProps + extends React.TextareaHTMLAttributes { + bottomAdornment?: React.ReactNode; +} const Textarea = React.forwardRef( - ({ className, ...props }, ref) => { + ({ className, bottomAdornment, ...props }, ref) => { return ( -