Skip to content

Commit

Permalink
Liste d'options pour disabled sur SelectCheckbox
Browse files Browse the repository at this point in the history
  • Loading branch information
JabX committed Jan 21, 2025
1 parent 997a56f commit e38727c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/forms/src/components/select-checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function clickHandlerFactory<T extends DomainFieldTypeMultiple>(

/** Props du SelectCheckbox */
export interface SelectCheckboxProps<T extends DomainFieldTypeMultiple> {
/** Désactive le select. */
disabled?: boolean;
/** Désactive le select en entier (si `true`) ou bien une liste d'options. */
disabled?: boolean | DomainType<T>[];
/** Message d'erreur à afficher. */
error?: string;
/** Libellé. */
Expand Down Expand Up @@ -91,7 +91,9 @@ export function SelectCheckbox<const T extends DomainFieldTypeMultiple>({

const isSelected = value ? !!value.find((val: any) => optVal === val) : false;
const isDisabled =
disabled || (maxSelectable !== undefined && maxSelectable === value?.length && !isSelected);
disabled === true ||
(Array.isArray(disabled) && disabled.includes(optVal)) ||
(maxSelectable !== undefined && maxSelectable === value?.length && !isSelected);
const clickHandler = clickHandlerFactory(isDisabled, isSelected, value, optVal, onChange);

return (
Expand Down

0 comments on commit e38727c

Please sign in to comment.