@sheetxl/studio-vanilla
Version:
SheetXL Studio - Vanilla entry point for integrating SheetXL UI.
40 lines (39 loc) • 2.42 kB
JavaScript
import { r as e, z as o, K as N, j as i, A as $, B as A, M as E, k as R, l as y, as as W, p as w } from "./Bf37sZn7h1jSr98w.mjs";
/**
* @license @sheetxl/studio-vanilla - SheetXL Studio - Vanilla entry point for integrating SheetXL UI. - v0.7.27
*
* (C) 2025-present SheetXL Inc. & Michael T. Ford
* License: The license can be found at https://www.sheetxl.com/license.
*/
const q = ["Input"], J = e.memo(e.forwardRef((O, T) => {
const { initialValue: F = "", onOption: I, onValidateOption: l, onInput: r, onValidateInput: p, onDone: u, propsInput: c, inputLabel: S, inputType: j, inputPlaceHolder: k, options: d = q, autoFocusSel: v = ".autoFocus", cancelOption: g, defaultOption: m = d?.[0], ...C } = O, [b, V] = e.useState(!1), [t, B] = e.useState(F), [D, M] = e.useState(""), [P, z] = e.useState(!0), s = o(async (a, n) => {
if (!p) return !0;
const h = await p?.(a, n);
M(h?.message ?? "");
const x = h?.valid ?? !0;
return z(x), x;
}, [p]), f = o(async (a) => {
r?.(t, a);
}, [t, r, u, I, g, m]), H = o(async (a) => {
a.keyCode === N.Enter && await s?.(t, null);
}, [t, f]), K = o((a) => {
B(a.target.value), s?.(a.target.value, null);
}, [l]), L = o(async (a) => {
let n = await s(t, a);
try {
n !== !1 && (n = await s(t, a));
} catch {
}
return n ?? !0;
}, [t, l]);
return i.jsx($, { options: d, onDone: u, onOption: (a, n) => {
n || f(a);
}, onValidateOption: L, cancelOption: g, defaultOption: m, autoFocusSel: v, ref: T, ...C, children: i.jsx(A, { sx: { paddingTop: (a) => a.spacing(1), paddingBottom: (a) => a.spacing(0) }, children: i.jsx(E, { sx: { paddingTop: (a) => a.spacing(1.5), minWidth: 135, width: "100%" }, size: "small", children: i.jsx(R, { onFocus: (a) => {
b || a.target?.select(), V(!0);
}, type: j, label: S, helperText: D || " ", sx: { width: "100%", "& .MuiFormHelperText-root": { marginTop: (a) => a.spacing(0.5), color: P ? void 0 : "error.main" } }, slotProps: { inputLabel: { shrink: !0 }, htmlInput: { placeholder: k, spellCheck: !1, autoComplete: "off", ...c, className: W("autoFocus", c?.className), sx: { paddingTop: (a) => a.spacing(1.25), paddingBottom: (a) => a.spacing(0.75), backgroundImage: `linear-gradient(${y("#fff", w(5))}, ${y("#fff", w(5))})` } } }, value: t, onChange: K, onKeyDown: H, onContextMenu: (a) => {
a.stopPropagation();
} }) }) }) });
}));
export {
J as default
};