Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/cjs/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/index.js.map

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions dist/cjs/types/lib/RadioGroup/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { FC } from 'react';
import "./index.css";
interface RadioOption {
value: string;
label: React.ReactNode;
className?: string;
disabled?: boolean;
}
interface RadioGroupProps {
name?: string;
required?: boolean;
disabled?: boolean;
defaultValue?: string;
value?: string;
onChange?: (option: RadioOption) => void;
options: RadioOption[];
className?: string;
}
declare const RadioGroup: FC<RadioGroupProps>;
export type { RadioOption, RadioGroupProps };
export { RadioGroup };
1 change: 1 addition & 0 deletions dist/cjs/types/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from "./Dropdown";
export * from "./Avatar";
export * from "./Slider";
export * from "./Accordion";
export * from "./RadioGroup";
2 changes: 1 addition & 1 deletion dist/esm/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/index.js.map

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions dist/esm/types/lib/RadioGroup/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { FC } from 'react';
import "./index.css";
interface RadioOption {
value: string;
label: React.ReactNode;
className?: string;
disabled?: boolean;
}
interface RadioGroupProps {
name?: string;
required?: boolean;
disabled?: boolean;
defaultValue?: string;
value?: string;
onChange?: (option: RadioOption) => void;
options: RadioOption[];
className?: string;
}
declare const RadioGroup: FC<RadioGroupProps>;
export type { RadioOption, RadioGroupProps };
export { RadioGroup };
1 change: 1 addition & 0 deletions dist/esm/types/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from "./Dropdown";
export * from "./Avatar";
export * from "./Slider";
export * from "./Accordion";
export * from "./RadioGroup";
20 changes: 19 additions & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,22 @@ type AccordionItem = {
};
declare const Accordion: React__default.FC<AccordionProps>;

export { Accordion, type AccordionItem, type AccordionProps, type AllowedInputTypes, Avatar, type AvatarProps, Button, type ButtonProps, type Direction, type DropDownMenuItem, Dropdown, type DropdownProps, type IOrientation, type IPlacement, type ImageLoadingStatus, Input, type InputProps, OTPInput, type OTPInputProps, Slider, type SliderProps, Tooltip, type TooltipProps };
interface RadioOption {
value: string;
label: React__default.ReactNode;
className?: string;
disabled?: boolean;
}
interface RadioGroupProps {
name?: string;
required?: boolean;
disabled?: boolean;
defaultValue?: string;
value?: string;
onChange?: (option: RadioOption) => void;
options: RadioOption[];
className?: string;
}
declare const RadioGroup: FC<RadioGroupProps>;

export { Accordion, type AccordionItem, type AccordionProps, type AllowedInputTypes, Avatar, type AvatarProps, Button, type ButtonProps, type Direction, type DropDownMenuItem, Dropdown, type DropdownProps, type IOrientation, type IPlacement, type ImageLoadingStatus, Input, type InputProps, OTPInput, type OTPInputProps, RadioGroup, type RadioGroupProps, type RadioOption, Slider, type SliderProps, Tooltip, type TooltipProps };
11 changes: 11 additions & 0 deletions src/lib/RadioGroup/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Basic styles */
.radio-group-item {
display: flex;
align-items: center;
cursor: pointer;
margin-bottom: 8px;
}

.radio-group-item:last-child {
margin-bottom: 0;
}
68 changes: 68 additions & 0 deletions src/lib/RadioGroup/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React, { FC, useEffect, useState } from 'react';
import "./index.css";

interface RadioOption {
value: string;
label: React.ReactNode;
className?: string;
disabled?: boolean;
}

interface RadioGroupProps {
name?: string;
required?: boolean;
disabled?: boolean;
defaultValue?: string;
value?: string;
onChange?: (option: RadioOption) => void;
options: RadioOption[];
className?: string;
}

const RadioGroup: FC<RadioGroupProps> = ({
name,
required = false,
disabled = false,
defaultValue,
value: valueProp,
onChange,
options,
className = "",
}) => {
const [value, setValue] = useState<string | undefined>(defaultValue);

useEffect(() => {
if (valueProp !== undefined) {
setValue(valueProp);
}
}, [valueProp]);

const handleChange = (option: RadioOption) => {
setValue(option?.value);
onChange?.(option);
};

return (
<div role="radiogroup" aria-required={required} data-disabled={disabled ? '' : undefined} className={`radio-group ${className}`}>
{options.map((option) => (
<label key={option.value} className={`radio-group-item ${option?.className ?? ""}`}>
<input
type="radio"
name={name}
value={option.value}
checked={value === option.value}
required={required}
disabled={disabled || option.disabled}
onChange={() => handleChange(option)}
className="radio-input"
/>
<span className="radio-custom"></span> {/* Custom span for design */}
{option.label}
</label>
))}
</div>
);
};

export type { RadioOption, RadioGroupProps };
export { RadioGroup };
1 change: 1 addition & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from "./Dropdown";
export * from "./Avatar";
export * from "./Slider";
export * from "./Accordion";
export * from "./RadioGroup";