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