2021-02-26 20:57:36 +00:00
|
|
|
// Wraps the register callback from useForm into a new ref function, such that
|
|
|
|
// any child of the provided element that is an input component will be
|
|
|
|
// registered.
|
|
|
|
export function findInput(register) {
|
|
|
|
return (element) => {
|
|
|
|
const found = element ? element.querySelector('input, textarea, select, checkbox') : null
|
|
|
|
register(found)
|
|
|
|
}
|
|
|
|
}
|
2022-04-06 19:05:18 +00:00
|
|
|
|
|
|
|
// Generates pairs from the input iterable
|
|
|
|
export function* pairwise(it) {
|
|
|
|
let lastValue
|
|
|
|
let firstRound = true
|
|
|
|
|
|
|
|
for (const i of it) {
|
|
|
|
if (firstRound) {
|
|
|
|
firstRound = false
|
|
|
|
} else {
|
|
|
|
yield [lastValue, i]
|
|
|
|
}
|
|
|
|
lastValue = i
|
|
|
|
}
|
|
|
|
}
|