From de919b39b036037a724d82ab4bf80db843c52cb8 Mon Sep 17 00:00:00 2001 From: Charles de Dreuille Date: Sat, 11 Oct 2025 22:31:35 +0100 Subject: [PATCH] Fix fields Signed-off-by: Charles de Dreuille --- .../PasswordField/PasswordField.tsx | 36 ++++++++++------- .../components/SearchField/SearchField.tsx | 39 +++++++++++-------- .../ui/src/components/TextField/TextField.tsx | 29 ++++++++------ packages/ui/src/utils/componentDefinitions.ts | 5 +++ 4 files changed, 66 insertions(+), 43 deletions(-) diff --git a/packages/ui/src/components/PasswordField/PasswordField.tsx b/packages/ui/src/components/PasswordField/PasswordField.tsx index fc5dae1088..8701d50652 100644 --- a/packages/ui/src/components/PasswordField/PasswordField.tsx +++ b/packages/ui/src/components/PasswordField/PasswordField.tsx @@ -32,17 +32,9 @@ import { RiEyeLine, RiEyeOffLine } from '@remixicon/react'; export const PasswordField = forwardRef( (props, ref) => { const { - className, - icon, - size = 'small', label, - secondaryLabel, - description, - isRequired, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, - placeholder, - ...rest } = props; useEffect(() => { @@ -53,15 +45,28 @@ export const PasswordField = forwardRef( } }, [label, ariaLabel, ariaLabelledBy]); - const { classNames: passwordFieldClassNames, dataAttributes } = useStyles( - 'PasswordField', - { - size, - }, - ); - const { classNames: textFieldClassNames } = useStyles('TextField', {}); + const { + classNames: passwordFieldClassNames, + dataAttributes, + style, + cleanedProps, + } = useStyles('PasswordField', { + size: 'small', + ...props, + }); + + const { + className, + description, + icon, + isRequired, + secondaryLabel, + placeholder, + ...rest + } = cleanedProps; + // If a secondary label is provided, use it. Otherwise, use 'Required' if the field is required. const secondaryLabelText = secondaryLabel || (isRequired ? 'Required' : null); @@ -76,6 +81,7 @@ export const PasswordField = forwardRef( aria-label={ariaLabel} aria-labelledby={ariaLabelledBy} type="password" + style={style} {...rest} ref={ref} > diff --git a/packages/ui/src/components/SearchField/SearchField.tsx b/packages/ui/src/components/SearchField/SearchField.tsx index 1c4bb7fa18..009bad2150 100644 --- a/packages/ui/src/components/SearchField/SearchField.tsx +++ b/packages/ui/src/components/SearchField/SearchField.tsx @@ -32,19 +32,9 @@ import type { SearchFieldProps } from './types'; export const SearchField = forwardRef( (props, ref) => { const { - className, - icon, - size = 'small', label, - secondaryLabel, - description, - isRequired, - onChange, - placeholder = 'Search', - startCollapsed = false, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, - ...rest } = props; const [isCollapsed, setIsCollapsed] = useState(false); @@ -58,14 +48,28 @@ export const SearchField = forwardRef( } }, [label, ariaLabel, ariaLabelledBy]); - const { classNames: textFieldClassNames, dataAttributes } = useStyles( - 'TextField', - { - size, - }, - ); + const { classNames: textFieldClassNames } = useStyles('TextField'); - const { classNames: searchFieldClassNames } = useStyles('SearchField', {}); + const { + classNames: searchFieldClassNames, + dataAttributes, + style, + cleanedProps, + } = useStyles('SearchField', { + size: 'small', + ...props, + }); + + const { + className, + description, + icon, + isRequired, + secondaryLabel, + placeholder, + startCollapsed, + ...rest + } = cleanedProps; // If a secondary label is provided, use it. Otherwise, use 'Required' if the field is required. const secondaryLabelText = @@ -105,6 +109,7 @@ export const SearchField = forwardRef( data-collapsed={isCollapsed} onFocusChange={handleClick} onChange={handleChange} + style={style} {...rest} ref={ref} > diff --git a/packages/ui/src/components/TextField/TextField.tsx b/packages/ui/src/components/TextField/TextField.tsx index 2756c3c85f..84b4642d93 100644 --- a/packages/ui/src/components/TextField/TextField.tsx +++ b/packages/ui/src/components/TextField/TextField.tsx @@ -27,17 +27,9 @@ import { useStyles } from '../../hooks/useStyles'; export const TextField = forwardRef( (props, ref) => { const { - className, - icon, - size = 'small', label, - secondaryLabel, - description, - isRequired, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, - placeholder, - ...rest } = props; useEffect(() => { @@ -48,9 +40,23 @@ export const TextField = forwardRef( } }, [label, ariaLabel, ariaLabelledBy]); - const { classNames, dataAttributes } = useStyles('TextField', { - size, - }); + const { classNames, dataAttributes, style, cleanedProps } = useStyles( + 'TextField', + { + size: 'small', + ...props, + }, + ); + + const { + className, + description, + icon, + isRequired, + secondaryLabel, + placeholder, + ...rest + } = cleanedProps; // If a secondary label is provided, use it. Otherwise, use 'Required' if the field is required. const secondaryLabelText = @@ -62,6 +68,7 @@ export const TextField = forwardRef( {...dataAttributes} aria-label={ariaLabel} aria-labelledby={ariaLabelledBy} + style={style} {...rest} ref={ref} > diff --git a/packages/ui/src/utils/componentDefinitions.ts b/packages/ui/src/utils/componentDefinitions.ts index 131bca54b9..fe40abace5 100644 --- a/packages/ui/src/utils/componentDefinitions.ts +++ b/packages/ui/src/utils/componentDefinitions.ts @@ -248,6 +248,9 @@ export const componentDefinitions = { root: 'bui-PasswordField', inputVisibility: 'bui-InputVisibility', }, + dataAttributes: { + size: ['small', 'medium'] as const, + }, }, Popover: { classNames: { @@ -276,6 +279,7 @@ export const componentDefinitions = { }, dataAttributes: { startCollapsed: [true, false] as const, + size: ['small', 'medium'] as const, }, }, Select: { @@ -366,6 +370,7 @@ export const componentDefinitions = { dataAttributes: { invalid: [true, false] as const, disabled: [true, false] as const, + size: ['small', 'medium'] as const, }, }, Tooltip: {