( currentValue: string[], choice: string, isChecked: boolean, )
| 3 | * Used by MultiCheckbox and ImageCheckbox components |
| 4 | */ |
| 5 | export function updateCheckboxArray( |
| 6 | currentValue: string[], |
| 7 | choice: string, |
| 8 | isChecked: boolean, |
| 9 | ): string[] { |
| 10 | // Ensure we have an array |
| 11 | const valueArray = Array.isArray(currentValue) ? currentValue : []; |
| 12 | |
| 13 | if (isChecked) { |
| 14 | // Add choice if not already present |
| 15 | return valueArray.includes(choice) ? valueArray : [...valueArray, choice]; |
| 16 | } else { |
| 17 | // Remove choice |
| 18 | return valueArray.filter((item) => item !== choice); |
| 19 | } |
| 20 | } |
nothing calls this directly
no outgoing calls
no test coverage detected