diff --git a/src/components/TextInput/TextInput.stories.tsx b/src/components/TextInput/TextInput.stories.tsx index 2b519d6f..e05d523d 100644 --- a/src/components/TextInput/TextInput.stories.tsx +++ b/src/components/TextInput/TextInput.stories.tsx @@ -111,7 +111,7 @@ export const AfterIconButtonComponent: Story = { }, }; -export const AfterPrefixComponent: Story = { +export const AfterSufixComponent: Story = { args: { afterComponent: { type: 'Sufix', diff --git a/src/components/TextInput/TextInput.style.ts b/src/components/TextInput/TextInput.style.ts index 297cd28b..952108e6 100644 --- a/src/components/TextInput/TextInput.style.ts +++ b/src/components/TextInput/TextInput.style.ts @@ -28,11 +28,10 @@ export const defaultConfig = { h: 'medium', padding: 'component-padding-small component-padding-large', flexShrink: 0, - ring: '100', + ring: 'small', ringColor: { _: 'interaction-border-neutral-normal', - hover: 'interaction-border-hover', - focus: 'interaction-focus-default', + hoverWithoutButton: 'interaction-border-hover', alert: 'interaction-border-alert', }, borderRadius: 'large', @@ -40,13 +39,13 @@ export const defaultConfig = { disabled: 'disabled', }, outlineStyle: { - focusWithin: 'solid', + '&:has(input:focus)': 'solid', }, outlineColor: { focusWithin: 'interaction-focus-default', }, outlineWidth: { - focusWithin: 'focus', + '&:has(input:focus)': 'focus', }, outlineOffset: { alert: 'focus', diff --git a/src/components/TextInput/TextInput.tsx b/src/components/TextInput/TextInput.tsx index 2ba6514d..ee1bb177 100644 --- a/src/components/TextInput/TextInput.tsx +++ b/src/components/TextInput/TextInput.tsx @@ -16,7 +16,7 @@ import { Avatar } from '../Avatar'; import { Button } from '../Button'; import { IconButton } from '../IconButton'; -import { extractMarginProps } from '@/services/extractMarginProps'; +import { extractInputProps } from '@/services'; import { tet } from '@/tetrisly'; import { MarginProps } from '@/types/MarginProps'; @@ -34,7 +34,7 @@ export const TextInput = forwardRef< custom, value, onChange, - ...rest + ...restProps }, inputRef, ) => { @@ -43,9 +43,7 @@ export const TextInput = forwardRef< () => stylesBuilder(custom, beforeComponent?.type, afterComponent?.type), [afterComponent?.type, beforeComponent?.type, custom], ); - const [marginProps, inputProps] = extractMarginProps< - TextInputProps & MarginProps - >(rest); + const [textInputProps, containerProps] = extractInputProps(restProps); const containerRef = useRef(null); @@ -53,8 +51,7 @@ export const TextInput = forwardRef< (e) => { if (e.target === containerRef.current) { const input = containerRef.current?.querySelector('input'); - - if (input) input.focus(); + input?.focus(); } }, [containerRef], @@ -83,7 +80,8 @@ export const TextInput = forwardRef< pr={!!afterComponent && '0'} data-testid="text-input" data-state={state} - {...marginProps} + tabIndex={0} + {...containerProps} > {!!beforeComponent && ( = Omit< - T, - | 'm' - | 'margin' - | 'mt' - | 'marginTop' - | 'mr' - | 'marginRight' - | 'mb' - | 'marginBottom' - | 'ml' - | 'marginLeft' - | 'mx' - | 'my' ->; - -export const extractMarginProps = ( - props: T, -): [MarginsProps, OmitMarginProps] => { - if (!(props instanceof Object)) return [{}, {} as T]; - - const entries = Object.entries(props) as [keyof MarginProps, object][]; - const [marginsProps, restProps] = entries.reduce( - ([margins, rest], [key, value]) => { - if (marginPropsKeys.includes(key)) { - return [{ ...margins, [key]: value }, rest]; - } - return [margins, { ...rest, [key]: value }]; - }, - [{} as MarginProps, {} as OmitMarginProps], - ); - - return [marginsProps, restProps]; -}; diff --git a/src/services/extractMarginProps/index.ts b/src/services/extractMarginProps/index.ts deleted file mode 100644 index daa2f0c8..00000000 --- a/src/services/extractMarginProps/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { extractMarginProps } from './extractMarginProps'; diff --git a/src/services/index.ts b/src/services/index.ts index de55be94..b843824f 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,5 +1,4 @@ export * from './extractInputProps'; -export * from './extractMarginProps'; export * from './isKeyOf'; export * from './mergeConfigWithCustom'; export * from './mergeObjects'; diff --git a/src/theme/Theme.interface.ts b/src/theme/Theme.interface.ts index 00500de5..61b1b2b7 100644 --- a/src/theme/Theme.interface.ts +++ b/src/theme/Theme.interface.ts @@ -1228,5 +1228,6 @@ export type States = { selected: string; loading: string; alert: string; + hoverWithoutButton: string; indeterminate: string; }; diff --git a/src/theme/theme.ts b/src/theme/theme.ts index a7e3467c..4e4d93ff 100644 --- a/src/theme/theme.ts +++ b/src/theme/theme.ts @@ -1156,6 +1156,8 @@ const tempTheme: Omit = { disabled: '&:disabled, &[aria-disabled=true], &[data-state="disabled"]', selected: '&[data-state="selected"]', loading: '&[data-state="loading"]', + hoverWithoutButton: + '&:hover:not(:has(button:hover), &:invalid, &[data-state="alert"])', alert: '&:invalid, &[data-state="alert"]', indeterminate: '&:indeterminate', },