Skip to content

Commit

Permalink
chore: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfrancois committed Oct 10, 2023
1 parent 0432b1c commit b06871d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import Label from '../../Label';

import styles from './Checkbox.module.scss';

type CheckboxProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> & {
// Redefine onChange
onChange?: (isChecked: boolean) => void;

type CheckboxProps = InputHTMLAttributes<HTMLInputElement> & {
value?: string | number;
};

Expand Down Expand Up @@ -72,10 +69,9 @@ const CheckboxPrimitive = forwardRef(
id={checkboxId}
checked={checked}
aria-checked={indeterminate ? 'mixed' : checked}
onChange={() =>
// If readonly, we return current check status ; Else we return opposite status as new status
onChange?.(Boolean(readOnly ? checked : !checked))
}
onChange={e => {
onChange?.(e);
}}
{...rest}
/>
<Label htmlFor={checkboxId} inline>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { CheckboxPrimitiveType } from '../../Checkbox/Primitive/CheckboxPrimitiv

import styles from './ToggleSwitchPrimitive.module.scss';

export type ToggleSwitchPrimitiveType = CheckboxPrimitiveType;
export type ToggleSwitchPrimitiveType = Omit<CheckboxPrimitiveType, 'onChange'> & {
onChange?: (checked: boolean) => void;
};

const ToggleSwitchPrimitive = forwardRef(
(
Expand Down
7 changes: 5 additions & 2 deletions packages/design-system/src/components/Form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import Fieldset from './Fieldset';
import Form from './Form';
import Label from './Label';
import Row from './Row';
import { Checkbox } from './Checkbox';

export const FormComponent = Form as typeof Form & {
Row: typeof Row;
Color: typeof Input.Color;
Checkbox: typeof Checkbox;
Datalist: typeof Datalist;
Date: typeof Input.Date;
DatetimeLocal: typeof Input.DatetimeLocal;
Expand Down Expand Up @@ -41,29 +43,30 @@ export const FormComponent = Form as typeof Form & {
FormComponent.Row = Row;

FormComponent.Color = Input.Color;
FormComponent.Copy = Input.Copy;
FormComponent.Checkbox = Checkbox;
FormComponent.Datalist = Datalist;
FormComponent.Date = Input.Date;
FormComponent.DatetimeLocal = Input.DatetimeLocal;
FormComponent.Email = Input.Email;
FormComponent.Fieldset = Fieldset;
FormComponent.File = Input.File;
FormComponent.Hidden = Input.Hidden;
FormComponent.Copy = Input.Copy;
FormComponent.Label = Label;
FormComponent.Month = Input.Month;
FormComponent.Number = Input.Number;
FormComponent.Password = Input.Password;
FormComponent.Radio = Input.Radio;
FormComponent.Search = Input.Search;
FormComponent.Select = Select;
FormComponent.ToggleSwitch = ToggleSwitch;
FormComponent.Tel = Input.Tel;
FormComponent.Text = Input.Text;
FormComponent.Textarea = Textarea;
FormComponent.Time = Input.Time;
FormComponent.Url = Input.Url;
FormComponent.Week = Input.Week;
FormComponent.Input = Input;
FormComponent.ToggleSwitch = ToggleSwitch;

FormComponent.Buttons = Buttons;

Expand Down

0 comments on commit b06871d

Please sign in to comment.