UNPKG

@sheetxl/studio-vanilla

Version:

SheetXL Studio - Vanilla entry point for integrating SheetXL UI.

42 lines (41 loc) 2.5 kB
import { a as i } from "./DrQ2E12IEJK6WHfw.js"; import { r as n } from "./BTLmGxC1eZDXb9cY.js"; import { Y as e, K as $, Z as z, B as A, a1 as E, v as R, x as y, ap as W, A as w } from "./elB9a338Kjeh3S89.js"; /** * @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 Y = ["Input"], J = n.memo(n.forwardRef((O, T) => { const { initialValue: v = "", onOption: F, onValidateOption: l, onInput: r, onValidateInput: p, onDone: u, propsInput: c, inputLabel: I, inputType: S, inputPlaceHolder: C, options: d = Y, autoFocusSel: b = ".autoFocus", cancelOption: m, defaultOption: g = d?.[0], ...j } = O, [k, V] = n.useState(!1), [a, B] = n.useState(v), [D, P] = n.useState(""), [H, K] = n.useState(!0), s = e(async (t, o) => { if (!p) return !0; const h = await p?.(t, o); P(h?.message ?? ""); const x = h?.valid ?? !0; return K(x), x; }, [p]), f = e(async (t) => { r?.(a, t); }, [a, r, u, F, m, g]), L = e(async (t) => { t.keyCode === $.Enter && await s?.(a, null); }, [a, f]), M = e((t) => { B(t.target.value), s?.(t.target.value, null); }, [l]), N = e(async (t) => { let o = await s(a, t); try { o !== !1 && (o = await s(a, t)); } catch { } return o ?? !0; }, [a, l]); return i.jsx(z, { options: d, onDone: u, onOption: (t, o) => { o || f(t); }, onValidateOption: N, cancelOption: m, defaultOption: g, autoFocusSel: b, ref: T, ...j, children: i.jsx(A, { sx: { paddingTop: (t) => t.spacing(1), paddingBottom: (t) => t.spacing(0) }, children: i.jsx(E, { sx: { paddingTop: (t) => t.spacing(1.5), minWidth: 135, width: "100%" }, size: "small", children: i.jsx(R, { onFocus: (t) => { k || t.target?.select(), V(!0); }, type: S, label: I, helperText: D || " ", sx: { width: "100%", "& .MuiFormHelperText-root": { marginTop: (t) => t.spacing(0.5), color: H ? void 0 : "error.main" } }, slotProps: { inputLabel: { shrink: !0 }, htmlInput: { placeholder: C, 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(${y("#fff", w(5))}, ${y("#fff", w(5))})` } } }, value: a, onChange: M, onKeyDown: L, onContextMenu: (t) => { t.stopPropagation(); } }) }) }) }); })); export { J as default };