Skip to content

Commit 148ac7d

Browse files
feat: Otp prop enhancements
1 parent 27d88c9 commit 148ac7d

6 files changed

Lines changed: 61 additions & 17 deletions

File tree

apps/showcase/assets/apidoc/index.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304193,6 +304193,30 @@
304193304193
"default": "",
304194304194
"description": "The children to render."
304195304195
},
304196+
{
304197+
"name": "size",
304198+
"optional": true,
304199+
"readonly": false,
304200+
"type": "\"small\" | \"large\" | \"normal\"",
304201+
"default": "",
304202+
"description": "Defines the size of the InputText."
304203+
},
304204+
{
304205+
"name": "variant",
304206+
"optional": true,
304207+
"readonly": false,
304208+
"type": "\"outlined\" | \"filled\"",
304209+
"default": "",
304210+
"description": "Specifies the input variant of the component."
304211+
},
304212+
{
304213+
"name": "disabled",
304214+
"optional": true,
304215+
"readonly": false,
304216+
"type": "boolean",
304217+
"default": "false",
304218+
"description": "When present, it specifies that the element should be disabled."
304219+
},
304196304220
{
304197304221
"name": "value",
304198304222
"optional": true,

apps/showcase/demo/inputotp/filled-demo.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { InputOtp } from 'primereact/inputotp';
33
export default function FilledDemo() {
44
return (
55
<div className="card flex justify-center">
6-
<InputOtp defaultValue={''}>
7-
<InputOtp.Text variant="filled" />
8-
<InputOtp.Text variant="filled" />
9-
<InputOtp.Text variant="filled" />
10-
<InputOtp.Text variant="filled" />
6+
<InputOtp defaultValue={''} variant="filled">
7+
<InputOtp.Text />
8+
<InputOtp.Text />
9+
<InputOtp.Text />
10+
<InputOtp.Text />
1111
</InputOtp>
1212
</div>
1313
);

apps/showcase/demo/inputotp/sizes-demo.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ import { InputOtp } from 'primereact/inputotp';
33
export default function SizesDemo() {
44
return (
55
<div className="card flex flex-col items-center gap-4">
6-
<InputOtp defaultValue={''}>
7-
<InputOtp.Text size="small" />
8-
<InputOtp.Text size="small" />
9-
<InputOtp.Text size="small" />
10-
<InputOtp.Text size="small" />
6+
<InputOtp defaultValue={''} size="small">
7+
<InputOtp.Text />
8+
<InputOtp.Text />
9+
<InputOtp.Text />
10+
<InputOtp.Text />
1111
</InputOtp>
1212
<InputOtp defaultValue={''}>
1313
<InputOtp.Text />
1414
<InputOtp.Text />
1515
<InputOtp.Text />
1616
<InputOtp.Text />
1717
</InputOtp>
18-
<InputOtp defaultValue={''}>
19-
<InputOtp.Text size="large" />
20-
<InputOtp.Text size="large" />
21-
<InputOtp.Text size="large" />
22-
<InputOtp.Text size="large" />
18+
<InputOtp defaultValue={''} size="large">
19+
<InputOtp.Text />
20+
<InputOtp.Text />
21+
<InputOtp.Text />
22+
<InputOtp.Text />
2323
</InputOtp>
2424
</div>
2525
);

packages/primereact/src/inputotp/InputOtp.props.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ import type { InputOtpProps } from '@primereact/types/shared/inputotp';
33

44
export const defaultProps: InputOtpProps = {
55
...HeadlessInputOtp.defaultProps,
6-
as: 'div'
6+
as: 'div',
7+
size: undefined,
8+
variant: undefined,
9+
disabled: false
710
};

packages/primereact/src/inputotp/text/InputOtpText.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export const InputOtpText = withComponent({
3131
type: inputotp?.inputType(),
3232
inputMode: inputotp?.inputMode(),
3333
className: inputotp?.cx('text'),
34+
size: inputotp?.props.size ?? props.size,
35+
variant: inputotp?.props.variant ?? props.variant,
36+
disabled: inputotp?.props.disabled ?? props.disabled,
3437
'data-pc-index': index,
3538
onInput: (e: React.FormEvent<HTMLInputElement>) => inputotp?.onInput?.(e, index),
3639
onClick: inputotp?.onClick,

packages/types/src/shared/inputotp/InputOtp.types.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,21 @@ export interface InputOtpPassThrough {
3434
/**
3535
* Defines valid properties in InputOtp component.
3636
*/
37-
export interface InputOtpProps extends BaseComponentProps<InputOtpInstance, useInputOtpProps, InputOtpPassThrough> {}
37+
export interface InputOtpProps extends BaseComponentProps<InputOtpInstance, useInputOtpProps, InputOtpPassThrough> {
38+
/**
39+
* Defines the size of the InputText.
40+
*/
41+
size?: 'small' | 'normal' | 'large' | undefined;
42+
/**
43+
* Specifies the input variant of the component.
44+
*/
45+
variant?: 'outlined' | 'filled' | undefined;
46+
/**
47+
* When present, it specifies that the element should be disabled.
48+
* @default false
49+
*/
50+
disabled?: boolean | undefined;
51+
}
3852

3953
/**
4054
* Defines valid state in InputOtp component.

0 commit comments

Comments
 (0)