code: fakemui,tsx,radiogroup (6 files)

This commit is contained in:
Richard Ward
2025-12-30 12:59:35 +00:00
parent 1a43ef57de
commit 56ed528b4e
6 changed files with 46 additions and 12 deletions

View File

@@ -4,7 +4,7 @@ import React, { forwardRef, Children, cloneElement, isValidElement } from 'react
* Props for ButtonGroup component
*/
export interface ButtonGroupProps extends React.HTMLAttributes<HTMLDivElement> {
children: React.ReactNode
children?: React.ReactNode
/** Button size to apply to all children */
size?: 'sm' | 'md' | 'lg'
/** Button variant to apply to all children */

View File

@@ -23,7 +23,7 @@ export const useFormControl = () => useContext(FormControlContext)
* Props for FormControl component
*/
export interface FormControlProps extends React.HTMLAttributes<HTMLDivElement> {
children: React.ReactNode
children?: React.ReactNode
/** Whether the field is required */
required?: boolean
/** Whether the field is disabled */

View File

@@ -5,7 +5,7 @@ import { useFormControl } from './FormControl'
* Props for NativeSelect component
*/
export interface NativeSelectProps extends React.SelectHTMLAttributes<HTMLSelectElement> {
children: React.ReactNode
children?: React.ReactNode
/** Visual variant */
variant?: 'standard' | 'outlined' | 'filled'
/** Icon component to use for dropdown indicator */

View File

@@ -20,7 +20,7 @@ export const useRadioGroup = () => useContext(RadioGroupContext)
* Props for RadioGroup component
*/
export interface RadioGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
children: React.ReactNode
children?: React.ReactNode
/** Name attribute for all radio buttons */
name?: string
/** Currently selected value */

View File

@@ -80,3 +80,37 @@ export const CardMedia: React.FC<CardMediaProps> = ({ image, alt = '', height, c
aria-label={alt}
/>
)
// Additional Card subcomponents for Lua package compatibility
export interface CardTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {
children?: React.ReactNode
text?: string
}
export const CardTitle: React.FC<CardTitleProps> = ({ children, text, className = '', ...props }) => (
<h3 className={`card-title ${className}`} {...props}>
{text || children}
</h3>
)
export interface CardDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {
children?: React.ReactNode
text?: string
}
export const CardDescription: React.FC<CardDescriptionProps> = ({ children, text, className = '', ...props }) => (
<p className={`card-description ${className}`} {...props}>
{text || children}
</p>
)
export interface CardFooterProps extends React.HTMLAttributes<HTMLDivElement> {
children?: React.ReactNode
}
export const CardFooter: React.FC<CardFooterProps> = ({ children, className = '', ...props }) => (
<div className={`card-footer ${className}`} {...props}>
{children}
</div>
)

View File

@@ -3,14 +3,14 @@ import {
Article,
Autorenew,
Chat,
CheckBox,
Checkbox,
CropFree,
CropPortrait,
FormatAlignLeft,
GridView,
LocalOffer,
LooksOne,
Remove,
Minus,
TableChart,
TextFields,
ToggleOn,
@@ -20,21 +20,21 @@ import {
ViewColumn,
ViewStream,
WarningAmber,
} from '@mui/icons-material'
import type { SvgIconProps } from '@mui/material/SvgIcon'
type IconProps,
} from '@/fakemui/icons'
import type { ComponentType, ReactElement } from 'react'
const iconMap: Record<string, ComponentType<SvgIconProps>> = {
const iconMap: Record<string, ComponentType<IconProps>> = {
Article,
Card: CropPortrait,
Chat,
CheckSquare: CheckBox,
CheckSquare: Checkbox,
CircleNotch: Autorenew,
Columns: ViewColumn,
CursorClick: TouchApp,
FrameCorners: CropFree,
GridFour: GridView,
Minus: Remove,
Minus,
Seal: Verified,
SlidersHorizontal: Tune,
Stack: ViewStream,
@@ -48,7 +48,7 @@ const iconMap: Record<string, ComponentType<SvgIconProps>> = {
Warning: WarningAmber,
}
export function getComponentIcon(iconName: string, props?: SvgIconProps): ReactElement | null {
export function getComponentIcon(iconName: string, props?: IconProps): ReactElement | null {
const Icon = iconMap[iconName]
return Icon ? <Icon {...props} /> : null
}