Skip to content

Commit

Permalink
chore: Add isRequired to NumberField RenderProps (#7831)
Browse files Browse the repository at this point in the history
  • Loading branch information
snowystinger authored Feb 26, 2025
1 parent 5334df7 commit 3f244b4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/react-aria-components/src/NumberField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export interface NumberFieldRenderProps {
* @selector [data-invalid]
*/
isInvalid: boolean,
/**
* Whether the number field is required.
* @selector [data-required]
*/
isRequired: boolean,
/**
* State of the number field.
*/
Expand Down Expand Up @@ -84,7 +89,8 @@ export const NumberField = /*#__PURE__*/ (forwardRef as forwardRefType)(function
values: {
state,
isDisabled: props.isDisabled || false,
isInvalid: validation.isInvalid || false
isInvalid: validation.isInvalid || false,
isRequired: props.isRequired || false
},
defaultClassName: 'react-aria-NumberField'
});
Expand Down Expand Up @@ -119,6 +125,7 @@ export const NumberField = /*#__PURE__*/ (forwardRef as forwardRefType)(function
ref={ref}
slot={props.slot || undefined}
data-disabled={props.isDisabled || undefined}
data-required={props.isRequired || undefined}
data-invalid={validation.isInvalid || undefined} />
{props.name && <input type="hidden" name={props.name} value={isNaN(state.numberValue) ? '' : state.numberValue} />}
</Provider>
Expand Down

1 comment on commit 3f244b4

@rspbot
Copy link

@rspbot rspbot commented on 3f244b4 Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.