@sheetxl/studio-vanilla
Version:
SheetXL Studio - Vanilla entry point for integrating SheetXL UI.
7 lines (6 loc) • 2.21 kB
JavaScript
"use strict";/**
* @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.
*/Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Bc1oKNEzl3Kcj4g5.cjs"),D=["Input"],M=e.reactExports.memo(e.reactExports.forwardRef((h,f)=>{const{initialValue:y="",onOption:O,onValidateOption:s,onInput:i,onValidateInput:r,onDone:p,propsInput:l,inputLabel:E,inputType:j,inputPlaceHolder:k,options:u=D,autoFocusSel:T=".autoFocus",cancelOption:c,defaultOption:d=u?.[0],...v}=h,[w,F]=e.reactExports.useState(!1),[o,S]=e.reactExports.useState(y),[b,C]=e.reactExports.useState(""),[I,R]=e.reactExports.useState(!0),n=e.k(async(t,a)=>{if(!r)return!0;const g=await r?.(t,a);C(g?.message??"");const m=g?.valid??!0;return R(m),m},[r]),x=e.k(async t=>{i?.(o,t)},[o,i,p,O,c,d]),P=e.k(async t=>{t.keyCode===e.Ko.Enter&&await n?.(o,null)},[o,x]),V=e.k(t=>{S(t.target.value),n?.(t.target.value,null)},[s]),B=e.k(async t=>{let a=await n(o,t);try{a!==!1&&(a=await n(o,t))}catch{}return a??!0},[o,s]);return e.jsxRuntimeExports.jsx(e.Or,{options:u,onDone:p,onOption:(t,a)=>{a||x(t)},onValidateOption:B,cancelOption:c,defaultOption:d,autoFocusSel:T,ref:f,...v,children:e.jsxRuntimeExports.jsx(e.Box,{sx:{paddingTop:t=>t.spacing(1),paddingBottom:t=>t.spacing(0)},children:e.jsxRuntimeExports.jsx(e.FormControl,{sx:{paddingTop:t=>t.spacing(1.5),minWidth:135,width:"100%"},size:"small",children:e.jsxRuntimeExports.jsx(e.TextField,{onFocus:t=>{w||t.target?.select(),F(!0)},type:j,label:E,helperText:b||" ",sx:{width:"100%","& .MuiFormHelperText-root":{marginTop:t=>t.spacing(.5),color:I?void 0:"error.main"}},slotProps:{inputLabel:{shrink:!0},htmlInput:{placeholder:k,spellCheck:!1,autoComplete:"off",...l,className:e.Oe("autoFocus",l?.className),sx:{paddingTop:t=>t.spacing(1.25),paddingBottom:t=>t.spacing(.75),backgroundImage:`linear-gradient(${e.alpha("#fff",e.getOverlayAlpha(5))}, ${e.alpha("#fff",e.getOverlayAlpha(5))})`}}},value:o,onChange:V,onKeyDown:P,onContextMenu:t=>{t.stopPropagation()}})})})})}));exports.default=M;