@sheetxl/studio-vanilla
Version:
SheetXL Studio - Vanilla entry point for integrating SheetXL UI.
7 lines (6 loc) • 3.19 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"),w=["Ok","Cancel"],y=e.reactExports.memo(T=>{const{initialValue:o=null,context:s,onInput:x,onOption:g,onValidateOption:r,onDone:i,options:m=w,defaultOption:p=m?.[0],cancelOption:u="Cancel",sx:k,...E}=T,O=e.reactExports.useMemo(()=>(o??s?.()?.getHyperlink())!==null,[]),c=e.reactExports.useMemo(()=>{let t=null,a=null;o&&(typeof o=="string"?a=o:t=o);const l=t??s?.()?.getHyperlink();return{address:a??l?.getAddress()??"",textToDisplay:l?.getDisplayText()??""}},[o,s]),[n,C]=e.reactExports.useState(c.address),[d,j]=e.reactExports.useState(()=>{const t=s?.().toTextUnformatted()??c.displayText;return t===c.address?"":t}),[b,h]=e.reactExports.useState(!1),v=e.reactExports.useCallback(t=>{j(t.target.value)},[]),f=e.reactExports.useCallback(async(t,a)=>null,[]),F=e.k(async t=>{const a=n===""?null:{address:n},l=t===u;l||x?.({address:a?.address??null,displayText:d??null}),g?.(t,l,t===p),i?.()},[n,d,s,x,i,g,p,u]),D=e.k(t=>{C(t.target.value),f(t.target.value,null)},[r]),M=e.k(async t=>{let a=await Promise.resolve(r?.(t));try{a!==!1&&(a=await f(n,t))}catch{}return a??!0},[r]);return e.jsxRuntimeExports.jsx(e.Or,{title:(O?"Edit":"Insert")+" Link",options:m,onDone:i,onOption:t=>F(t),onValidateOption:M,defaultOption:p,cancelOption:u,autoFocusSel:".autoFocus",sx:{width:"480px",...k},...E,children:e.jsxRuntimeExports.jsxs(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:"Address",placeholder:"Enter a url or cell reference.",onFocus:t=>{b||t.target?.select(),h(!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:n,onChange:D,onContextMenu:t=>{t.stopPropagation()}})}),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:"Display Text",placeholder:n?.startsWith("#")?n.substring(1):n,onFocus:()=>{h(!0)},sx:{"& .MuiFormHelperText-root":{marginTop:t=>t.spacing(.5)}},slotProps:{inputLabel:{shrink:!0},htmlInput:{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:d,onChange:v,onContextMenu:t=>{t.stopPropagation()}})})]})})});exports.HyperlinkDialog=y,exports.default=y;