UNPKG

@sheetxl/studio-vanilla

Version:

SheetXL Studio - Vanilla entry point for integrating SheetXL UI.

7 lines (6 loc) 3.38 kB
"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"),F=["Autofit","Ok","Cancel"],j=e.reactExports.memo(y=>{const{initialValue:E,context:s,onOption:m,onValidateOption:r,onInput:g,onDone:l,options:h=F,defaultOption:a=h?.[1],cancelOption:p="Cancel",sx:O,...v}=y,C=e.reactExports.useMemo(()=>s?.().getOrientation()===e.w.Orientation.Column,[s]),[o,f]=e.reactExports.useState(E),[R,b]=e.reactExports.useState(!1),u=e.reactExports.useCallback(async(t,n)=>!0,[]),x=e.reactExports.useMemo(()=>{if(!s().toUnits)return null;let t=o?.size??0,n="Px";return o.unit==="Px"?(t=s().toUnits?.(t),n=s().getUnitText()):(t=s().toPixels?.(t),n="Px"),{size:t,unit:n}},[o?.unit,o?.size]),c=e.k(async t=>{const n=t===p;n||g?.(o,t),m?.(t,n,t===a),l?.()},[o,g,l,m,p,a]),k=e.k(async t=>{t.keyCode===e.Ko.Enter&&await u?.(o,null)!==!1&&c(a)},[o,c]),z=e.k(async t=>{let n=await Promise.resolve(r?.(t));try{n!==!1&&(n=await Promise.resolve(u?.(o,t))??!0)}catch{}return n??!0},[r]),w=e.k(t=>{const n={...o,size:Number(t.target.value)};f(n),u?.(n,null)},[o,r]),P=e.k(t=>{const n=t.target.value,i={...o,unit:n};f(i)},[o]),T=e.reactExports.useMemo(()=>{const t=s().getUnitText(),n=d=>e.jsxRuntimeExports.jsx(e.MenuItem,{value:d,children:d},d),i=[];return i.push(n("Px")),i.push(n(t)),i},[]);return e.jsxRuntimeExports.jsx(e.Or,{title:"Resize "+(C?"Columns":"Rows"),options:h,onDone:l,onOption:t=>c(t),onValidateOption:z,defaultOption:a,cancelOption:p,autoFocusSel:".autoFocus",sx:{width:"380px",...O},...v,children:e.jsxRuntimeExports.jsxs(e.Box,{sx:{paddingTop:t=>t.spacing(0),paddingBottom:t=>t.spacing(1),display:"flex",flexDirection:"column"},children:[e.jsxRuntimeExports.jsxs(e.Box,{sx:{rowGap:t=>t.spacing(1),display:"flex",flexDirection:"row",gap:t=>t.spacing(.5),alignItems:"end",justifyContent:"center"},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,{label:"Size",onFocus:t=>{R||t.target?.select(),b(!0)},sx:{"& .MuiFormHelperText-root":{marginTop:t=>t.spacing(.5)}},slotProps:{inputLabel:{shrink:!0},htmlInput:{className:"autoFocus",spellCheck:!1,autoComplete:"off",type:"number",inputMode:"numeric",pattern:"[0-9]*",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.size,onChange:w,onKeyDown:k,onContextMenu:t=>{t.stopPropagation()}})}),e.jsxRuntimeExports.jsxs(e.FormControl,{sx:{minWidth:85},size:"small",children:[e.jsxRuntimeExports.jsx(e.InputLabel,{children:"Unit"}),e.jsxRuntimeExports.jsx(e.Select,{value:o.unit,label:"Unit",onChange:P,sx:{backgroundImage:`linear-gradient(${e.alpha("#fff",e.getOverlayAlpha(5))}, ${e.alpha("#fff",e.getOverlayAlpha(5))})`},children:T})]})]}),x&&e.jsxRuntimeExports.jsx(e.Box,{children:e.jsxRuntimeExports.jsxs(e.Typography,{variant:"body2",component:"div",sx:{paddingLeft:t=>t.spacing(2)},children:[x.size," ",x.unit]})})]})})});exports.ResizeHeaderDialog=j,exports.default=j;