( state: State, options: SelectOptions<A> )
| 205 | } |
| 206 | |
| 207 | function processSpace<A>( |
| 208 | state: State, |
| 209 | options: SelectOptions<A> |
| 210 | ) { |
| 211 | const selectedIndices = new Set(state.selectedIndices) |
| 212 | if (state.index === 0) { |
| 213 | if (state.selectedIndices.size === options.choices.length) { |
| 214 | selectedIndices.clear() |
| 215 | } else { |
| 216 | for (let i = 0; i < options.choices.length; i++) { |
| 217 | selectedIndices.add(i) |
| 218 | } |
| 219 | } |
| 220 | } else if (state.index === 1) { |
| 221 | for (let i = 0; i < options.choices.length; i++) { |
| 222 | if (state.selectedIndices.has(i)) { |
| 223 | selectedIndices.delete(i) |
| 224 | } else { |
| 225 | selectedIndices.add(i) |
| 226 | } |
| 227 | } |
| 228 | } else { |
| 229 | const choiceIndex = state.index - metaOptionsCount |
| 230 | if (selectedIndices.has(choiceIndex)) { |
| 231 | selectedIndices.delete(choiceIndex) |
| 232 | } else { |
| 233 | selectedIndices.add(choiceIndex) |
| 234 | } |
| 235 | } |
| 236 | return Effect.succeed(Action.NextFrame({ state: { ...state, selectedIndices } })) |
| 237 | } |
| 238 | |
| 239 | export function handleClear<A>(options: SelectOptions<A>) { |
| 240 | return Effect.gen(function*() { |
no test coverage detected