UNPKG

@sheetxl/studio-vanilla

Version:

SheetXL Studio - Vanilla entry point for integrating SheetXL UI.

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