Skip to content

Commit

Permalink
value: string | number
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Aug 7, 2024
1 parent 87e9b02 commit 57261f4
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 17 deletions.
5 changes: 4 additions & 1 deletion docs/pages/base-ui/api/radio-group-item.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"props": {
"value": { "type": { "name": "any" }, "required": true },
"value": {
"type": { "name": "union", "description": "number<br>&#124;&nbsp;string" },
"required": true
},
"className": { "type": { "name": "union", "description": "func<br>&#124;&nbsp;string" } },
"disabled": { "type": { "name": "bool" }, "default": "false" },
"readOnly": { "type": { "name": "bool" }, "default": "false" },
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/base-ui/api/radio-group-root.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"props": {
"className": { "type": { "name": "union", "description": "func<br>&#124;&nbsp;string" } },
"defaultValue": { "type": { "name": "any" } },
"defaultValue": { "type": { "name": "union", "description": "number<br>&#124;&nbsp;string" } },
"disabled": { "type": { "name": "bool" }, "default": "false" },
"name": { "type": { "name": "string" } },
"onValueChange": { "type": { "name": "func" } },
"readOnly": { "type": { "name": "bool" }, "default": "false" },
"render": { "type": { "name": "union", "description": "element<br>&#124;&nbsp;func" } },
"required": { "type": { "name": "bool" }, "default": "false" },
"value": { "type": { "name": "any" } }
"value": { "type": { "name": "union", "description": "number<br>&#124;&nbsp;string" } }
},
"name": "RadioGroupRoot",
"imports": [
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/RadioGroup/Item/RadioGroupItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ RadioGroupItem.propTypes /* remove-proptypes */ = {
/**
* The unique identifying value of the radio button in the group.
*/
value: PropTypes.any.isRequired,
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
} as any;

export { RadioGroupItem };
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface RadioGroupItemProps
/**
* The unique identifying value of the radio button in the group.
*/
value: unknown;
value: string | number;
/**
* Determines if the item is disabled.
* @default false
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/RadioGroup/Item/useRadioGroupItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { visuallyHidden } from '../../utils/visuallyHidden';
import { useRadioGroupRootContext } from '../Root/RadioGroupRootContext';

interface UseRadioGroupItemParameters {
value: unknown;
value: string | number;
disabled?: boolean;
readOnly?: boolean;
required?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-base/src/RadioGroup/Root/RadioGroupRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ RadioGroupRoot.propTypes /* remove-proptypes */ = {
/**
* The default value of the selected radio button. Use when uncontrolled.
*/
defaultValue: PropTypes.any,
defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
/**
* Determines if the radio group is disabled.
* @default false
Expand Down Expand Up @@ -117,7 +117,7 @@ RadioGroupRoot.propTypes /* remove-proptypes */ = {
/**
* The value of the selected radio button. Use when controlled.
*/
value: PropTypes.any,
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
} as any;

export { RadioGroupRoot };
6 changes: 3 additions & 3 deletions packages/mui-base/src/RadioGroup/Root/RadioGroupRoot.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export interface RadioGroupRootProps
/**
* The value of the selected radio button. Use when controlled.
*/
value?: unknown;
value?: string | number;
/**
* The default value of the selected radio button. Use when uncontrolled.
*/
defaultValue?: unknown;
defaultValue?: string | number;
/**
* Callback fired when the value changes.
*/
onValueChange?: (value: unknown, event: React.ChangeEvent<HTMLInputElement>) => void;
onValueChange?: (value: string | number, event: React.ChangeEvent<HTMLInputElement>) => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export interface RadioGroupRootContextValue {
disabled: boolean | undefined;
readOnly: boolean | undefined;
required: boolean | undefined;
checkedItem: unknown;
setCheckedItem: React.Dispatch<React.SetStateAction<unknown>>;
onValueChange: (value: unknown, event: React.ChangeEvent<HTMLInputElement>) => void;
checkedItem: string | number;
setCheckedItem: React.Dispatch<React.SetStateAction<string | number>>;
onValueChange: (value: string | number, event: React.ChangeEvent<HTMLInputElement>) => void;
touched: boolean;
setTouched: React.Dispatch<React.SetStateAction<boolean>>;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/mui-base/src/RadioGroup/Root/useRadioGroupRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { useControlled } from '../../utils/useControlled';
interface UseRadioGroupRootParameters {
disabled?: boolean;
readOnly?: boolean;
defaultValue?: string;
value?: string;
defaultValue?: string | number;
value?: string | number;
}
/**
*
Expand All @@ -17,7 +17,7 @@ interface UseRadioGroupRootParameters {
export function useRadioGroupRoot(params: UseRadioGroupRootParameters) {
const { disabled, defaultValue, readOnly, value: externalValue } = params;

const [checkedItem, setCheckedItem] = useControlled<unknown>({
const [checkedItem, setCheckedItem] = useControlled<string | number>({
controlled: externalValue,
default: defaultValue,
name: 'RadioGroup',
Expand Down

0 comments on commit 57261f4

Please sign in to comment.