Skip to content

Commit

Permalink
[@mantine/core] PinInput: Allow passing props to individual input ele…
Browse files Browse the repository at this point in the history
…ments depending on index with `getInputProps` (#6588)
  • Loading branch information
rtivital committed Aug 7, 2024
1 parent 8f5a15e commit ebe8b0e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/@mantine/core/src/components/PinInput/PinInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
useStyles,
} from '../../core';
import { Group } from '../Group';
import { Input } from '../Input';
import { Input, InputProps } from '../Input';
import { InputBase } from '../InputBase';
import { createPinArray } from './create-pin-array/create-pin-array';
import classes from './PinInput.module.css';
Expand Down Expand Up @@ -119,6 +119,9 @@ export interface PinInputProps

/** Assigns ref of the root element */
rootRef?: React.ForwardedRef<HTMLDivElement>;

/** Props added to the input element depending on its index */
getInputProps?: (index: number) => InputProps & ElementProps<'input', 'size'>;
}

export type PinInputFactory = Factory<{
Expand Down Expand Up @@ -178,6 +181,7 @@ export const PinInput = factory<PinInputFactory>((props, ref) => {
id,
hiddenInputProps,
rootRef,
getInputProps,
...others
} = useProps('PinInput', defaultProps, props);

Expand Down Expand Up @@ -415,6 +419,7 @@ export const PinInput = factory<PinInputFactory>((props, ref) => {
unstyled={unstyled}
aria-label={ariaLabel}
readOnly={readOnly}
{...getInputProps?.(index)}
/>
))}
</Group>
Expand Down

0 comments on commit ebe8b0e

Please sign in to comment.