koval-ui
Version:
React components collection with minimalistic design. Supports theming, layout, and input validation.
28 lines (27 loc) • 653 B
JavaScript
"use client";
import { useState as h, useCallback as m } from "react";
import { useCallbackRef as c } from "./useCallbackRef.js";
const V = (t) => typeof t == "function";
function b(t, ...o) {
return V(t) ? t(...o) : t;
}
function S(t) {
const {
value: o,
defaultValue: r,
onChange: i,
shouldUpdate: f = (a, e) => a !== e
} = t, l = c(i), s = c(f), [p, d] = h(r), u = o !== void 0, n = u ? o : p, C = m(
(a) => {
const e = b(a, n);
s(n, e) && (u || d(e), l(e));
},
[u, l, n, s]
);
return [n, C];
}
export {
b as runIfFn,
S as useControllableState
};
//# sourceMappingURL=useControllableState.js.map