alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
46 lines (42 loc) • 1.87 kB
JavaScript
import {
o2 as o
} from "./chunk-QEHUZJO2.js";
// node_modules/@headlessui/react/dist/utils/form.js
function e(i = {}, s = null, t = []) {
for (let [r, n] of Object.entries(i))
o2(t, f(s, r), n);
return t;
}
function f(i, s) {
return i ? i + "[" + s + "]" : s;
}
function o2(i, s, t) {
if (Array.isArray(t))
for (let [r, n] of t.entries())
o2(i, f(s, r.toString()), n);
else
t instanceof Date ? i.push([s, t.toISOString()]) : typeof t == "boolean" ? i.push([s, t ? "1" : "0"]) : typeof t == "string" ? i.push([s, t]) : typeof t == "number" ? i.push([s, `${t}`]) : t == null ? i.push([s, ""]) : e(t, s, i);
}
function p(i) {
var t, r;
let s = (t = i == null ? void 0 : i.form) != null ? t : i.closest("form");
if (s) {
for (let n of s.elements)
if (n !== i && (n.tagName === "INPUT" && n.type === "submit" || n.tagName === "BUTTON" && n.type === "submit" || n.nodeName === "INPUT" && n.type === "image")) {
n.click();
return;
}
(r = s.requestSubmit) == null || r.call(s);
}
}
// node_modules/@headlessui/react/dist/hooks/use-controllable.js
import { useRef as o3, useState as f2 } from "react";
function T(l, r, c) {
let [i, s] = f2(c), e2 = l !== void 0, t = o3(e2), u = o3(false), d = o3(false);
return e2 && !t.current && !u.current ? (u.current = true, t.current = e2, console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")) : !e2 && t.current && !d.current && (d.current = true, t.current = e2, console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")), [e2 ? l : i, o((n) => (e2 || s(n), r == null ? void 0 : r(n)))];
}
export {
e,
p,
T
};