@sheetxl/studio-vanilla
Version:
SheetXL Studio - Vanilla entry point for integrating SheetXL UI.
8 lines (7 loc) • 2.33 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"),S=["Ok","Cancel"],h=e.reactExports.memo(O=>{const{initialValue:C=null,onInput:x,context:E,onOption:m,onValidateOption:r,onDone:p,options:d=S,defaultOption:c=d?.[0],cancelOption:u="Cancel",sx:y,...j}=O,g=e.reactExports.useMemo(()=>{const t=C??E?.()?.getComments();let n="";if(t&&t.content&&t.content.runs){const s=t.content.runs;for(let a=0;a<s.length;a++){const l=s[a];n+=l?.text}}return n},[]),[o,k]=e.reactExports.useState(g),[v,F]=e.reactExports.useState(!1),f=e.reactExports.useCallback(async(t,n)=>null,[]),T=e.k(async t=>{const n=o===""?[]:o.split(`
`),s=t===u;if(!s){const a=n.length,l=new Array(a);for(let i=0;i<a;i++)l[i]={text:n[i]};x?.({content:{runs:l}})}m?.(t,s,t===c),p?.()},[o,x,p,m,c,u]),b=e.k(t=>{k(t.target.value),f(t.target.value,null)},[r]),w=e.k(async t=>{let n=await Promise.resolve(r?.(t));try{n!==!1&&(n=await f(o,t))}catch{}return n??!0},[r,o]);return e.jsxRuntimeExports.jsx(e.Or,{title:(g?"Edit":"Insert")+" Comments",options:d,onDone:p,onOption:t=>T(t),onValidateOption:w,defaultOption:c,cancelOption:u,autoFocusSel:".autoFocus",sx:{width:"480px",...y},...j,children:e.jsxRuntimeExports.jsx(e.Box,{sx:{paddingTop:t=>t.spacing(1),paddingBottom:t=>t.spacing(0),rowGap:t=>t.spacing(1),display:"flex",flexDirection:"column"},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:"Comments",placeholder:"Enter a comment.",onFocus:t=>{v||t.target?.select(),F(!0)},sx:{"& .MuiFormHelperText-root":{marginTop:t=>t.spacing(.5)}},slotProps:{inputLabel:{shrink:!0},htmlInput:{className:"autoFocus",spellCheck:!1,autoComplete:"off",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:b,onContextMenu:t=>{t.stopPropagation()}})})})})});exports.CommentsDialog=h,exports.default=h;