diff --git a/src/components/BaseInput/BaseInput.theme.ts b/src/components/BaseInput/BaseInput.theme.ts index c8c975d3..707d1600 100644 --- a/src/components/BaseInput/BaseInput.theme.ts +++ b/src/components/BaseInput/BaseInput.theme.ts @@ -27,10 +27,7 @@ import Theme from '../../themes/schema' * @param {Partial} theme - theme configuration. * @returns {Partial} The generated Input Ant theme configuration. */ -export default ({ palette, spacing, shape }: Partial): ComponentsTheme['Input'] => ({ - // sizing - paddingBlock: Number(spacing?.padding.sm), - paddingInline: Number(spacing?.padding.sm), +export default ({ palette, shape }: Partial): ComponentsTheme['Input'] => ({ // shape borderRadius: Number(shape?.border?.radius?.md), // palette diff --git a/src/components/Input/Input.tsx b/src/components/Input/Input.tsx index 8f495206..88c40523 100644 --- a/src/components/Input/Input.tsx +++ b/src/components/Input/Input.tsx @@ -16,6 +16,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { Input as AntInput, ConfigProvider, ThemeConfig } from 'antd' import { ChangeEvent, ReactElement, @@ -23,7 +24,6 @@ import { useMemo, useState, } from 'react' -import { Input as AntInput } from 'antd' import { AddonType, Type } from './types' import { BaseInput, defaults as baseInputDefaults } from '../BaseInput/BaseInput' @@ -32,6 +32,7 @@ import { Icon } from '../Icon' import { InputProps } from './props' import { isObject } from '../../utils/object.ts' import styles from './input.module.css' +import { useTheme } from '../../hooks/useTheme/useTheme.ts' export const defaults = { ...baseInputDefaults, @@ -95,6 +96,17 @@ export const Input = ( addonBefore: addonBeforeProp, }: InputProps ) : ReactElement => { + const { spacing } = useTheme() + + const scopedAntTheme: ThemeConfig = { + components: { + Input: { + paddingBlock: Number(spacing.padding.sm), + paddingInline: Number(spacing.padding.sm), + }, + }, + } + const [val, setVal] = useInputValue(value || defaultValue, valuePropName, { before: addonBeforeProp, after: addonAfterProp, @@ -160,29 +172,31 @@ export const Input = ( }, [getValue, defaultValue]) return ( - } - suffix={iconRight && } - type={type} - value={inputValue} - onChange={handleChange} - /> + + } + suffix={iconRight && } + type={type} + value={inputValue} + onChange={handleChange} + /> + ) } diff --git a/src/components/ThemeProvider/Ant.tsx b/src/components/ThemeProvider/Ant.tsx index 1a4c27b0..8de3e1a3 100644 --- a/src/components/ThemeProvider/Ant.tsx +++ b/src/components/ThemeProvider/Ant.tsx @@ -108,7 +108,7 @@ const generateAntTheme = ({ palette, typography, shape, spacing }: Partial