Update props in components pass 2
This commit is contained in:
@@ -8,16 +8,23 @@ import { normalizeState } from "../../../../lib/propNormalization";
|
||||
const SwitchContainer = memo(
|
||||
forwardRef<HTMLButtonElement, SwitchProps>((props, ref) => {
|
||||
const {
|
||||
checked = false,
|
||||
checked: checkedProp,
|
||||
propSwitch: propSwitchProp,
|
||||
onChange,
|
||||
onFocus,
|
||||
onBlur,
|
||||
state: stateProp = "default",
|
||||
label,
|
||||
label: labelProp,
|
||||
text: textProp,
|
||||
className = "",
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
// Backward compatibility: use propSwitch if provided, otherwise use checked
|
||||
const checked = propSwitchProp !== undefined ? propSwitchProp : (checkedProp !== undefined ? checkedProp : false);
|
||||
// Backward compatibility: use text if provided, otherwise use label
|
||||
const label = textProp !== undefined ? textProp : labelProp;
|
||||
|
||||
// Normalize props to handle both PascalCase (Figma) and lowercase (codebase)
|
||||
const state = normalizeState(stateProp);
|
||||
|
||||
|
||||
@@ -4,7 +4,15 @@ export interface SwitchProps extends Omit<
|
||||
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
"onChange"
|
||||
> {
|
||||
/**
|
||||
* Whether the switch is checked (backward compatibility - use propSwitch instead).
|
||||
*/
|
||||
checked?: boolean;
|
||||
/**
|
||||
* Whether the switch is checked (Figma prop).
|
||||
* @default false
|
||||
*/
|
||||
propSwitch?: boolean;
|
||||
onChange?: (
|
||||
_e:
|
||||
| React.MouseEvent<HTMLButtonElement>
|
||||
@@ -17,7 +25,14 @@ export interface SwitchProps extends Omit<
|
||||
* Figma uses PascalCase, codebase uses lowercase - both are supported.
|
||||
*/
|
||||
state?: StateValue;
|
||||
/**
|
||||
* Label text (backward compatibility - use text instead).
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* Label text (Figma prop).
|
||||
*/
|
||||
text?: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user