analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
218 lines • 7.44 kB
TypeScript
import { InputHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
import { StoreApi } from 'zustand';
/**
* Radio size variants
*/
type RadioSize = 'small' | 'medium' | 'large' | 'extraLarge';
/**
* Radio visual state
*/
type RadioState = 'default' | 'hovered' | 'focused' | 'invalid' | 'disabled';
/**
* Radio component props interface
*/
export type RadioProps = {
/** Label text to display next to the radio */
label?: ReactNode;
/** Size variant of the radio */
size?: RadioSize;
/** Visual state of the radio */
state?: RadioState;
/** Error message to display */
errorMessage?: string;
/** Helper text to display */
helperText?: string;
/** Additional CSS classes */
className?: string;
/** Label CSS classes */
labelClassName?: string;
/** Radio group name */
name?: string;
/** Radio value */
value?: string;
/** Default checked state for uncontrolled radios */
defaultChecked?: boolean;
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'type' | 'defaultChecked'>;
/**
* Radio component for Analytica Ensino platforms
*
* A radio button component with essential states, sizes and themes.
* Uses the Analytica Ensino Design System colors from styles.css with automatic
* light/dark mode support. Includes Text component integration for consistent typography.
*
* @example
* ```tsx
* // Basic radio
* <Radio name="option" value="1" label="Option 1" />
*
* // Small size
* <Radio size="small" name="option" value="2" label="Small option" />
*
* // Invalid state
* <Radio state="invalid" name="option" value="3" label="Required field" />
*
* // Disabled state
* <Radio disabled name="option" value="4" label="Disabled option" />
*
* // Default checked (uncontrolled)
* <Radio defaultChecked name="option" value="5" label="Initially checked" />
* ```
*/
declare const Radio: import("react").ForwardRefExoticComponent<{
/** Label text to display next to the radio */
label?: ReactNode;
/** Size variant of the radio */
size?: RadioSize;
/** Visual state of the radio */
state?: RadioState;
/** Error message to display */
errorMessage?: string;
/** Helper text to display */
helperText?: string;
/** Additional CSS classes */
className?: string;
/** Label CSS classes */
labelClassName?: string;
/** Radio group name */
name?: string;
/** Radio value */
value?: string;
/** Default checked state for uncontrolled radios */
defaultChecked?: boolean;
} & Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "defaultChecked" | "size"> & import("react").RefAttributes<HTMLInputElement>>;
/**
* RadioGroup store interface
*/
interface RadioGroupStore {
value: string;
setValue: (value: string) => void;
onValueChange?: (value: string) => void;
disabled: boolean;
name: string;
}
type RadioGroupStoreApi = StoreApi<RadioGroupStore>;
/**
* Hook to access RadioGroup store
*/
export declare const useRadioGroupStore: (externalStore?: RadioGroupStoreApi) => RadioGroupStoreApi;
/**
* RadioGroup component props interface
*/
export type RadioGroupProps = {
/** Current selected value */
value?: string;
/** Default selected value for uncontrolled usage */
defaultValue?: string;
/** Callback when selection changes */
onValueChange?: (value: string) => void;
/** Group name for all radios */
name?: string;
/** Disabled state for the entire group */
disabled?: boolean;
/** Additional CSS classes */
className?: string;
/** Children components */
children: ReactNode;
} & Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'>;
/**
* RadioGroup component for flexible radio group composition
*
* Uses Zustand for state management with automatic store injection.
* Allows complete control over layout and styling by composing with RadioGroupItem.
*
* @example
* ```tsx
* <RadioGroup defaultValue="option1" onValueChange={setValue}>
* <div className="flex items-center gap-3">
* <RadioGroupItem value="option1" id="r1" />
* <label htmlFor="r1">Option 1</label>
* </div>
* <div className="flex items-center gap-3">
* <RadioGroupItem value="option2" id="r2" />
* <label htmlFor="r2">Option 2</label>
* </div>
* </RadioGroup>
* ```
*/
declare const RadioGroup: import("react").ForwardRefExoticComponent<{
/** Current selected value */
value?: string;
/** Default selected value for uncontrolled usage */
defaultValue?: string;
/** Callback when selection changes */
onValueChange?: (value: string) => void;
/** Group name for all radios */
name?: string;
/** Disabled state for the entire group */
disabled?: boolean;
/** Additional CSS classes */
className?: string;
/** Children components */
children: ReactNode;
} & Omit<HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> & import("react").RefAttributes<HTMLDivElement>>;
/**
* RadioGroupItem component props interface
*/
export type RadioGroupItemProps = {
/** Value for this radio item */
value: string;
/** Optional label rendered next to the radio (parity with CheckBox/Radio APIs) */
label?: ReactNode;
/** CSS classes applied to the label */
labelClassName?: string;
/** Store reference (automatically injected by RadioGroup) */
store?: RadioGroupStoreApi;
/** Disabled state for this specific item */
disabled?: boolean;
/** Size variant */
size?: RadioSize;
/** Visual state */
state?: RadioState;
/** Additional CSS classes */
className?: string;
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'name' | 'value' | 'checked' | 'onChange' | 'size'>;
/**
* RadioGroupItem component for use within RadioGroup
*
* A radio button that works within RadioGroup context.
* Accepts a `label` prop for the common case (parity with CheckBox/Radio).
* When `label` is omitted, renders just the input for custom composition.
*
* @example
* ```tsx
* // With label (recommended)
* <RadioGroup defaultValue="option1">
* <RadioGroupItem value="option1" label="Option 1" />
* <RadioGroupItem value="option2" label="Option 2" />
* </RadioGroup>
*
* // Without label - manual composition
* <RadioGroup defaultValue="option1">
* <div className="flex items-center gap-3">
* <RadioGroupItem value="option1" id="r1" />
* <label htmlFor="r1">Custom layout</label>
* </div>
* </RadioGroup>
* ```
*/
declare const RadioGroupItem: import("react").ForwardRefExoticComponent<{
/** Value for this radio item */
value: string;
/** Optional label rendered next to the radio (parity with CheckBox/Radio APIs) */
label?: ReactNode;
/** CSS classes applied to the label */
labelClassName?: string;
/** Store reference (automatically injected by RadioGroup) */
store?: RadioGroupStoreApi;
/** Disabled state for this specific item */
disabled?: boolean;
/** Size variant */
size?: RadioSize;
/** Visual state */
state?: RadioState;
/** Additional CSS classes */
className?: string;
} & Omit<InputHTMLAttributes<HTMLInputElement>, "name" | "type" | "value" | "onChange" | "size" | "checked"> & import("react").RefAttributes<HTMLInputElement>>;
export default Radio;
export { RadioGroup, RadioGroupItem };
//# sourceMappingURL=Radio.d.ts.map