@sheetxl/studio-vanilla
Version:
SheetXL Studio - Vanilla entry point for integrating SheetXL UI.
8 lines (7 loc) • 2.34 kB
JavaScript
"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"),S=["Ok","Cancel"],g=e.reactExports.memo(f=>{const{initialComments:h=null,onUpdateComments:c,context:C,onOption:u,onValidateOption:i,onDone:r,options:m=S,defaultOption:p=m?.[0],cancelOption:l="Cancel",sx:O,...E}=f,x=e.reactExports.useMemo(()=>{const t=h??C?.()?.getComments();let n="";if(t&&t.content&&t.content.runs){const s=t.content.runs;for(let o=0;o<s.length;o++){const P=s[o];n+=P?.text}}return n},[]),[a,T]=e.reactExports.useState(x),[j,y]=e.reactExports.useState(!1),d=e.reactExports.useCallback(async(t,n)=>null,[]),v=e.T(async t=>{const n=a===""?[]:a.split(`
`);if(t!==l){const s=[];for(let o=0;o<n.length;o++)s.push({text:n[o]});c?.({content:{runs:s}})}u?.(t,t===l,t===p),r?.()},[a,c,r,u,p,l]),F=e.T(t=>{T(t.target.value),d(t.target.value,null)},[i]),b=e.T(async t=>{let n=await Promise.resolve(i?.(t));try{n!==!1&&(n=await d(a,t))}catch{}return n??!0},[i,a]);return e.jsxRuntimeExports.jsx(e.S3,{title:(x?"Edit":"Insert")+" Comments",options:m,onDone:r,onOption:t=>v(t),onValidateOption:b,defaultOption:p,cancelOption:l,autoFocusSel:".autoFocus",sx:{width:"480px",...O},...E,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=>{j||t.target?.select(),y(!0)},sx:{"& .MuiFormHelperText-root":{marginTop:t=>t.spacing(.5)}},InputLabelProps:{shrink:!0},InputProps:{inputProps:{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:a,onChange:F,onContextMenu:t=>{t.stopPropagation()}})})})})});exports.CommentsDialog=g,exports.default=g;