UNPKG

@sheetxl/studio-vanilla

Version:

SheetXL Studio - Vanilla entry point for integrating SheetXL UI.

7 lines (6 loc) 2.23 kB
"use strict";/** * @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. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Bd-US8M4eZh5SC26.cjs"),D=["Input"],H=e.reactExports.memo(e.reactExports.forwardRef((f,h)=>{const{initialValue:T="",onOption:y,onValidateOption:p,onInputOption:r,onValidateInputOption:i,onDone:s,inputProps:l,inputLabel:O,inputType:E,inputPlaceHolder:j,options:u=D,autoFocusSel:S=".autoFocus",cancelOption:c,defaultOption:d=u?.[0],...v}=f,[w,F]=e.reactExports.useState(!1),[o,P]=e.reactExports.useState(T),[b,C]=e.reactExports.useState(""),[I,R]=e.reactExports.useState(!0),n=e.T(async(t,a)=>{if(!i)return!0;const g=await i?.(t,a);C(g?.message??"");const m=g?.valid??!0;return R(m),m},[i]),x=e.T(async t=>{r?.(o,t)},[o,r,s,y,c,d]),k=e.T(async t=>{t.keyCode===e.eo.Enter&&await n?.(o,null)},[o,x]),V=e.T(t=>{P(t.target.value),n?.(t.target.value,null)},[p]),B=e.T(async t=>{let a=await n(o,t);try{a!==!1&&(a=await n(o,t))}catch{}return a??!0},[o,p]);return e.jsxRuntimeExports.jsx(e.S3,{options:u,onDone:s,onOption:(t,a)=>{a||x(t)},onValidateOption:B,cancelOption:c,defaultOption:d,autoFocusSel:S,ref:h,...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:E,label:O,helperText:b||" ",sx:{width:"100%","& .MuiFormHelperText-root":{marginTop:t=>t.spacing(.5),color:I?void 0:"error.main"}},InputLabelProps:{shrink:!0},InputProps:{inputProps:{placeholder:j,spellCheck:!1,autoComplete:"off",...l,className:e.H0("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:k,onContextMenu:t=>{t.stopPropagation()}})})})})}));exports.default=H;