import { Meta } from '@storybook/addon-docs/blocks'

<Meta title='@dxtmisha/en/functional-basic/Functions/setValues - Managing the list of selected values'/>

# `setValues`

Handles updating selected values based on the selection mode (single or multiple). Allows adding, removing, or replacing values with support for maximum element constraints.

**Parameters:**
- `selected: T | T[] | undefined` — The current selected values.
- `value: any` — The new value to process.
- `options` — An object with settings:
    - `multiple: boolean` — Multiple selection mode (defaults to `false`).
    - `maxlength: number` — Maximum number of elements for multiple selection (defaults to `0` — unlimited).
    - `alwaysChange: boolean` — Forced value replacement flag (defaults to `true`).
    - `notEmpty: boolean` — Prevents the list from being completely cleared (defaults to `false`).

**Returns:**
`T | T[] | undefined` — The new state of selected values.

```typescript
import { setValues } from '@dxtmisha/functional-basic'

// Single selection
console.log(setValues(1, 2, {})) // 2

// Multiple selection (toggle)
let list = [1, 2]
list = setValues(list, 2, { multiple: true }) // [1] (removal of existing)
list = setValues(list, 3, { multiple: true }) // [1, 3] (addition of new)
```
