@univerjs/sheets-ui 0.5.5-nightly.202501231606 → 0.5.5-nightly.202501241606

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -40,7 +40,7 @@
40
40
  univer-flex univer-items-center univer-justify-center univer-px-1 univer-cursor-pointer
41
41
  univer-absolute univer-right-0 univer-h-full univer-transition-colors univer-duration-200
42
42
  hover:univer-bg-gray-100
43
- `,{"univer-text-gray-300 univer-cursor-not-allowed hover:univer-bg-transparent":disable}),children:jsxRuntime.jsx(MoreDownSingle,{})})}),jsxRuntime.jsx(design.DropdownOverlay,{className:"univer-z-[1001]",offset:{x:-75,y:2},children:jsxRuntime.jsx(DefinedNameOverlay,{})})]})]})}__name(DefinedName,"DefinedName");const formulaBox="univer-formula-box",nameRanges="univer-name-ranges",formulaBar="univer-formula-bar",formulaIcon="univer-formula-icon",formulaIconDisable="univer-formula-icon-disable",formulaIconWrapper="univer-formula-icon-wrapper",iconContainer="univer-icon-container",iconContainerSuccess="univer-icon-container-success",formulaActive="univer-formula-active",iconContainerError="univer-icon-container-error",iconContainerFx="univer-icon-container-fx",formulaInput="univer-formula-input",formulaContainer="univer-formula-container",sheetEmbeddingFormulaEditorWrap="univer-sheet-embedding-formula-editor-wrap",formulaContent="univer-formula-content",arrowContainer="univer-arrow-container",arrowContainerDisable="univer-arrow-container-disable",styles$f={formulaBox,nameRanges,formulaBar,formulaIcon,formulaIconDisable,formulaIconWrapper,iconContainer,iconContainerSuccess,formulaActive,iconContainerError,iconContainerFx,formulaInput,formulaContainer,sheetEmbeddingFormulaEditorWrap,formulaContent,arrowContainer,arrowContainerDisable};function FormulaBar(){var _a61;const[iconStyle,setIconStyle]=React.useState(styles$f.formulaGrey),[arrowDirection,setArrowDirection]=React.useState(0),formulaEditorManagerService=core.useDependency(IFormulaEditorManagerService),editorBridgeService=core.useDependency(IEditorBridgeService),worksheetProtectionRuleModel=core.useDependency(sheets.WorksheetProtectionRuleModel),rangeProtectionRuleModel=core.useDependency(sheets.RangeProtectionRuleModel),univerInstanceService=core.useDependency(core.IUniverInstanceService),selectionManager=core.useDependency(sheets.SheetsSelectionsService),permissionService=core.useDependency(core.IPermissionService),[disable,setDisable]=React.useState(!1),[imageDisable,setImageDisable]=React.useState(!1),currentWorkbook=useActiveWorkbook(),componentManager=core.useDependency(ui.ComponentManager),workbook=core.useObservable(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),isRefSelecting=React.useRef(0),editState=editorBridgeService.getEditLocation(),keyCodeConfig=useKeyEventConfig(isRefSelecting,(_a61=editState==null?void 0:editState.unitId)!=null?_a61:""),FormulaEditor=componentManager.get(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY),formulaAuxUIParts=ui.useComponentsOfPart(SheetsUIPart.FORMULA_AUX),contextService=core.useDependency(core.IContextService);core.useObservable(React.useMemo(()=>contextService.subscribeContextValue$(core.FOCUSING_FX_BAR_EDITOR),[contextService]));const isFocusFxBar=contextService.getContextValue(core.FOCUSING_FX_BAR_EDITOR),ref=React.useRef(null);function getPermissionIds(unitId,subUnitId){return[new sheets.WorkbookEditablePermission(unitId).id,new sheets.WorksheetSetCellValuePermission(unitId,subUnitId).id,new sheets.WorksheetEditPermission(unitId,subUnitId).id]}__name(getPermissionIds,"getPermissionIds"),React.useLayoutEffect(()=>{const subscription=workbook.activeSheet$.pipe(rxjs.switchMap(worksheet=>worksheet?rxjs.merge(worksheetProtectionRuleModel.ruleChange$,rangeProtectionRuleModel.ruleChange$,selectionManager.selectionMoveEnd$,selectionManager.selectionSet$).pipe(rxjs.switchMap(()=>{var _a62,_b;const unitId=workbook.getUnitId(),subUnitId=worksheet.getSheetId();if(!((_a62=selectionManager.getCurrentLastSelection())==null?void 0:_a62.range))return rxjs.EMPTY;const permissionIds=getPermissionIds(unitId,subUnitId),selectionRanges=(_b=selectionManager.getCurrentSelections())==null?void 0:_b.map(selection=>selection.range);return rangeProtectionRuleModel.getSubunitRuleList(unitId,subUnitId).filter(rule=>rule.ranges.some(r2=>selectionRanges==null?void 0:selectionRanges.some(selectionRange=>core.Rectangle.intersects(r2,selectionRange)))).forEach(p=>{permissionIds.push(new sheets.RangeProtectionPermissionEditPoint(unitId,subUnitId,p.permissionId).id)}),permissionService.composePermission$(permissionIds)})):rxjs.EMPTY)).subscribe(permissions=>{permissions&&setDisable(!permissions.every(p=>p.value))});return()=>{subscription.unsubscribe()}},[workbook]),React.useEffect(()=>{const subscription=editorBridgeService.visible$.subscribe(visibleInfo=>{setIconStyle(visibleInfo.visible?styles$f.formulaActive:styles$f.formulaGrey)});return()=>subscription.unsubscribe()},[editorBridgeService.visible$]),React.useEffect(()=>{const subscription=editorBridgeService.currentEditCellState$.subscribe(state=>{var _a62,_b,_c;(_c=(_b=(_a62=state==null?void 0:state.documentLayoutObject.documentModel)==null?void 0:_a62.getBody())==null?void 0:_b.customBlocks)!=null&&_c.length?setImageDisable(!0):setImageDisable(!1)});return()=>subscription.unsubscribe()},[editorBridgeService.currentEditCellState$]),React.useEffect(()=>{if(ref.current){const handleResize=__name(()=>{const editorRect=ref.current.getBoundingClientRect();formulaEditorManagerService.setPosition(editorRect)},"handleResize");handleResize();const a=new ResizeObserver(handleResize);return a.observe(ref.current),()=>a.disconnect()}},[formulaEditorManagerService]);function handleArrowClick(){setArrowDirection(arrowDirection===0?1:0),setTimeout(()=>{formulaEditorManagerService.handleFoldBtnClick(arrowDirection===1)},150)}__name(handleArrowClick,"handleArrowClick");function handleCloseBtnClick(){var _a62;editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.Keyboard,keycode:ui.KeyCode.ESC,unitId:(_a62=currentWorkbook==null?void 0:currentWorkbook.getUnitId())!=null?_a62:""})}__name(handleCloseBtnClick,"handleCloseBtnClick");function handleConfirmBtnClick(){var _a62;editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.PointerDown,unitId:(_a62=currentWorkbook==null?void 0:currentWorkbook.getUnitId())!=null?_a62:""})}__name(handleConfirmBtnClick,"handleConfirmBtnClick");function handlerFxBtnClick(){formulaEditorManagerService.handleFxBtnClick(!0)}__name(handlerFxBtnClick,"handlerFxBtnClick");const disabled=disable||imageDisable;return jsxRuntime.jsxs("div",{className:styles$f.formulaBox,style:{height:arrowDirection===0?"28px":"82px",pointerEvents:disable?"none":"auto"},children:[jsxRuntime.jsx("div",{className:styles$f.nameRanges,children:jsxRuntime.jsx(DefinedName,{disable})}),jsxRuntime.jsxs("div",{className:styles$f.formulaBar,children:[jsxRuntime.jsx("div",{className:clsx(styles$f.formulaIcon,{[styles$f.formulaIconDisable]:disabled}),children:jsxRuntime.jsxs("div",{className:styles$f.formulaIconWrapper,children:[jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerError,iconStyle),onClick:handleCloseBtnClick,children:jsxRuntime.jsx(CloseSingle,{})}),jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerSuccess,iconStyle),onClick:handleConfirmBtnClick,children:jsxRuntime.jsx(CheckMarkSingle,{})}),jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerFx),onClick:handlerFxBtnClick,children:jsxRuntime.jsx(FxSingle,{})})]})}),jsxRuntime.jsxs("div",{className:styles$f.formulaContainer,children:[jsxRuntime.jsx("div",{className:styles$f.formulaInput,ref,children:FormulaEditor&&jsxRuntime.jsx(FormulaEditor,{disableSelectionOnClick:!0,editorId:core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,initValue:"",onChange:__name(()=>{},"onChange"),isFocus:isFocusFxBar,className:styles$f.formulaContent,unitId:editState==null?void 0:editState.unitId,subUnitId:editState==null?void 0:editState.sheetId,isSupportAcrossSheet:!0,resetSelectionOnBlur:!1,isSingle:!1,keyboradEventConfig:keyCodeConfig,onFormulaSelectingChange:__name(isSelecting=>{isRefSelecting.current=isSelecting,isSelecting?editorBridgeService.enableForceKeepVisible():editorBridgeService.disableForceKeepVisible()},"onFormulaSelectingChange"),autoScrollbar:!1,disableContextMenu:!1})}),jsxRuntime.jsx("div",{className:clsx(styles$f.arrowContainer,{[styles$f.arrowContainerDisable]:disable}),onClick:handleArrowClick,children:arrowDirection===0?jsxRuntime.jsx(DropdownSingle,{}):jsxRuntime.jsx(DropdownSingle,{style:{transform:"rotateZ(180deg)"}})})]})]}),jsxRuntime.jsx(ui.ComponentContainer,{components:formulaAuxUIParts},"formula-aux")]})}__name(FormulaBar,"FormulaBar");const operateContainer="univer-operate-container",autoFillPopupMenu="univer-auto-fill-popup-menu",autoFillPopupMenuItem="univer-auto-fill-popup-menu-item",autoFillPopupMenuItemIcon="univer-auto-fill-popup-menu-item-icon",autoFillPopupMenuItemTitle="univer-auto-fill-popup-menu-item-title",autoFillPopupMenuItemHide="univer-auto-fill-popup-menu-item-hide",btnContainer="univer-btn-container",btnContainerExpand="univer-btn-container-expand",styles$e={operateContainer,autoFillPopupMenu,autoFillPopupMenuItem,autoFillPopupMenuItemIcon,autoFillPopupMenuItemTitle,autoFillPopupMenuItemHide,btnContainer,btnContainerExpand},useUpdate=__name(()=>{const[,setState]=React.useState({});return React.useCallback(()=>setState(prevState=>!prevState),[])},"useUpdate"),AutoFillPopupMenu=__name(()=>{const commandService=core.useDependency(core.ICommandService),univerInstanceService=core.useDependency(core.IUniverInstanceService),renderManagerService=core.useDependency(engineRender.IRenderManagerService),autoFillService=core.useDependency(IAutoFillService),localeService=core.useDependency(core.LocaleService),[menu,setMenu]=React.useState([]),[visible,setVisible]=React.useState(!1),[anchor,setAnchor]=React.useState({row:-1,col:-1}),[selected,setSelected]=React.useState(APPLY_TYPE.SERIES),[isHovered,setHovered]=React.useState(!1),workbook=useActiveWorkbook(),{sheetSkeletonManagerService,selectionRenderService}=React.useMemo(()=>{if(workbook){const ru=renderManagerService.getRenderById(workbook.getUnitId());return{sheetSkeletonManagerService:ru==null?void 0:ru.with(exports.SheetSkeletonManagerService),selectionRenderService:ru==null?void 0:ru.with(ISheetSelectionRenderService)}}return{sheetSkeletonManagerService:null,selectionRenderService:null}},[workbook,renderManagerService]),handleMouseEnter=__name(()=>{setHovered(!0)},"handleMouseEnter"),handleMouseLeave=__name(()=>{setHovered(!1)},"handleMouseLeave"),forceUpdate=useUpdate();if(React.useEffect(()=>commandService.onCommandExecuted((command,options)=>{command.id===SetScrollOperation.id&&forceUpdate()}).dispose,[forceUpdate,commandService]),React.useEffect(()=>{const disposable=sheetSkeletonManagerService&&core.toDisposable(sheetSkeletonManagerService.currentSkeleton$.subscribe(skeleton2=>{skeleton2&&forceUpdate()}));return disposable==null?void 0:disposable.dispose},[sheetSkeletonManagerService,forceUpdate]),React.useEffect(()=>core.toDisposable(autoFillService.menu$.subscribe(menu2=>{setMenu(menu2.map(i=>({...i,index:menu2.indexOf(i)})))})).dispose,[autoFillService]),React.useEffect(()=>core.toDisposable(autoFillService.showMenu$.subscribe(show=>{const{source,target}=autoFillService.autoFillLocation||{source:null,target:null};if(show&&source&&target){const lastRow=Math.max(source.rows[source.rows.length-1],target.rows[target.rows.length-1]),lastCol=Math.max(source.cols[source.cols.length-1],target.cols[target.cols.length-1]);setAnchor({row:lastRow,col:lastCol})}else setAnchor({row:-1,col:-1})})).dispose,[autoFillService]),React.useEffect(()=>core.toDisposable(autoFillService.applyType$.subscribe(type=>{setSelected(type)})).dispose,[autoFillService]),React.useEffect(()=>{function handleClose(){setVisible(!1)}return __name(handleClose,"handleClose"),document.addEventListener("wheel",handleClose),()=>{document.removeEventListener("wheel",handleClose)}},[visible]),anchor.col<0||anchor.row<0)return null;const sheetObject=getSheetObject(univerInstanceService,renderManagerService);if(!sheetObject||!selectionRenderService)return null;const{scene}=sheetObject,skeleton=sheetSkeletonManagerService==null?void 0:sheetSkeletonManagerService.getCurrentSkeleton(),viewport=selectionRenderService.getViewPort(),scaleX=scene==null?void 0:scene.scaleX,scaleY=scene==null?void 0:scene.scaleY,scrollXY=scene==null?void 0:scene.getViewportScrollXY(viewport);if(!scaleX||!scene||!scaleX||!scaleY||!scrollXY)return null;const x=(skeleton==null?void 0:skeleton.getNoMergeCellPositionByIndex(anchor.row,anchor.col).endX)||0,y=(skeleton==null?void 0:skeleton.getNoMergeCellPositionByIndex(anchor.row,anchor.col).endY)||0,relativeX=skeleton==null?void 0:skeleton.convertTransformToOffsetX(x,scaleX,scrollXY),relativeY=skeleton==null?void 0:skeleton.convertTransformToOffsetY(y,scaleY,scrollXY);if(relativeX==null||relativeY==null)return null;const onVisibleChange=__name(visible2=>{setVisible(visible2)},"onVisibleChange"),handleClick=__name(item=>{commandService.executeCommand(RefillCommand.id,{type:item.value}),setVisible(!1)},"handleClick"),showMore=visible||isHovered,availableMenu=menu.filter(item=>!item.disable);return jsxRuntime.jsx("div",{onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,style:{left:`${relativeX+2}px`,top:`${relativeY+2}px`,position:"absolute"},children:jsxRuntime.jsx(design.DropdownLegacy,{placement:"bottomLeft",trigger:["click"],overlay:jsxRuntime.jsx("ul",{className:styles$e.autoFillPopupMenu,children:availableMenu.map(item=>jsxRuntime.jsxs("li",{onClick:__name(()=>handleClick(item),"onClick"),className:styles$e.autoFillPopupMenuItem,children:[jsxRuntime.jsx("span",{className:styles$e.autoFillPopupMenuItemIcon,children:item.value===selected&&jsxRuntime.jsx(CheckMarkSingle,{style:{color:"rgb(var(--green-700, #409f11))"}})}),jsxRuntime.jsx("span",{className:styles$e.autoFillPopupMenuItemTitle,children:localeService.t(item.label)})]},item.index))}),visible,onVisibleChange,children:jsxRuntime.jsxs("div",{className:clsx(styles$e.btnContainer,{[styles$e.btnContainerExpand]:visible}),children:[jsxRuntime.jsx(Autofill,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),showMore&&jsxRuntime.jsx(MoreDownSingle,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},"AutoFillPopupMenu"),OperateContainer=__name(()=>jsxRuntime.jsx("div",{className:styles$e.operateContainer,children:jsxRuntime.jsx(AutoFillPopupMenu,{})}),"OperateContainer"),sheetBar="univer-sheet-bar",sheetBarOptions="univer-sheet-bar-options",sheetBarOptionsDivider="univer-sheet-bar-options-divider",styles$d={sheetBar,sheetBarOptions,sheetBarOptionsDivider},sheetBarBtn="univer-sheet-bar-btn",styles$c={sheetBarBtn};function SheetBarButton(props){const{children,className,style,disabled=!1,onClick,...restProps}=props,handleClick=__name(e=>{if(disabled){e.preventDefault();return}onClick&&onClick(e)},"handleClick");return jsxRuntime.jsx("button",{className:styles$c.sheetBarBtn,style,disabled,onClick:handleClick,...restProps,children})}__name(SheetBarButton,"SheetBarButton");const sheetFooterBarHeight="36",sheetContainer="univer-sheet-container",sheetBarMenu="univer-sheet-bar-menu",sheetBarMenuItem="univer-sheet-bar-menu-item",sheetBarMenuItemIcon="univer-sheet-bar-menu-item-icon",sheetBarMenuItemHide="univer-sheet-bar-menu-item-hide",sheetBarMenuItemSelect="univer-sheet-bar-menu-item-select",sheetBarMenuItemLabel="univer-sheet-bar-menu-item-label",styles$b={sheetFooterBarHeight,sheetContainer,sheetBarMenu,sheetBarMenuItem,sheetBarMenuItemIcon,sheetBarMenuItemHide,sheetBarMenuItemSelect,sheetBarMenuItemLabel};function SheetBarMenu(props){const{style}=props,[menu,setMenu]=React.useState([]),[visible,setVisible]=React.useState(!1),univerInstanceService=core.useDependency(core.IUniverInstanceService),commandService=core.useDependency(core.ICommandService),sheetBarService=core.useDependency(ISheetBarService),worksheetProtectionRuleModel=core.useDependency(sheets.WorksheetProtectionRuleModel),workbook=ui.useObservable(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET),null,!1,[]),handleClick=__name(item=>{const{sheetId}=item;!sheetId||!workbook||(item.hidden?commandService.executeCommand(sheets.SetWorksheetShowCommand.id,{unitId:workbook.getUnitId(),subUnitId:sheetId,value:sheetId}):item.selected||commandService.executeCommand(sheets.SetWorksheetActivateCommand.id,{unitId:workbook.getUnitId(),subUnitId:sheetId}),setVisible(!1))},"handleClick"),statusInit=React.useCallback(()=>{if(!workbook)return;const sheets2=workbook.getSheets(),activeSheet=workbook.getActiveSheet(),worksheetMenuItems=sheets2.map((sheet,index)=>({label:sheet.getName(),index:`${index}`,sheetId:sheet.getSheetId(),hidden:sheet.isSheetHidden()===core.BooleanNumber.TRUE,selected:activeSheet===sheet}));setMenu(worksheetMenuItems)},[workbook,worksheetProtectionRuleModel]),setupStatusUpdate=React.useCallback(()=>commandService.onCommandExecuted(commandInfo=>{switch(commandInfo.id){case sheets.SetWorksheetHideMutation.id:case sheets.RemoveSheetMutation.id:case sheets.SetWorksheetNameMutation.id:case sheets.InsertSheetMutation.id:case sheets.SetWorksheetOrderMutation.id:case sheets.SetWorksheetActiveOperation.id:statusInit();break}}),[commandService,statusInit]);function handleSheetBarMenu(){setVisible(!0)}__name(handleSheetBarMenu,"handleSheetBarMenu");const onVisibleChange=__name(visible2=>{setVisible(visible2)},"onVisibleChange");return React.useEffect(()=>{statusInit();const disposables=new core.DisposableCollection;return disposables.add(setupStatusUpdate()),disposables.add(sheetBarService.registerSheetBarMenuHandler({handleSheetBarMenu})),()=>disposables.dispose()},[setupStatusUpdate,sheetBarService,statusInit,workbook]),jsxRuntime.jsx(design.DropdownLegacy,{placement:"topLeft",trigger:["click"],overlay:jsxRuntime.jsx("ul",{className:styles$b.sheetBarMenu,style:{...style},children:menu.map(item=>jsxRuntime.jsxs("li",{onClick:__name(()=>handleClick(item),"onClick"),className:item.selected?`
43
+ `,{"univer-text-gray-300 univer-cursor-not-allowed hover:univer-bg-transparent":disable}),children:jsxRuntime.jsx(MoreDownSingle,{})})}),jsxRuntime.jsx(design.DropdownOverlay,{className:"univer-z-[1001]",offset:{x:-75,y:2},children:jsxRuntime.jsx(DefinedNameOverlay,{})})]})]})}__name(DefinedName,"DefinedName");const formulaBox="univer-formula-box",nameRanges="univer-name-ranges",formulaBar="univer-formula-bar",formulaIcon="univer-formula-icon",formulaIconDisable="univer-formula-icon-disable",formulaIconWrapper="univer-formula-icon-wrapper",iconContainer="univer-icon-container",iconContainerSuccess="univer-icon-container-success",formulaActive="univer-formula-active",iconContainerError="univer-icon-container-error",iconContainerFx="univer-icon-container-fx",formulaInput="univer-formula-input",formulaContainer="univer-formula-container",sheetEmbeddingFormulaEditorWrap="univer-sheet-embedding-formula-editor-wrap",formulaContent="univer-formula-content",arrowContainer="univer-arrow-container",arrowContainerDisable="univer-arrow-container-disable",styles$f={formulaBox,nameRanges,formulaBar,formulaIcon,formulaIconDisable,formulaIconWrapper,iconContainer,iconContainerSuccess,formulaActive,iconContainerError,iconContainerFx,formulaInput,formulaContainer,sheetEmbeddingFormulaEditorWrap,formulaContent,arrowContainer,arrowContainerDisable};function FormulaBar(){var _a61;const[iconStyle,setIconStyle]=React.useState(styles$f.formulaGrey),[arrowDirection,setArrowDirection]=React.useState(0),formulaEditorManagerService=core.useDependency(IFormulaEditorManagerService),editorBridgeService=core.useDependency(IEditorBridgeService),worksheetProtectionRuleModel=core.useDependency(sheets.WorksheetProtectionRuleModel),rangeProtectionRuleModel=core.useDependency(sheets.RangeProtectionRuleModel),univerInstanceService=core.useDependency(core.IUniverInstanceService),selectionManager=core.useDependency(sheets.SheetsSelectionsService),permissionService=core.useDependency(core.IPermissionService),rangeProtectionCache=core.useDependency(sheets.RangeProtectionCache),[disableInfo,setDisableInfo]=React.useState({editDisable:!1,viewDisable:!1}),[imageDisable,setImageDisable]=React.useState(!1),currentWorkbook=useActiveWorkbook(),componentManager=core.useDependency(ui.ComponentManager),workbook=core.useObservable(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),isRefSelecting=React.useRef(0),editState=editorBridgeService.getEditLocation(),keyCodeConfig=useKeyEventConfig(isRefSelecting,(_a61=editState==null?void 0:editState.unitId)!=null?_a61:""),FormulaEditor=componentManager.get(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY),formulaAuxUIParts=ui.useComponentsOfPart(SheetsUIPart.FORMULA_AUX),contextService=core.useDependency(core.IContextService);core.useObservable(React.useMemo(()=>contextService.subscribeContextValue$(core.FOCUSING_FX_BAR_EDITOR),[contextService]));const isFocusFxBar=contextService.getContextValue(core.FOCUSING_FX_BAR_EDITOR),ref=React.useRef(null);React.useLayoutEffect(()=>{const subscription=workbook.activeSheet$.pipe(rxjs.switchMap(worksheet=>worksheet?rxjs.merge(worksheetProtectionRuleModel.ruleChange$,rangeProtectionRuleModel.ruleChange$,selectionManager.selectionMoveEnd$,selectionManager.selectionSet$).pipe(rxjs.switchMap(()=>{var _a62,_b;const unitId=workbook.getUnitId(),subUnitId=worksheet.getSheetId();if(!((_a62=selectionManager.getCurrentLastSelection())==null?void 0:_a62.range))return rxjs.EMPTY;const primary=(_b=selectionManager.getCurrentLastSelection())==null?void 0:_b.primary;return primary?rxjs.of({unitId,subUnitId,primary}):rxjs.of(null)})):rxjs.EMPTY)).subscribe(cellInfo=>{var _a62,_b,_c,_d,_e,_f;if(cellInfo){const{unitId,subUnitId,primary}=cellInfo;if(worksheetProtectionRuleModel.getRule(unitId,subUnitId)){const editDisable2=!((_b=(_a62=permissionService.getPermissionPoint(new sheets.WorksheetEditPermission(unitId,subUnitId).id))==null?void 0:_a62.value)==null||_b),viewDisable2=!((_d=(_c=permissionService.getPermissionPoint(new sheets.WorksheetViewPermission(unitId,subUnitId).id))==null?void 0:_c.value)==null||_d);setDisableInfo({viewDisable:viewDisable2,editDisable:editDisable2});return}const{actualRow,actualColumn}=primary,cellInfoWithPermission=rangeProtectionCache.getCellInfo(unitId,subUnitId,actualRow,actualColumn);setDisableInfo({editDisable:!((_e=cellInfoWithPermission==null?void 0:cellInfoWithPermission[sheets.UnitAction.Edit])==null||_e),viewDisable:!((_f=cellInfoWithPermission==null?void 0:cellInfoWithPermission[sheets.UnitAction.View])==null||_f)})}else setDisableInfo({viewDisable:!1,editDisable:!1})});return()=>{subscription.unsubscribe()}},[workbook]),React.useEffect(()=>{const subscription=editorBridgeService.visible$.subscribe(visibleInfo=>{setIconStyle(visibleInfo.visible?styles$f.formulaActive:styles$f.formulaGrey)});return()=>subscription.unsubscribe()},[editorBridgeService.visible$]),React.useEffect(()=>{const subscription=editorBridgeService.currentEditCellState$.subscribe(state=>{var _a62,_b,_c;(_c=(_b=(_a62=state==null?void 0:state.documentLayoutObject.documentModel)==null?void 0:_a62.getBody())==null?void 0:_b.customBlocks)!=null&&_c.length?setImageDisable(!0):setImageDisable(!1)});return()=>subscription.unsubscribe()},[editorBridgeService.currentEditCellState$]),React.useEffect(()=>{if(ref.current){const handleResize=__name(()=>{const editorRect=ref.current.getBoundingClientRect();formulaEditorManagerService.setPosition(editorRect)},"handleResize");handleResize();const a=new ResizeObserver(handleResize);return a.observe(ref.current),()=>a.disconnect()}},[formulaEditorManagerService]);function handleArrowClick(){setArrowDirection(arrowDirection===0?1:0),setTimeout(()=>{formulaEditorManagerService.handleFoldBtnClick(arrowDirection===1)},150)}__name(handleArrowClick,"handleArrowClick");function handleCloseBtnClick(){var _a62;editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.Keyboard,keycode:ui.KeyCode.ESC,unitId:(_a62=currentWorkbook==null?void 0:currentWorkbook.getUnitId())!=null?_a62:""})}__name(handleCloseBtnClick,"handleCloseBtnClick");function handleConfirmBtnClick(){var _a62;editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.PointerDown,unitId:(_a62=currentWorkbook==null?void 0:currentWorkbook.getUnitId())!=null?_a62:""})}__name(handleConfirmBtnClick,"handleConfirmBtnClick");function handlerFxBtnClick(){formulaEditorManagerService.handleFxBtnClick(!0)}__name(handlerFxBtnClick,"handlerFxBtnClick");const{viewDisable,editDisable}=disableInfo,disabled=editDisable||imageDisable;return jsxRuntime.jsxs("div",{className:styles$f.formulaBox,style:{height:arrowDirection===0?"28px":"82px",pointerEvents:editDisable?"none":"auto"},children:[jsxRuntime.jsx("div",{className:styles$f.nameRanges,children:jsxRuntime.jsx(DefinedName,{disable:editDisable})}),jsxRuntime.jsxs("div",{className:styles$f.formulaBar,children:[jsxRuntime.jsx("div",{className:clsx(styles$f.formulaIcon,{[styles$f.formulaIconDisable]:disabled}),children:jsxRuntime.jsxs("div",{className:styles$f.formulaIconWrapper,children:[jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerError,iconStyle),onClick:handleCloseBtnClick,children:jsxRuntime.jsx(CloseSingle,{})}),jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerSuccess,iconStyle),onClick:handleConfirmBtnClick,children:jsxRuntime.jsx(CheckMarkSingle,{})}),jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerFx),onClick:handlerFxBtnClick,children:jsxRuntime.jsx(FxSingle,{})})]})}),jsxRuntime.jsxs("div",{className:styles$f.formulaContainer,children:[jsxRuntime.jsx("div",{className:styles$f.formulaInput,ref,children:FormulaEditor&&jsxRuntime.jsx(FormulaEditor,{disableSelectionOnClick:!0,editorId:core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,initValue:"",onChange:__name(()=>{},"onChange"),isFocus:isFocusFxBar,className:styles$f.formulaContent,unitId:editState==null?void 0:editState.unitId,subUnitId:editState==null?void 0:editState.sheetId,isSupportAcrossSheet:!0,resetSelectionOnBlur:!1,isSingle:!1,keyboradEventConfig:keyCodeConfig,onFormulaSelectingChange:__name(isSelecting=>{isRefSelecting.current=isSelecting,isSelecting?editorBridgeService.enableForceKeepVisible():editorBridgeService.disableForceKeepVisible()},"onFormulaSelectingChange"),autoScrollbar:!1,disableContextMenu:!1})}),jsxRuntime.jsx("div",{className:clsx(styles$f.arrowContainer,{[styles$f.arrowContainerDisable]:editDisable}),onClick:handleArrowClick,children:arrowDirection===0?jsxRuntime.jsx(DropdownSingle,{}):jsxRuntime.jsx(DropdownSingle,{style:{transform:"rotateZ(180deg)"}})})]})]}),jsxRuntime.jsx(ui.ComponentContainer,{components:formulaAuxUIParts},"formula-aux")]})}__name(FormulaBar,"FormulaBar");const operateContainer="univer-operate-container",autoFillPopupMenu="univer-auto-fill-popup-menu",autoFillPopupMenuItem="univer-auto-fill-popup-menu-item",autoFillPopupMenuItemIcon="univer-auto-fill-popup-menu-item-icon",autoFillPopupMenuItemTitle="univer-auto-fill-popup-menu-item-title",autoFillPopupMenuItemHide="univer-auto-fill-popup-menu-item-hide",btnContainer="univer-btn-container",btnContainerExpand="univer-btn-container-expand",styles$e={operateContainer,autoFillPopupMenu,autoFillPopupMenuItem,autoFillPopupMenuItemIcon,autoFillPopupMenuItemTitle,autoFillPopupMenuItemHide,btnContainer,btnContainerExpand},useUpdate=__name(()=>{const[,setState]=React.useState({});return React.useCallback(()=>setState(prevState=>!prevState),[])},"useUpdate"),AutoFillPopupMenu=__name(()=>{const commandService=core.useDependency(core.ICommandService),univerInstanceService=core.useDependency(core.IUniverInstanceService),renderManagerService=core.useDependency(engineRender.IRenderManagerService),autoFillService=core.useDependency(IAutoFillService),localeService=core.useDependency(core.LocaleService),[menu,setMenu]=React.useState([]),[visible,setVisible]=React.useState(!1),[anchor,setAnchor]=React.useState({row:-1,col:-1}),[selected,setSelected]=React.useState(APPLY_TYPE.SERIES),[isHovered,setHovered]=React.useState(!1),workbook=useActiveWorkbook(),{sheetSkeletonManagerService,selectionRenderService}=React.useMemo(()=>{if(workbook){const ru=renderManagerService.getRenderById(workbook.getUnitId());return{sheetSkeletonManagerService:ru==null?void 0:ru.with(exports.SheetSkeletonManagerService),selectionRenderService:ru==null?void 0:ru.with(ISheetSelectionRenderService)}}return{sheetSkeletonManagerService:null,selectionRenderService:null}},[workbook,renderManagerService]),handleMouseEnter=__name(()=>{setHovered(!0)},"handleMouseEnter"),handleMouseLeave=__name(()=>{setHovered(!1)},"handleMouseLeave"),forceUpdate=useUpdate();if(React.useEffect(()=>commandService.onCommandExecuted((command,options)=>{command.id===SetScrollOperation.id&&forceUpdate()}).dispose,[forceUpdate,commandService]),React.useEffect(()=>{const disposable=sheetSkeletonManagerService&&core.toDisposable(sheetSkeletonManagerService.currentSkeleton$.subscribe(skeleton2=>{skeleton2&&forceUpdate()}));return disposable==null?void 0:disposable.dispose},[sheetSkeletonManagerService,forceUpdate]),React.useEffect(()=>core.toDisposable(autoFillService.menu$.subscribe(menu2=>{setMenu(menu2.map(i=>({...i,index:menu2.indexOf(i)})))})).dispose,[autoFillService]),React.useEffect(()=>core.toDisposable(autoFillService.showMenu$.subscribe(show=>{const{source,target}=autoFillService.autoFillLocation||{source:null,target:null};if(show&&source&&target){const lastRow=Math.max(source.rows[source.rows.length-1],target.rows[target.rows.length-1]),lastCol=Math.max(source.cols[source.cols.length-1],target.cols[target.cols.length-1]);setAnchor({row:lastRow,col:lastCol})}else setAnchor({row:-1,col:-1})})).dispose,[autoFillService]),React.useEffect(()=>core.toDisposable(autoFillService.applyType$.subscribe(type=>{setSelected(type)})).dispose,[autoFillService]),React.useEffect(()=>{function handleClose(){setVisible(!1)}return __name(handleClose,"handleClose"),document.addEventListener("wheel",handleClose),()=>{document.removeEventListener("wheel",handleClose)}},[visible]),anchor.col<0||anchor.row<0)return null;const sheetObject=getSheetObject(univerInstanceService,renderManagerService);if(!sheetObject||!selectionRenderService)return null;const{scene}=sheetObject,skeleton=sheetSkeletonManagerService==null?void 0:sheetSkeletonManagerService.getCurrentSkeleton(),viewport=selectionRenderService.getViewPort(),scaleX=scene==null?void 0:scene.scaleX,scaleY=scene==null?void 0:scene.scaleY,scrollXY=scene==null?void 0:scene.getViewportScrollXY(viewport);if(!scaleX||!scene||!scaleX||!scaleY||!scrollXY)return null;const x=(skeleton==null?void 0:skeleton.getNoMergeCellPositionByIndex(anchor.row,anchor.col).endX)||0,y=(skeleton==null?void 0:skeleton.getNoMergeCellPositionByIndex(anchor.row,anchor.col).endY)||0,relativeX=skeleton==null?void 0:skeleton.convertTransformToOffsetX(x,scaleX,scrollXY),relativeY=skeleton==null?void 0:skeleton.convertTransformToOffsetY(y,scaleY,scrollXY);if(relativeX==null||relativeY==null)return null;const onVisibleChange=__name(visible2=>{setVisible(visible2)},"onVisibleChange"),handleClick=__name(item=>{commandService.executeCommand(RefillCommand.id,{type:item.value}),setVisible(!1)},"handleClick"),showMore=visible||isHovered,availableMenu=menu.filter(item=>!item.disable);return jsxRuntime.jsx("div",{onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,style:{left:`${relativeX+2}px`,top:`${relativeY+2}px`,position:"absolute"},children:jsxRuntime.jsx(design.DropdownLegacy,{placement:"bottomLeft",trigger:["click"],overlay:jsxRuntime.jsx("ul",{className:styles$e.autoFillPopupMenu,children:availableMenu.map(item=>jsxRuntime.jsxs("li",{onClick:__name(()=>handleClick(item),"onClick"),className:styles$e.autoFillPopupMenuItem,children:[jsxRuntime.jsx("span",{className:styles$e.autoFillPopupMenuItemIcon,children:item.value===selected&&jsxRuntime.jsx(CheckMarkSingle,{style:{color:"rgb(var(--green-700, #409f11))"}})}),jsxRuntime.jsx("span",{className:styles$e.autoFillPopupMenuItemTitle,children:localeService.t(item.label)})]},item.index))}),visible,onVisibleChange,children:jsxRuntime.jsxs("div",{className:clsx(styles$e.btnContainer,{[styles$e.btnContainerExpand]:visible}),children:[jsxRuntime.jsx(Autofill,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),showMore&&jsxRuntime.jsx(MoreDownSingle,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},"AutoFillPopupMenu"),OperateContainer=__name(()=>jsxRuntime.jsx("div",{className:styles$e.operateContainer,children:jsxRuntime.jsx(AutoFillPopupMenu,{})}),"OperateContainer"),sheetBar="univer-sheet-bar",sheetBarOptions="univer-sheet-bar-options",sheetBarOptionsDivider="univer-sheet-bar-options-divider",styles$d={sheetBar,sheetBarOptions,sheetBarOptionsDivider},sheetBarBtn="univer-sheet-bar-btn",styles$c={sheetBarBtn};function SheetBarButton(props){const{children,className,style,disabled=!1,onClick,...restProps}=props,handleClick=__name(e=>{if(disabled){e.preventDefault();return}onClick&&onClick(e)},"handleClick");return jsxRuntime.jsx("button",{className:styles$c.sheetBarBtn,style,disabled,onClick:handleClick,...restProps,children})}__name(SheetBarButton,"SheetBarButton");const sheetFooterBarHeight="36",sheetContainer="univer-sheet-container",sheetBarMenu="univer-sheet-bar-menu",sheetBarMenuItem="univer-sheet-bar-menu-item",sheetBarMenuItemIcon="univer-sheet-bar-menu-item-icon",sheetBarMenuItemHide="univer-sheet-bar-menu-item-hide",sheetBarMenuItemSelect="univer-sheet-bar-menu-item-select",sheetBarMenuItemLabel="univer-sheet-bar-menu-item-label",styles$b={sheetFooterBarHeight,sheetContainer,sheetBarMenu,sheetBarMenuItem,sheetBarMenuItemIcon,sheetBarMenuItemHide,sheetBarMenuItemSelect,sheetBarMenuItemLabel};function SheetBarMenu(props){const{style}=props,[menu,setMenu]=React.useState([]),[visible,setVisible]=React.useState(!1),univerInstanceService=core.useDependency(core.IUniverInstanceService),commandService=core.useDependency(core.ICommandService),sheetBarService=core.useDependency(ISheetBarService),worksheetProtectionRuleModel=core.useDependency(sheets.WorksheetProtectionRuleModel),workbook=ui.useObservable(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET),null,!1,[]),handleClick=__name(item=>{const{sheetId}=item;!sheetId||!workbook||(item.hidden?commandService.executeCommand(sheets.SetWorksheetShowCommand.id,{unitId:workbook.getUnitId(),subUnitId:sheetId,value:sheetId}):item.selected||commandService.executeCommand(sheets.SetWorksheetActivateCommand.id,{unitId:workbook.getUnitId(),subUnitId:sheetId}),setVisible(!1))},"handleClick"),statusInit=React.useCallback(()=>{if(!workbook)return;const sheets2=workbook.getSheets(),activeSheet=workbook.getActiveSheet(),worksheetMenuItems=sheets2.map((sheet,index)=>({label:sheet.getName(),index:`${index}`,sheetId:sheet.getSheetId(),hidden:sheet.isSheetHidden()===core.BooleanNumber.TRUE,selected:activeSheet===sheet}));setMenu(worksheetMenuItems)},[workbook,worksheetProtectionRuleModel]),setupStatusUpdate=React.useCallback(()=>commandService.onCommandExecuted(commandInfo=>{switch(commandInfo.id){case sheets.SetWorksheetHideMutation.id:case sheets.RemoveSheetMutation.id:case sheets.SetWorksheetNameMutation.id:case sheets.InsertSheetMutation.id:case sheets.SetWorksheetOrderMutation.id:case sheets.SetWorksheetActiveOperation.id:statusInit();break}}),[commandService,statusInit]);function handleSheetBarMenu(){setVisible(!0)}__name(handleSheetBarMenu,"handleSheetBarMenu");const onVisibleChange=__name(visible2=>{setVisible(visible2)},"onVisibleChange");return React.useEffect(()=>{statusInit();const disposables=new core.DisposableCollection;return disposables.add(setupStatusUpdate()),disposables.add(sheetBarService.registerSheetBarMenuHandler({handleSheetBarMenu})),()=>disposables.dispose()},[setupStatusUpdate,sheetBarService,statusInit,workbook]),jsxRuntime.jsx(design.DropdownLegacy,{placement:"topLeft",trigger:["click"],overlay:jsxRuntime.jsx("ul",{className:styles$b.sheetBarMenu,style:{...style},children:menu.map(item=>jsxRuntime.jsxs("li",{onClick:__name(()=>handleClick(item),"onClick"),className:item.selected?`
44
44
  ${styles$b.sheetBarMenuItem}
45
45
  ${styles$b.sheetBarMenuItemSelect}
46
46
  `:item.hidden?`
package/lib/es/index.js CHANGED
@@ -8,7 +8,7 @@ import { IRenderManagerService, SHEET_VIEWPORT_KEY, CURSOR_TYPE, Vector2, Rect,
8
8
  import { useObservable, KeyCode, ILayoutService, MetaKeys, DEFAULT_BACKGROUND_COLOR_RGB, DEFAULT_BACKGROUND_COLOR_RGBA, handleStringToStyle, textTrim, PLAIN_TEXT_CLIPBOARD_MIME_TYPE, HTML_CLIPBOARD_MIME_TYPE, imageMimeTypeSet, IClipboardInterfaceService, INotificationService, IPlatformService, FILE_PNG_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FILE__BMP_CLIPBOARD_MIME_TYPE, CopyCommand, CutCommand, PasteCommand, SheetPasteShortKeyCommandName, IConfirmService, IContextMenuService, MenuItemType, getMenuHiddenObservable, FONT_FAMILY_LIST, FONT_SIZE_LIST, ISidebarService, IDialogService, ComponentManager, useSidebarClick, DISABLE_AUTO_FOCUS_KEY, useEvent, useComponentsOfPart, ComponentContainer, UI_PLUGIN_CONFIG_KEY, UIMenu, ContextMenuPosition, IMessageService, IMenuManagerService, ToolbarItem, RibbonStartGroup, ContextMenuGroup, FontFamily, FontFamilyItem, FontSize, BuiltInUIPart, IShortcutService, IUIPartsService, ICanvasPopupService, IZenZoneService, UniverMobileUIPlugin } from "@univerjs/ui";
9
9
  import React, { useMemo, useState, useEffect, forwardRef, useRef, createElement, useCallback, useLayoutEffect } from "react";
10
10
  import { BehaviorSubject, Subject, of, merge, map, startWith, switchMap, takeUntil, distinctUntilChanged, throttleTime, filter, combineLatest, debounceTime, Observable, combineLatestWith, Subscription, withLatestFrom, EMPTY } from "rxjs";
11
- import { SELECTION_CONTROL_BORDER_BUFFER_WIDTH, SELECTION_CONTROL_BORDER_BUFFER_COLOR, SELECTIONS_ENABLED, REF_SELECTIONS_ENABLED, SheetsSelectionsService, SheetInterceptorService, SetWorksheetRowAutoHeightMutationFactory, SetWorksheetRowAutoHeightMutation, SetRangeValuesCommand, SetWorksheetRowIsAutoHeightCommand, SetStyleCommand, MoveRangeCommand, ReorderRangeCommand, SetSelectionsOperation, SetRangeValuesMutation, getSheetCommandTarget, generateNullCellValue, SetRangeValuesUndoMutationFactory, BEFORE_CELL_EDIT, IRefSelectionsService, SetWorksheetActiveOperation, MoveRangeMutation, RemoveRowMutation, RemoveColMutation, InsertRowMutation, InsertColMutation, MoveRowsMutation, MoveColsMutation, SetWorksheetColWidthMutation, SetWorksheetRowHeightMutation, RemoveSheetMutation, RemoveMergeUndoMutationFactory, RemoveWorksheetMergeMutation, AddWorksheetMergeMutation, getAddMergeMutationRangeByType, AddMergeUndoMutationFactory, WorkbookEditablePermission, WorksheetEditPermission, UnitAction, alignToMergedCellsBorders, getSelectionsService, getCellAtRowCol, SelectionMoveType, expandToContinuousRange, ScrollToCellOperation, COMMAND_LISTENER_SKELETON_CHANGE, SetWorksheetActivateCommand, getPrimaryForRange, SetRowHiddenCommand, SetColHiddenCommand, SetBoldCommand, SetItalicCommand, SetUnderlineCommand, SetStrikeThroughCommand, SetFontSizeCommand, SetFontFamilyCommand, SetTextColorCommand, SetFrozenMutationFactory, SetFrozenMutation, IExclusiveRangeService, RangeProtectionRuleModel, WorksheetProtectionRuleModel, RangeProtectionPermissionEditPoint, WorksheetCopyPermission, WorksheetSetCellStylePermission, ResetBackgroundColorCommand, SetBackgroundColorCommand, SetHorizontalTextAlignCommand, SetVerticalTextAlignCommand, SetTextWrapCommand, SetTextRotationCommand, WorkbookCopyPermission, RangeProtectionPermissionViewPoint, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, CancelFrozenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSelectedRowsVisibleCommand, SetColHiddenMutation, SetColVisibleMutation, SetSelectedColsVisibleCommand, SetRowHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetColWidthCommand, SetFrozenCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowCommand, InsertColCommand, MoveColsCommand, MoveRowsCommand, RemoveColCommand, RemoveRowCommand, MergeCellController, MERGE_CELL_INTERCEPTOR_CHECK, DeltaRowHeightCommand, DeltaColumnWidthCommand, COMMAND_LISTENER_VALUE_CHANGE, AddMergeRedoSelectionsOperationFactory, AddMergeUndoSelectionsOperationFactory, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, UnitObject, ViewStateEnum, EditStateEnum, DeleteWorksheetProtectionCommand, DeleteRangeProtectionMutation, AddRangeProtectionMutation, RemoveSheetCommand, AddWorksheetProtectionCommand, BorderStyleManagerService, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, InsertDefinedNameCommand, SetDefinedNameCommand, RemoveDefinedNameCommand, SetWorksheetShowCommand, SetWorksheetOrderMutation, InsertSheetMutation, SetWorksheetNameMutation, SetWorksheetHideMutation, SetWorksheetNameCommand, SetWorksheetOrderCommand, WorkbookManageCollaboratorPermission, WorkbookRenameSheetPermission, SetTabColorMutation, WorkbookCreateSheetPermission, InsertSheetCommand, SetBorderBasicCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, ClearSelectionAllCommand, WorksheetDeleteColumnPermission, WorksheetDeleteRowPermission, ToggleGridlinesCommand, ToggleGridlinesMutation, WorksheetInsertColumnPermission, WorksheetInsertRowPermission, InsertRowBeforeCommand, InsertRowAfterCommand, InsertColBeforeCommand, InsertColAfterCommand, RemoveWorksheetMergeCommand, WorksheetManageCollaboratorPermission, RangeProtectionCache, WorkbookCreateProtectPermission, WorksheetDeleteProtectionPermission, CopySheetCommand, SetTabColorCommand, SetWorksheetHideCommand, WorkbookDeleteSheetPermission, WorkbookHideSheetPermission, ResetTextColorCommand, AddWorksheetMergeCommand as AddWorksheetMergeCommand$1, AddWorksheetMergeAllCommand as AddWorksheetMergeAllCommand$1, AddWorksheetMergeVerticalCommand as AddWorksheetMergeVerticalCommand$1, AddWorksheetMergeHorizontalCommand as AddWorksheetMergeHorizontalCommand$1, RefRangeService, MAX_CELL_PER_SHEET_KEY, INTERCEPTOR_POINT, SheetPermissionCheckController, INumfmtService, WorksheetViewPermission, SetProtectionCommand, AddRangeProtectionCommand, setEndForRange, baseProtectionActions, DeleteRangeProtectionCommand, WorksheetProtectionPointModel, SetWorksheetPermissionPointsCommand, getAllWorksheetPermissionPoint, convertSelectionDataToRange, UniverSheetsPlugin, RefSelectionsService, ToggleCellCheckboxCommand, SetSpecificRowsVisibleCommand, SetSpecificColsVisibleCommand } from "@univerjs/sheets";
11
+ import { SELECTION_CONTROL_BORDER_BUFFER_WIDTH, SELECTION_CONTROL_BORDER_BUFFER_COLOR, SELECTIONS_ENABLED, REF_SELECTIONS_ENABLED, SheetsSelectionsService, SheetInterceptorService, SetWorksheetRowAutoHeightMutationFactory, SetWorksheetRowAutoHeightMutation, SetRangeValuesCommand, SetWorksheetRowIsAutoHeightCommand, SetStyleCommand, MoveRangeCommand, ReorderRangeCommand, SetSelectionsOperation, SetRangeValuesMutation, getSheetCommandTarget, generateNullCellValue, SetRangeValuesUndoMutationFactory, BEFORE_CELL_EDIT, IRefSelectionsService, SetWorksheetActiveOperation, MoveRangeMutation, RemoveRowMutation, RemoveColMutation, InsertRowMutation, InsertColMutation, MoveRowsMutation, MoveColsMutation, SetWorksheetColWidthMutation, SetWorksheetRowHeightMutation, RemoveSheetMutation, RemoveMergeUndoMutationFactory, RemoveWorksheetMergeMutation, AddWorksheetMergeMutation, getAddMergeMutationRangeByType, AddMergeUndoMutationFactory, WorkbookEditablePermission, WorksheetEditPermission, UnitAction, alignToMergedCellsBorders, getSelectionsService, getCellAtRowCol, SelectionMoveType, expandToContinuousRange, ScrollToCellOperation, COMMAND_LISTENER_SKELETON_CHANGE, SetWorksheetActivateCommand, getPrimaryForRange, SetRowHiddenCommand, SetColHiddenCommand, SetBoldCommand, SetItalicCommand, SetUnderlineCommand, SetStrikeThroughCommand, SetFontSizeCommand, SetFontFamilyCommand, SetTextColorCommand, SetFrozenMutationFactory, SetFrozenMutation, IExclusiveRangeService, RangeProtectionRuleModel, WorksheetProtectionRuleModel, RangeProtectionPermissionEditPoint, WorksheetCopyPermission, WorksheetSetCellStylePermission, ResetBackgroundColorCommand, SetBackgroundColorCommand, SetHorizontalTextAlignCommand, SetVerticalTextAlignCommand, SetTextWrapCommand, SetTextRotationCommand, WorkbookCopyPermission, RangeProtectionPermissionViewPoint, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, CancelFrozenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSelectedRowsVisibleCommand, SetColHiddenMutation, SetColVisibleMutation, SetSelectedColsVisibleCommand, SetRowHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetColWidthCommand, SetFrozenCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowCommand, InsertColCommand, MoveColsCommand, MoveRowsCommand, RemoveColCommand, RemoveRowCommand, MergeCellController, MERGE_CELL_INTERCEPTOR_CHECK, DeltaRowHeightCommand, DeltaColumnWidthCommand, COMMAND_LISTENER_VALUE_CHANGE, AddMergeRedoSelectionsOperationFactory, AddMergeUndoSelectionsOperationFactory, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, UnitObject, ViewStateEnum, EditStateEnum, DeleteWorksheetProtectionCommand, DeleteRangeProtectionMutation, AddRangeProtectionMutation, RemoveSheetCommand, AddWorksheetProtectionCommand, BorderStyleManagerService, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, InsertDefinedNameCommand, SetDefinedNameCommand, RemoveDefinedNameCommand, SetWorksheetShowCommand, RangeProtectionCache, WorksheetViewPermission, SetWorksheetOrderMutation, InsertSheetMutation, SetWorksheetNameMutation, SetWorksheetHideMutation, SetWorksheetNameCommand, SetWorksheetOrderCommand, WorkbookManageCollaboratorPermission, WorkbookRenameSheetPermission, SetTabColorMutation, WorkbookCreateSheetPermission, InsertSheetCommand, SetBorderBasicCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, ClearSelectionAllCommand, WorksheetDeleteColumnPermission, WorksheetDeleteRowPermission, ToggleGridlinesCommand, ToggleGridlinesMutation, WorksheetInsertColumnPermission, WorksheetInsertRowPermission, InsertRowBeforeCommand, InsertRowAfterCommand, InsertColBeforeCommand, InsertColAfterCommand, RemoveWorksheetMergeCommand, WorksheetManageCollaboratorPermission, WorkbookCreateProtectPermission, WorksheetDeleteProtectionPermission, CopySheetCommand, SetTabColorCommand, SetWorksheetHideCommand, WorkbookDeleteSheetPermission, WorkbookHideSheetPermission, ResetTextColorCommand, AddWorksheetMergeCommand as AddWorksheetMergeCommand$1, AddWorksheetMergeAllCommand as AddWorksheetMergeAllCommand$1, AddWorksheetMergeVerticalCommand as AddWorksheetMergeVerticalCommand$1, AddWorksheetMergeHorizontalCommand as AddWorksheetMergeHorizontalCommand$1, RefRangeService, MAX_CELL_PER_SHEET_KEY, INTERCEPTOR_POINT, SheetPermissionCheckController, INumfmtService, SetProtectionCommand, AddRangeProtectionCommand, setEndForRange, baseProtectionActions, DeleteRangeProtectionCommand, WorksheetProtectionPointModel, SetWorksheetPermissionPointsCommand, getAllWorksheetPermissionPoint, convertSelectionDataToRange, UniverSheetsPlugin, RefSelectionsService, ToggleCellCheckboxCommand, SetSpecificRowsVisibleCommand, SetSpecificColsVisibleCommand } from "@univerjs/sheets";
12
12
  import { DocSkeletonManagerService, DocSelectionManagerService, RichTextEditingMutation, SetTextSelectionsOperation } from "@univerjs/docs";
13
13
  import { sequenceNodeType, matchToken, LexerTreeBuilder, IFunctionService, SetFormulaCalculationNotificationMutation, IDefinedNamesService, operatorToken, isReferenceStrings, isReferenceStringWithEffectiveColumn, serializeRangeWithSheet, FUNCTION_NAMES_STATISTICAL, FUNCTION_NAMES_MATH, FUNCTION_NAMES_TEXT, NullValueObject, serializeRange, deserializeRangeWithSheet } from "@univerjs/engine-formula";
14
14
  import { DEFAULT_TEXT_FORMAT } from "@univerjs/engine-numfmt";
@@ -13476,17 +13476,13 @@ function FormulaBar() {
13476
13476
  const [iconStyle, setIconStyle] = useState(styles$f.formulaGrey), [arrowDirection, setArrowDirection] = useState(
13477
13477
  0
13478
13478
  /* Down */
13479
- ), formulaEditorManagerService = useDependency(IFormulaEditorManagerService), editorBridgeService = useDependency(IEditorBridgeService), worksheetProtectionRuleModel = useDependency(WorksheetProtectionRuleModel), rangeProtectionRuleModel = useDependency(RangeProtectionRuleModel), univerInstanceService = useDependency(IUniverInstanceService), selectionManager = useDependency(SheetsSelectionsService), permissionService = useDependency(IPermissionService), [disable, setDisable] = useState(!1), [imageDisable, setImageDisable] = useState(!1), currentWorkbook = useActiveWorkbook(), componentManager = useDependency(ComponentManager), workbook = useObservable$1(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), void 0, void 0, []), isRefSelecting = useRef(0), editState = editorBridgeService.getEditLocation(), keyCodeConfig = useKeyEventConfig(isRefSelecting, (_a61 = editState == null ? void 0 : editState.unitId) != null ? _a61 : ""), FormulaEditor = componentManager.get(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY), formulaAuxUIParts = useComponentsOfPart(SheetsUIPart.FORMULA_AUX), contextService = useDependency(IContextService);
13479
+ ), formulaEditorManagerService = useDependency(IFormulaEditorManagerService), editorBridgeService = useDependency(IEditorBridgeService), worksheetProtectionRuleModel = useDependency(WorksheetProtectionRuleModel), rangeProtectionRuleModel = useDependency(RangeProtectionRuleModel), univerInstanceService = useDependency(IUniverInstanceService), selectionManager = useDependency(SheetsSelectionsService), permissionService = useDependency(IPermissionService), rangeProtectionCache = useDependency(RangeProtectionCache), [disableInfo, setDisableInfo] = useState({
13480
+ editDisable: !1,
13481
+ viewDisable: !1
13482
+ }), [imageDisable, setImageDisable] = useState(!1), currentWorkbook = useActiveWorkbook(), componentManager = useDependency(ComponentManager), workbook = useObservable$1(() => univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET), void 0, void 0, []), isRefSelecting = useRef(0), editState = editorBridgeService.getEditLocation(), keyCodeConfig = useKeyEventConfig(isRefSelecting, (_a61 = editState == null ? void 0 : editState.unitId) != null ? _a61 : ""), FormulaEditor = componentManager.get(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY), formulaAuxUIParts = useComponentsOfPart(SheetsUIPart.FORMULA_AUX), contextService = useDependency(IContextService);
13480
13483
  useObservable$1(useMemo(() => contextService.subscribeContextValue$(FOCUSING_FX_BAR_EDITOR), [contextService]));
13481
13484
  const isFocusFxBar = contextService.getContextValue(FOCUSING_FX_BAR_EDITOR), ref = useRef(null);
13482
- function getPermissionIds(unitId, subUnitId) {
13483
- return [
13484
- new WorkbookEditablePermission(unitId).id,
13485
- new WorksheetSetCellValuePermission(unitId, subUnitId).id,
13486
- new WorksheetEditPermission(unitId, subUnitId).id
13487
- ];
13488
- }
13489
- __name(getPermissionIds, "getPermissionIds"), useLayoutEffect(() => {
13485
+ useLayoutEffect(() => {
13490
13486
  const subscription = workbook.activeSheet$.pipe(
13491
13487
  switchMap((worksheet) => worksheet ? merge(
13492
13488
  worksheetProtectionRuleModel.ruleChange$,
@@ -13498,14 +13494,36 @@ function FormulaBar() {
13498
13494
  var _a62, _b;
13499
13495
  const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId();
13500
13496
  if (!((_a62 = selectionManager.getCurrentLastSelection()) == null ? void 0 : _a62.range)) return EMPTY;
13501
- const permissionIds = getPermissionIds(unitId, subUnitId), selectionRanges = (_b = selectionManager.getCurrentSelections()) == null ? void 0 : _b.map((selection) => selection.range);
13502
- return rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).filter((rule) => rule.ranges.some((r2) => selectionRanges == null ? void 0 : selectionRanges.some((selectionRange) => Rectangle.intersects(r2, selectionRange)))).forEach((p) => {
13503
- permissionIds.push(new RangeProtectionPermissionEditPoint(unitId, subUnitId, p.permissionId).id);
13504
- }), permissionService.composePermission$(permissionIds);
13497
+ const primary = (_b = selectionManager.getCurrentLastSelection()) == null ? void 0 : _b.primary;
13498
+ return primary ? of({
13499
+ unitId,
13500
+ subUnitId,
13501
+ primary
13502
+ }) : of(null);
13505
13503
  })
13506
13504
  ) : EMPTY)
13507
- ).subscribe((permissions) => {
13508
- permissions && setDisable(!permissions.every((p) => p.value));
13505
+ ).subscribe((cellInfo) => {
13506
+ var _a62, _b, _c, _d, _e, _f;
13507
+ if (cellInfo) {
13508
+ const { unitId, subUnitId, primary } = cellInfo;
13509
+ if (worksheetProtectionRuleModel.getRule(unitId, subUnitId)) {
13510
+ const editDisable2 = !((_b = (_a62 = permissionService.getPermissionPoint(new WorksheetEditPermission(unitId, subUnitId).id)) == null ? void 0 : _a62.value) == null || _b), viewDisable2 = !((_d = (_c = permissionService.getPermissionPoint(new WorksheetViewPermission(unitId, subUnitId).id)) == null ? void 0 : _c.value) == null || _d);
13511
+ setDisableInfo({
13512
+ viewDisable: viewDisable2,
13513
+ editDisable: editDisable2
13514
+ });
13515
+ return;
13516
+ }
13517
+ const { actualRow, actualColumn } = primary, cellInfoWithPermission = rangeProtectionCache.getCellInfo(unitId, subUnitId, actualRow, actualColumn);
13518
+ setDisableInfo({
13519
+ editDisable: !((_e = cellInfoWithPermission == null ? void 0 : cellInfoWithPermission[UnitAction.Edit]) == null || _e),
13520
+ viewDisable: !((_f = cellInfoWithPermission == null ? void 0 : cellInfoWithPermission[UnitAction.View]) == null || _f)
13521
+ });
13522
+ } else
13523
+ setDisableInfo({
13524
+ viewDisable: !1,
13525
+ editDisable: !1
13526
+ });
13509
13527
  });
13510
13528
  return () => {
13511
13529
  subscription.unsubscribe();
@@ -13567,17 +13585,17 @@ function FormulaBar() {
13567
13585
  formulaEditorManagerService.handleFxBtnClick(!0);
13568
13586
  }
13569
13587
  __name(handlerFxBtnClick, "handlerFxBtnClick");
13570
- const disabled = disable || imageDisable;
13588
+ const { viewDisable, editDisable } = disableInfo, disabled = editDisable || imageDisable;
13571
13589
  return /* @__PURE__ */ jsxs(
13572
13590
  "div",
13573
13591
  {
13574
13592
  className: styles$f.formulaBox,
13575
13593
  style: {
13576
13594
  height: arrowDirection === 0 ? "28px" : "82px",
13577
- pointerEvents: disable ? "none" : "auto"
13595
+ pointerEvents: editDisable ? "none" : "auto"
13578
13596
  },
13579
13597
  children: [
13580
- /* @__PURE__ */ jsx("div", { className: styles$f.nameRanges, children: /* @__PURE__ */ jsx(DefinedName, { disable }) }),
13598
+ /* @__PURE__ */ jsx("div", { className: styles$f.nameRanges, children: /* @__PURE__ */ jsx(DefinedName, { disable: editDisable }) }),
13581
13599
  /* @__PURE__ */ jsxs("div", { className: styles$f.formulaBar, children: [
13582
13600
  /* @__PURE__ */ jsx("div", { className: clsx(styles$f.formulaIcon, { [styles$f.formulaIconDisable]: disabled }), children: /* @__PURE__ */ jsxs("div", { className: styles$f.formulaIconWrapper, children: [
13583
13601
  /* @__PURE__ */ jsx(
@@ -13622,7 +13640,7 @@ function FormulaBar() {
13622
13640
  disableContextMenu: !1
13623
13641
  }
13624
13642
  ) }),
13625
- /* @__PURE__ */ jsx("div", { className: clsx(styles$f.arrowContainer, { [styles$f.arrowContainerDisable]: disable }), onClick: handleArrowClick, children: arrowDirection === 0 ? /* @__PURE__ */ jsx(DropdownSingle, {}) : /* @__PURE__ */ jsx(DropdownSingle, { style: { transform: "rotateZ(180deg)" } }) })
13643
+ /* @__PURE__ */ jsx("div", { className: clsx(styles$f.arrowContainer, { [styles$f.arrowContainerDisable]: editDisable }), onClick: handleArrowClick, children: arrowDirection === 0 ? /* @__PURE__ */ jsx(DropdownSingle, {}) : /* @__PURE__ */ jsx(DropdownSingle, { style: { transform: "rotateZ(180deg)" } }) })
13626
13644
  ] })
13627
13645
  ] }),
13628
13646
  /* @__PURE__ */ jsx(ComponentContainer, { components: formulaAuxUIParts }, "formula-aux")
@@ -618,6 +618,9 @@ export interface ISheetSkeletonChangedEvent extends ISheetUIEventBase {
618
618
  payload: CommandListenerSkeletonChange;
619
619
  effectedRanges: FRange[];
620
620
  }
621
+ /**
622
+ * @ignore
623
+ */
621
624
  export interface IFSheetsUIEventParamConfig {
622
625
  BeforeClipboardChange: IBeforeClipboardChangeParam;
623
626
  ClipboardChanged: IClipboardChangedParam;
package/lib/umd/index.js CHANGED
@@ -40,7 +40,7 @@
40
40
  univer-flex univer-items-center univer-justify-center univer-px-1 univer-cursor-pointer
41
41
  univer-absolute univer-right-0 univer-h-full univer-transition-colors univer-duration-200
42
42
  hover:univer-bg-gray-100
43
- `,{"univer-text-gray-300 univer-cursor-not-allowed hover:univer-bg-transparent":disable}),children:jsxRuntime.jsx(MoreDownSingle,{})})}),jsxRuntime.jsx(design.DropdownOverlay,{className:"univer-z-[1001]",offset:{x:-75,y:2},children:jsxRuntime.jsx(DefinedNameOverlay,{})})]})]})}__name(DefinedName,"DefinedName");const styles$f={formulaBox:"univer-formula-box",nameRanges:"univer-name-ranges",formulaBar:"univer-formula-bar",formulaIcon:"univer-formula-icon",formulaIconDisable:"univer-formula-icon-disable",formulaIconWrapper:"univer-formula-icon-wrapper",iconContainer:"univer-icon-container",iconContainerSuccess:"univer-icon-container-success",formulaActive:"univer-formula-active",iconContainerError:"univer-icon-container-error",iconContainerFx:"univer-icon-container-fx",formulaInput:"univer-formula-input",formulaContainer:"univer-formula-container",sheetEmbeddingFormulaEditorWrap:"univer-sheet-embedding-formula-editor-wrap",formulaContent:"univer-formula-content",arrowContainer:"univer-arrow-container",arrowContainerDisable:"univer-arrow-container-disable"};function FormulaBar(){var _a2;const[iconStyle,setIconStyle]=React.useState(styles$f.formulaGrey),[arrowDirection,setArrowDirection]=React.useState(0),formulaEditorManagerService=core.useDependency(IFormulaEditorManagerService),editorBridgeService=core.useDependency(IEditorBridgeService),worksheetProtectionRuleModel=core.useDependency(sheets.WorksheetProtectionRuleModel),rangeProtectionRuleModel=core.useDependency(sheets.RangeProtectionRuleModel),univerInstanceService=core.useDependency(core.IUniverInstanceService),selectionManager=core.useDependency(sheets.SheetsSelectionsService),permissionService=core.useDependency(core.IPermissionService),[disable,setDisable]=React.useState(!1),[imageDisable,setImageDisable]=React.useState(!1),currentWorkbook=useActiveWorkbook(),componentManager=core.useDependency(ui.ComponentManager),workbook=core.useObservable(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),isRefSelecting=React.useRef(0),editState=editorBridgeService.getEditLocation(),keyCodeConfig=useKeyEventConfig(isRefSelecting,(_a2=editState==null?void 0:editState.unitId)!=null?_a2:""),FormulaEditor=componentManager.get(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY),formulaAuxUIParts=ui.useComponentsOfPart(SheetsUIPart.FORMULA_AUX),contextService=core.useDependency(core.IContextService);core.useObservable(React.useMemo(()=>contextService.subscribeContextValue$(core.FOCUSING_FX_BAR_EDITOR),[contextService]));const isFocusFxBar=contextService.getContextValue(core.FOCUSING_FX_BAR_EDITOR),ref=React.useRef(null);function getPermissionIds(unitId,subUnitId){return[new sheets.WorkbookEditablePermission(unitId).id,new sheets.WorksheetSetCellValuePermission(unitId,subUnitId).id,new sheets.WorksheetEditPermission(unitId,subUnitId).id]}__name(getPermissionIds,"getPermissionIds"),React.useLayoutEffect(()=>{const subscription=workbook.activeSheet$.pipe(rxjs.switchMap(worksheet=>worksheet?rxjs.merge(worksheetProtectionRuleModel.ruleChange$,rangeProtectionRuleModel.ruleChange$,selectionManager.selectionMoveEnd$,selectionManager.selectionSet$).pipe(rxjs.switchMap(()=>{var _a3,_b2;const unitId=workbook.getUnitId(),subUnitId=worksheet.getSheetId();if(!((_a3=selectionManager.getCurrentLastSelection())==null?void 0:_a3.range))return rxjs.EMPTY;const permissionIds=getPermissionIds(unitId,subUnitId),selectionRanges=(_b2=selectionManager.getCurrentSelections())==null?void 0:_b2.map(selection=>selection.range);return rangeProtectionRuleModel.getSubunitRuleList(unitId,subUnitId).filter(rule=>rule.ranges.some(r2=>selectionRanges==null?void 0:selectionRanges.some(selectionRange=>core.Rectangle.intersects(r2,selectionRange)))).forEach(p=>{permissionIds.push(new sheets.RangeProtectionPermissionEditPoint(unitId,subUnitId,p.permissionId).id)}),permissionService.composePermission$(permissionIds)})):rxjs.EMPTY)).subscribe(permissions=>{permissions&&setDisable(!permissions.every(p=>p.value))});return()=>{subscription.unsubscribe()}},[workbook]),React.useEffect(()=>{const subscription=editorBridgeService.visible$.subscribe(visibleInfo=>{setIconStyle(visibleInfo.visible?styles$f.formulaActive:styles$f.formulaGrey)});return()=>subscription.unsubscribe()},[editorBridgeService.visible$]),React.useEffect(()=>{const subscription=editorBridgeService.currentEditCellState$.subscribe(state=>{var _a3,_b2,_c2;(_c2=(_b2=(_a3=state==null?void 0:state.documentLayoutObject.documentModel)==null?void 0:_a3.getBody())==null?void 0:_b2.customBlocks)!=null&&_c2.length?setImageDisable(!0):setImageDisable(!1)});return()=>subscription.unsubscribe()},[editorBridgeService.currentEditCellState$]),React.useEffect(()=>{if(ref.current){const handleResize=__name(()=>{const editorRect=ref.current.getBoundingClientRect();formulaEditorManagerService.setPosition(editorRect)},"handleResize");handleResize();const a=new ResizeObserver(handleResize);return a.observe(ref.current),()=>a.disconnect()}},[formulaEditorManagerService]);function handleArrowClick(){setArrowDirection(arrowDirection===0?1:0),setTimeout(()=>{formulaEditorManagerService.handleFoldBtnClick(arrowDirection===1)},150)}__name(handleArrowClick,"handleArrowClick");function handleCloseBtnClick(){var _a3;editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.Keyboard,keycode:ui.KeyCode.ESC,unitId:(_a3=currentWorkbook==null?void 0:currentWorkbook.getUnitId())!=null?_a3:""})}__name(handleCloseBtnClick,"handleCloseBtnClick");function handleConfirmBtnClick(){var _a3;editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.PointerDown,unitId:(_a3=currentWorkbook==null?void 0:currentWorkbook.getUnitId())!=null?_a3:""})}__name(handleConfirmBtnClick,"handleConfirmBtnClick");function handlerFxBtnClick(){formulaEditorManagerService.handleFxBtnClick(!0)}__name(handlerFxBtnClick,"handlerFxBtnClick");const disabled=disable||imageDisable;return jsxRuntime.jsxs("div",{className:styles$f.formulaBox,style:{height:arrowDirection===0?"28px":"82px",pointerEvents:disable?"none":"auto"},children:[jsxRuntime.jsx("div",{className:styles$f.nameRanges,children:jsxRuntime.jsx(DefinedName,{disable})}),jsxRuntime.jsxs("div",{className:styles$f.formulaBar,children:[jsxRuntime.jsx("div",{className:clsx(styles$f.formulaIcon,{[styles$f.formulaIconDisable]:disabled}),children:jsxRuntime.jsxs("div",{className:styles$f.formulaIconWrapper,children:[jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerError,iconStyle),onClick:handleCloseBtnClick,children:jsxRuntime.jsx(CloseSingle,{})}),jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerSuccess,iconStyle),onClick:handleConfirmBtnClick,children:jsxRuntime.jsx(CheckMarkSingle,{})}),jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerFx),onClick:handlerFxBtnClick,children:jsxRuntime.jsx(FxSingle,{})})]})}),jsxRuntime.jsxs("div",{className:styles$f.formulaContainer,children:[jsxRuntime.jsx("div",{className:styles$f.formulaInput,ref,children:FormulaEditor&&jsxRuntime.jsx(FormulaEditor,{disableSelectionOnClick:!0,editorId:core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,initValue:"",onChange:__name(()=>{},"onChange"),isFocus:isFocusFxBar,className:styles$f.formulaContent,unitId:editState==null?void 0:editState.unitId,subUnitId:editState==null?void 0:editState.sheetId,isSupportAcrossSheet:!0,resetSelectionOnBlur:!1,isSingle:!1,keyboradEventConfig:keyCodeConfig,onFormulaSelectingChange:__name(isSelecting=>{isRefSelecting.current=isSelecting,isSelecting?editorBridgeService.enableForceKeepVisible():editorBridgeService.disableForceKeepVisible()},"onFormulaSelectingChange"),autoScrollbar:!1,disableContextMenu:!1})}),jsxRuntime.jsx("div",{className:clsx(styles$f.arrowContainer,{[styles$f.arrowContainerDisable]:disable}),onClick:handleArrowClick,children:arrowDirection===0?jsxRuntime.jsx(DropdownSingle,{}):jsxRuntime.jsx(DropdownSingle,{style:{transform:"rotateZ(180deg)"}})})]})]}),jsxRuntime.jsx(ui.ComponentContainer,{components:formulaAuxUIParts},"formula-aux")]})}__name(FormulaBar,"FormulaBar");const styles$e={operateContainer:"univer-operate-container",autoFillPopupMenu:"univer-auto-fill-popup-menu",autoFillPopupMenuItem:"univer-auto-fill-popup-menu-item",autoFillPopupMenuItemIcon:"univer-auto-fill-popup-menu-item-icon",autoFillPopupMenuItemTitle:"univer-auto-fill-popup-menu-item-title",autoFillPopupMenuItemHide:"univer-auto-fill-popup-menu-item-hide",btnContainer:"univer-btn-container",btnContainerExpand:"univer-btn-container-expand"},useUpdate=__name(()=>{const[,setState]=React.useState({});return React.useCallback(()=>setState(prevState=>!prevState),[])},"useUpdate"),AutoFillPopupMenu=__name(()=>{const commandService=core.useDependency(core.ICommandService),univerInstanceService=core.useDependency(core.IUniverInstanceService),renderManagerService=core.useDependency(engineRender.IRenderManagerService),autoFillService=core.useDependency(IAutoFillService),localeService=core.useDependency(core.LocaleService),[menu,setMenu]=React.useState([]),[visible,setVisible]=React.useState(!1),[anchor,setAnchor]=React.useState({row:-1,col:-1}),[selected,setSelected]=React.useState(APPLY_TYPE.SERIES),[isHovered,setHovered]=React.useState(!1),workbook=useActiveWorkbook(),{sheetSkeletonManagerService,selectionRenderService}=React.useMemo(()=>{if(workbook){const ru=renderManagerService.getRenderById(workbook.getUnitId());return{sheetSkeletonManagerService:ru==null?void 0:ru.with(exports2.SheetSkeletonManagerService),selectionRenderService:ru==null?void 0:ru.with(ISheetSelectionRenderService)}}return{sheetSkeletonManagerService:null,selectionRenderService:null}},[workbook,renderManagerService]),handleMouseEnter=__name(()=>{setHovered(!0)},"handleMouseEnter"),handleMouseLeave=__name(()=>{setHovered(!1)},"handleMouseLeave"),forceUpdate=useUpdate();if(React.useEffect(()=>commandService.onCommandExecuted((command,options)=>{command.id===SetScrollOperation.id&&forceUpdate()}).dispose,[forceUpdate,commandService]),React.useEffect(()=>{const disposable=sheetSkeletonManagerService&&core.toDisposable(sheetSkeletonManagerService.currentSkeleton$.subscribe(skeleton2=>{skeleton2&&forceUpdate()}));return disposable==null?void 0:disposable.dispose},[sheetSkeletonManagerService,forceUpdate]),React.useEffect(()=>core.toDisposable(autoFillService.menu$.subscribe(menu2=>{setMenu(menu2.map(i=>({...i,index:menu2.indexOf(i)})))})).dispose,[autoFillService]),React.useEffect(()=>core.toDisposable(autoFillService.showMenu$.subscribe(show=>{const{source,target}=autoFillService.autoFillLocation||{source:null,target:null};if(show&&source&&target){const lastRow=Math.max(source.rows[source.rows.length-1],target.rows[target.rows.length-1]),lastCol=Math.max(source.cols[source.cols.length-1],target.cols[target.cols.length-1]);setAnchor({row:lastRow,col:lastCol})}else setAnchor({row:-1,col:-1})})).dispose,[autoFillService]),React.useEffect(()=>core.toDisposable(autoFillService.applyType$.subscribe(type=>{setSelected(type)})).dispose,[autoFillService]),React.useEffect(()=>{function handleClose(){setVisible(!1)}return __name(handleClose,"handleClose"),document.addEventListener("wheel",handleClose),()=>{document.removeEventListener("wheel",handleClose)}},[visible]),anchor.col<0||anchor.row<0)return null;const sheetObject=getSheetObject(univerInstanceService,renderManagerService);if(!sheetObject||!selectionRenderService)return null;const{scene}=sheetObject,skeleton=sheetSkeletonManagerService==null?void 0:sheetSkeletonManagerService.getCurrentSkeleton(),viewport=selectionRenderService.getViewPort(),scaleX=scene==null?void 0:scene.scaleX,scaleY=scene==null?void 0:scene.scaleY,scrollXY=scene==null?void 0:scene.getViewportScrollXY(viewport);if(!scaleX||!scene||!scaleX||!scaleY||!scrollXY)return null;const x=(skeleton==null?void 0:skeleton.getNoMergeCellPositionByIndex(anchor.row,anchor.col).endX)||0,y=(skeleton==null?void 0:skeleton.getNoMergeCellPositionByIndex(anchor.row,anchor.col).endY)||0,relativeX=skeleton==null?void 0:skeleton.convertTransformToOffsetX(x,scaleX,scrollXY),relativeY=skeleton==null?void 0:skeleton.convertTransformToOffsetY(y,scaleY,scrollXY);if(relativeX==null||relativeY==null)return null;const onVisibleChange=__name(visible2=>{setVisible(visible2)},"onVisibleChange"),handleClick=__name(item=>{commandService.executeCommand(RefillCommand.id,{type:item.value}),setVisible(!1)},"handleClick"),showMore=visible||isHovered,availableMenu=menu.filter(item=>!item.disable);return jsxRuntime.jsx("div",{onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,style:{left:`${relativeX+2}px`,top:`${relativeY+2}px`,position:"absolute"},children:jsxRuntime.jsx(design.DropdownLegacy,{placement:"bottomLeft",trigger:["click"],overlay:jsxRuntime.jsx("ul",{className:styles$e.autoFillPopupMenu,children:availableMenu.map(item=>jsxRuntime.jsxs("li",{onClick:__name(()=>handleClick(item),"onClick"),className:styles$e.autoFillPopupMenuItem,children:[jsxRuntime.jsx("span",{className:styles$e.autoFillPopupMenuItemIcon,children:item.value===selected&&jsxRuntime.jsx(CheckMarkSingle,{style:{color:"rgb(var(--green-700, #409f11))"}})}),jsxRuntime.jsx("span",{className:styles$e.autoFillPopupMenuItemTitle,children:localeService.t(item.label)})]},item.index))}),visible,onVisibleChange,children:jsxRuntime.jsxs("div",{className:clsx(styles$e.btnContainer,{[styles$e.btnContainerExpand]:visible}),children:[jsxRuntime.jsx(Autofill,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),showMore&&jsxRuntime.jsx(MoreDownSingle,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},"AutoFillPopupMenu"),OperateContainer=__name(()=>jsxRuntime.jsx("div",{className:styles$e.operateContainer,children:jsxRuntime.jsx(AutoFillPopupMenu,{})}),"OperateContainer"),styles$d={sheetBar:"univer-sheet-bar",sheetBarOptions:"univer-sheet-bar-options",sheetBarOptionsDivider:"univer-sheet-bar-options-divider"},styles$c={sheetBarBtn:"univer-sheet-bar-btn"};function SheetBarButton(props){const{children,className,style,disabled=!1,onClick,...restProps}=props,handleClick=__name(e=>{if(disabled){e.preventDefault();return}onClick&&onClick(e)},"handleClick");return jsxRuntime.jsx("button",{className:styles$c.sheetBarBtn,style,disabled,onClick:handleClick,...restProps,children})}__name(SheetBarButton,"SheetBarButton");const styles$b={sheetFooterBarHeight:"36",sheetContainer:"univer-sheet-container",sheetBarMenu:"univer-sheet-bar-menu",sheetBarMenuItem:"univer-sheet-bar-menu-item",sheetBarMenuItemIcon:"univer-sheet-bar-menu-item-icon",sheetBarMenuItemHide:"univer-sheet-bar-menu-item-hide",sheetBarMenuItemSelect:"univer-sheet-bar-menu-item-select",sheetBarMenuItemLabel:"univer-sheet-bar-menu-item-label"};function SheetBarMenu(props){const{style}=props,[menu,setMenu]=React.useState([]),[visible,setVisible]=React.useState(!1),univerInstanceService=core.useDependency(core.IUniverInstanceService),commandService=core.useDependency(core.ICommandService),sheetBarService=core.useDependency(ISheetBarService),worksheetProtectionRuleModel=core.useDependency(sheets.WorksheetProtectionRuleModel),workbook=ui.useObservable(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET),null,!1,[]),handleClick=__name(item=>{const{sheetId}=item;!sheetId||!workbook||(item.hidden?commandService.executeCommand(sheets.SetWorksheetShowCommand.id,{unitId:workbook.getUnitId(),subUnitId:sheetId,value:sheetId}):item.selected||commandService.executeCommand(sheets.SetWorksheetActivateCommand.id,{unitId:workbook.getUnitId(),subUnitId:sheetId}),setVisible(!1))},"handleClick"),statusInit=React.useCallback(()=>{if(!workbook)return;const sheets2=workbook.getSheets(),activeSheet=workbook.getActiveSheet(),worksheetMenuItems=sheets2.map((sheet,index)=>({label:sheet.getName(),index:`${index}`,sheetId:sheet.getSheetId(),hidden:sheet.isSheetHidden()===core.BooleanNumber.TRUE,selected:activeSheet===sheet}));setMenu(worksheetMenuItems)},[workbook,worksheetProtectionRuleModel]),setupStatusUpdate=React.useCallback(()=>commandService.onCommandExecuted(commandInfo=>{switch(commandInfo.id){case sheets.SetWorksheetHideMutation.id:case sheets.RemoveSheetMutation.id:case sheets.SetWorksheetNameMutation.id:case sheets.InsertSheetMutation.id:case sheets.SetWorksheetOrderMutation.id:case sheets.SetWorksheetActiveOperation.id:statusInit();break}}),[commandService,statusInit]);function handleSheetBarMenu(){setVisible(!0)}__name(handleSheetBarMenu,"handleSheetBarMenu");const onVisibleChange=__name(visible2=>{setVisible(visible2)},"onVisibleChange");return React.useEffect(()=>{statusInit();const disposables=new core.DisposableCollection;return disposables.add(setupStatusUpdate()),disposables.add(sheetBarService.registerSheetBarMenuHandler({handleSheetBarMenu})),()=>disposables.dispose()},[setupStatusUpdate,sheetBarService,statusInit,workbook]),jsxRuntime.jsx(design.DropdownLegacy,{placement:"topLeft",trigger:["click"],overlay:jsxRuntime.jsx("ul",{className:styles$b.sheetBarMenu,style:{...style},children:menu.map(item=>jsxRuntime.jsxs("li",{onClick:__name(()=>handleClick(item),"onClick"),className:item.selected?`
43
+ `,{"univer-text-gray-300 univer-cursor-not-allowed hover:univer-bg-transparent":disable}),children:jsxRuntime.jsx(MoreDownSingle,{})})}),jsxRuntime.jsx(design.DropdownOverlay,{className:"univer-z-[1001]",offset:{x:-75,y:2},children:jsxRuntime.jsx(DefinedNameOverlay,{})})]})]})}__name(DefinedName,"DefinedName");const styles$f={formulaBox:"univer-formula-box",nameRanges:"univer-name-ranges",formulaBar:"univer-formula-bar",formulaIcon:"univer-formula-icon",formulaIconDisable:"univer-formula-icon-disable",formulaIconWrapper:"univer-formula-icon-wrapper",iconContainer:"univer-icon-container",iconContainerSuccess:"univer-icon-container-success",formulaActive:"univer-formula-active",iconContainerError:"univer-icon-container-error",iconContainerFx:"univer-icon-container-fx",formulaInput:"univer-formula-input",formulaContainer:"univer-formula-container",sheetEmbeddingFormulaEditorWrap:"univer-sheet-embedding-formula-editor-wrap",formulaContent:"univer-formula-content",arrowContainer:"univer-arrow-container",arrowContainerDisable:"univer-arrow-container-disable"};function FormulaBar(){var _a2;const[iconStyle,setIconStyle]=React.useState(styles$f.formulaGrey),[arrowDirection,setArrowDirection]=React.useState(0),formulaEditorManagerService=core.useDependency(IFormulaEditorManagerService),editorBridgeService=core.useDependency(IEditorBridgeService),worksheetProtectionRuleModel=core.useDependency(sheets.WorksheetProtectionRuleModel),rangeProtectionRuleModel=core.useDependency(sheets.RangeProtectionRuleModel),univerInstanceService=core.useDependency(core.IUniverInstanceService),selectionManager=core.useDependency(sheets.SheetsSelectionsService),permissionService=core.useDependency(core.IPermissionService),rangeProtectionCache=core.useDependency(sheets.RangeProtectionCache),[disableInfo,setDisableInfo]=React.useState({editDisable:!1,viewDisable:!1}),[imageDisable,setImageDisable]=React.useState(!1),currentWorkbook=useActiveWorkbook(),componentManager=core.useDependency(ui.ComponentManager),workbook=core.useObservable(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),isRefSelecting=React.useRef(0),editState=editorBridgeService.getEditLocation(),keyCodeConfig=useKeyEventConfig(isRefSelecting,(_a2=editState==null?void 0:editState.unitId)!=null?_a2:""),FormulaEditor=componentManager.get(EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY),formulaAuxUIParts=ui.useComponentsOfPart(SheetsUIPart.FORMULA_AUX),contextService=core.useDependency(core.IContextService);core.useObservable(React.useMemo(()=>contextService.subscribeContextValue$(core.FOCUSING_FX_BAR_EDITOR),[contextService]));const isFocusFxBar=contextService.getContextValue(core.FOCUSING_FX_BAR_EDITOR),ref=React.useRef(null);React.useLayoutEffect(()=>{const subscription=workbook.activeSheet$.pipe(rxjs.switchMap(worksheet=>worksheet?rxjs.merge(worksheetProtectionRuleModel.ruleChange$,rangeProtectionRuleModel.ruleChange$,selectionManager.selectionMoveEnd$,selectionManager.selectionSet$).pipe(rxjs.switchMap(()=>{var _a3,_b2;const unitId=workbook.getUnitId(),subUnitId=worksheet.getSheetId();if(!((_a3=selectionManager.getCurrentLastSelection())==null?void 0:_a3.range))return rxjs.EMPTY;const primary=(_b2=selectionManager.getCurrentLastSelection())==null?void 0:_b2.primary;return primary?rxjs.of({unitId,subUnitId,primary}):rxjs.of(null)})):rxjs.EMPTY)).subscribe(cellInfo=>{var _a3,_b2,_c2,_d2,_e2,_f2;if(cellInfo){const{unitId,subUnitId,primary}=cellInfo;if(worksheetProtectionRuleModel.getRule(unitId,subUnitId)){const editDisable2=!((_b2=(_a3=permissionService.getPermissionPoint(new sheets.WorksheetEditPermission(unitId,subUnitId).id))==null?void 0:_a3.value)==null||_b2),viewDisable2=!((_d2=(_c2=permissionService.getPermissionPoint(new sheets.WorksheetViewPermission(unitId,subUnitId).id))==null?void 0:_c2.value)==null||_d2);setDisableInfo({viewDisable:viewDisable2,editDisable:editDisable2});return}const{actualRow,actualColumn}=primary,cellInfoWithPermission=rangeProtectionCache.getCellInfo(unitId,subUnitId,actualRow,actualColumn);setDisableInfo({editDisable:!((_e2=cellInfoWithPermission==null?void 0:cellInfoWithPermission[sheets.UnitAction.Edit])==null||_e2),viewDisable:!((_f2=cellInfoWithPermission==null?void 0:cellInfoWithPermission[sheets.UnitAction.View])==null||_f2)})}else setDisableInfo({viewDisable:!1,editDisable:!1})});return()=>{subscription.unsubscribe()}},[workbook]),React.useEffect(()=>{const subscription=editorBridgeService.visible$.subscribe(visibleInfo=>{setIconStyle(visibleInfo.visible?styles$f.formulaActive:styles$f.formulaGrey)});return()=>subscription.unsubscribe()},[editorBridgeService.visible$]),React.useEffect(()=>{const subscription=editorBridgeService.currentEditCellState$.subscribe(state=>{var _a3,_b2,_c2;(_c2=(_b2=(_a3=state==null?void 0:state.documentLayoutObject.documentModel)==null?void 0:_a3.getBody())==null?void 0:_b2.customBlocks)!=null&&_c2.length?setImageDisable(!0):setImageDisable(!1)});return()=>subscription.unsubscribe()},[editorBridgeService.currentEditCellState$]),React.useEffect(()=>{if(ref.current){const handleResize=__name(()=>{const editorRect=ref.current.getBoundingClientRect();formulaEditorManagerService.setPosition(editorRect)},"handleResize");handleResize();const a=new ResizeObserver(handleResize);return a.observe(ref.current),()=>a.disconnect()}},[formulaEditorManagerService]);function handleArrowClick(){setArrowDirection(arrowDirection===0?1:0),setTimeout(()=>{formulaEditorManagerService.handleFoldBtnClick(arrowDirection===1)},150)}__name(handleArrowClick,"handleArrowClick");function handleCloseBtnClick(){var _a3;editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.Keyboard,keycode:ui.KeyCode.ESC,unitId:(_a3=currentWorkbook==null?void 0:currentWorkbook.getUnitId())!=null?_a3:""})}__name(handleCloseBtnClick,"handleCloseBtnClick");function handleConfirmBtnClick(){var _a3;editorBridgeService.isVisible().visible&&editorBridgeService.changeVisible({visible:!1,eventType:engineRender.DeviceInputEventType.PointerDown,unitId:(_a3=currentWorkbook==null?void 0:currentWorkbook.getUnitId())!=null?_a3:""})}__name(handleConfirmBtnClick,"handleConfirmBtnClick");function handlerFxBtnClick(){formulaEditorManagerService.handleFxBtnClick(!0)}__name(handlerFxBtnClick,"handlerFxBtnClick");const{viewDisable,editDisable}=disableInfo,disabled=editDisable||imageDisable;return jsxRuntime.jsxs("div",{className:styles$f.formulaBox,style:{height:arrowDirection===0?"28px":"82px",pointerEvents:editDisable?"none":"auto"},children:[jsxRuntime.jsx("div",{className:styles$f.nameRanges,children:jsxRuntime.jsx(DefinedName,{disable:editDisable})}),jsxRuntime.jsxs("div",{className:styles$f.formulaBar,children:[jsxRuntime.jsx("div",{className:clsx(styles$f.formulaIcon,{[styles$f.formulaIconDisable]:disabled}),children:jsxRuntime.jsxs("div",{className:styles$f.formulaIconWrapper,children:[jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerError,iconStyle),onClick:handleCloseBtnClick,children:jsxRuntime.jsx(CloseSingle,{})}),jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerSuccess,iconStyle),onClick:handleConfirmBtnClick,children:jsxRuntime.jsx(CheckMarkSingle,{})}),jsxRuntime.jsx("span",{className:clsx(styles$f.iconContainer,styles$f.iconContainerFx),onClick:handlerFxBtnClick,children:jsxRuntime.jsx(FxSingle,{})})]})}),jsxRuntime.jsxs("div",{className:styles$f.formulaContainer,children:[jsxRuntime.jsx("div",{className:styles$f.formulaInput,ref,children:FormulaEditor&&jsxRuntime.jsx(FormulaEditor,{disableSelectionOnClick:!0,editorId:core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,initValue:"",onChange:__name(()=>{},"onChange"),isFocus:isFocusFxBar,className:styles$f.formulaContent,unitId:editState==null?void 0:editState.unitId,subUnitId:editState==null?void 0:editState.sheetId,isSupportAcrossSheet:!0,resetSelectionOnBlur:!1,isSingle:!1,keyboradEventConfig:keyCodeConfig,onFormulaSelectingChange:__name(isSelecting=>{isRefSelecting.current=isSelecting,isSelecting?editorBridgeService.enableForceKeepVisible():editorBridgeService.disableForceKeepVisible()},"onFormulaSelectingChange"),autoScrollbar:!1,disableContextMenu:!1})}),jsxRuntime.jsx("div",{className:clsx(styles$f.arrowContainer,{[styles$f.arrowContainerDisable]:editDisable}),onClick:handleArrowClick,children:arrowDirection===0?jsxRuntime.jsx(DropdownSingle,{}):jsxRuntime.jsx(DropdownSingle,{style:{transform:"rotateZ(180deg)"}})})]})]}),jsxRuntime.jsx(ui.ComponentContainer,{components:formulaAuxUIParts},"formula-aux")]})}__name(FormulaBar,"FormulaBar");const styles$e={operateContainer:"univer-operate-container",autoFillPopupMenu:"univer-auto-fill-popup-menu",autoFillPopupMenuItem:"univer-auto-fill-popup-menu-item",autoFillPopupMenuItemIcon:"univer-auto-fill-popup-menu-item-icon",autoFillPopupMenuItemTitle:"univer-auto-fill-popup-menu-item-title",autoFillPopupMenuItemHide:"univer-auto-fill-popup-menu-item-hide",btnContainer:"univer-btn-container",btnContainerExpand:"univer-btn-container-expand"},useUpdate=__name(()=>{const[,setState]=React.useState({});return React.useCallback(()=>setState(prevState=>!prevState),[])},"useUpdate"),AutoFillPopupMenu=__name(()=>{const commandService=core.useDependency(core.ICommandService),univerInstanceService=core.useDependency(core.IUniverInstanceService),renderManagerService=core.useDependency(engineRender.IRenderManagerService),autoFillService=core.useDependency(IAutoFillService),localeService=core.useDependency(core.LocaleService),[menu,setMenu]=React.useState([]),[visible,setVisible]=React.useState(!1),[anchor,setAnchor]=React.useState({row:-1,col:-1}),[selected,setSelected]=React.useState(APPLY_TYPE.SERIES),[isHovered,setHovered]=React.useState(!1),workbook=useActiveWorkbook(),{sheetSkeletonManagerService,selectionRenderService}=React.useMemo(()=>{if(workbook){const ru=renderManagerService.getRenderById(workbook.getUnitId());return{sheetSkeletonManagerService:ru==null?void 0:ru.with(exports2.SheetSkeletonManagerService),selectionRenderService:ru==null?void 0:ru.with(ISheetSelectionRenderService)}}return{sheetSkeletonManagerService:null,selectionRenderService:null}},[workbook,renderManagerService]),handleMouseEnter=__name(()=>{setHovered(!0)},"handleMouseEnter"),handleMouseLeave=__name(()=>{setHovered(!1)},"handleMouseLeave"),forceUpdate=useUpdate();if(React.useEffect(()=>commandService.onCommandExecuted((command,options)=>{command.id===SetScrollOperation.id&&forceUpdate()}).dispose,[forceUpdate,commandService]),React.useEffect(()=>{const disposable=sheetSkeletonManagerService&&core.toDisposable(sheetSkeletonManagerService.currentSkeleton$.subscribe(skeleton2=>{skeleton2&&forceUpdate()}));return disposable==null?void 0:disposable.dispose},[sheetSkeletonManagerService,forceUpdate]),React.useEffect(()=>core.toDisposable(autoFillService.menu$.subscribe(menu2=>{setMenu(menu2.map(i=>({...i,index:menu2.indexOf(i)})))})).dispose,[autoFillService]),React.useEffect(()=>core.toDisposable(autoFillService.showMenu$.subscribe(show=>{const{source,target}=autoFillService.autoFillLocation||{source:null,target:null};if(show&&source&&target){const lastRow=Math.max(source.rows[source.rows.length-1],target.rows[target.rows.length-1]),lastCol=Math.max(source.cols[source.cols.length-1],target.cols[target.cols.length-1]);setAnchor({row:lastRow,col:lastCol})}else setAnchor({row:-1,col:-1})})).dispose,[autoFillService]),React.useEffect(()=>core.toDisposable(autoFillService.applyType$.subscribe(type=>{setSelected(type)})).dispose,[autoFillService]),React.useEffect(()=>{function handleClose(){setVisible(!1)}return __name(handleClose,"handleClose"),document.addEventListener("wheel",handleClose),()=>{document.removeEventListener("wheel",handleClose)}},[visible]),anchor.col<0||anchor.row<0)return null;const sheetObject=getSheetObject(univerInstanceService,renderManagerService);if(!sheetObject||!selectionRenderService)return null;const{scene}=sheetObject,skeleton=sheetSkeletonManagerService==null?void 0:sheetSkeletonManagerService.getCurrentSkeleton(),viewport=selectionRenderService.getViewPort(),scaleX=scene==null?void 0:scene.scaleX,scaleY=scene==null?void 0:scene.scaleY,scrollXY=scene==null?void 0:scene.getViewportScrollXY(viewport);if(!scaleX||!scene||!scaleX||!scaleY||!scrollXY)return null;const x=(skeleton==null?void 0:skeleton.getNoMergeCellPositionByIndex(anchor.row,anchor.col).endX)||0,y=(skeleton==null?void 0:skeleton.getNoMergeCellPositionByIndex(anchor.row,anchor.col).endY)||0,relativeX=skeleton==null?void 0:skeleton.convertTransformToOffsetX(x,scaleX,scrollXY),relativeY=skeleton==null?void 0:skeleton.convertTransformToOffsetY(y,scaleY,scrollXY);if(relativeX==null||relativeY==null)return null;const onVisibleChange=__name(visible2=>{setVisible(visible2)},"onVisibleChange"),handleClick=__name(item=>{commandService.executeCommand(RefillCommand.id,{type:item.value}),setVisible(!1)},"handleClick"),showMore=visible||isHovered,availableMenu=menu.filter(item=>!item.disable);return jsxRuntime.jsx("div",{onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,style:{left:`${relativeX+2}px`,top:`${relativeY+2}px`,position:"absolute"},children:jsxRuntime.jsx(design.DropdownLegacy,{placement:"bottomLeft",trigger:["click"],overlay:jsxRuntime.jsx("ul",{className:styles$e.autoFillPopupMenu,children:availableMenu.map(item=>jsxRuntime.jsxs("li",{onClick:__name(()=>handleClick(item),"onClick"),className:styles$e.autoFillPopupMenuItem,children:[jsxRuntime.jsx("span",{className:styles$e.autoFillPopupMenuItemIcon,children:item.value===selected&&jsxRuntime.jsx(CheckMarkSingle,{style:{color:"rgb(var(--green-700, #409f11))"}})}),jsxRuntime.jsx("span",{className:styles$e.autoFillPopupMenuItemTitle,children:localeService.t(item.label)})]},item.index))}),visible,onVisibleChange,children:jsxRuntime.jsxs("div",{className:clsx(styles$e.btnContainer,{[styles$e.btnContainerExpand]:visible}),children:[jsxRuntime.jsx(Autofill,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),showMore&&jsxRuntime.jsx(MoreDownSingle,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},"AutoFillPopupMenu"),OperateContainer=__name(()=>jsxRuntime.jsx("div",{className:styles$e.operateContainer,children:jsxRuntime.jsx(AutoFillPopupMenu,{})}),"OperateContainer"),styles$d={sheetBar:"univer-sheet-bar",sheetBarOptions:"univer-sheet-bar-options",sheetBarOptionsDivider:"univer-sheet-bar-options-divider"},styles$c={sheetBarBtn:"univer-sheet-bar-btn"};function SheetBarButton(props){const{children,className,style,disabled=!1,onClick,...restProps}=props,handleClick=__name(e=>{if(disabled){e.preventDefault();return}onClick&&onClick(e)},"handleClick");return jsxRuntime.jsx("button",{className:styles$c.sheetBarBtn,style,disabled,onClick:handleClick,...restProps,children})}__name(SheetBarButton,"SheetBarButton");const styles$b={sheetFooterBarHeight:"36",sheetContainer:"univer-sheet-container",sheetBarMenu:"univer-sheet-bar-menu",sheetBarMenuItem:"univer-sheet-bar-menu-item",sheetBarMenuItemIcon:"univer-sheet-bar-menu-item-icon",sheetBarMenuItemHide:"univer-sheet-bar-menu-item-hide",sheetBarMenuItemSelect:"univer-sheet-bar-menu-item-select",sheetBarMenuItemLabel:"univer-sheet-bar-menu-item-label"};function SheetBarMenu(props){const{style}=props,[menu,setMenu]=React.useState([]),[visible,setVisible]=React.useState(!1),univerInstanceService=core.useDependency(core.IUniverInstanceService),commandService=core.useDependency(core.ICommandService),sheetBarService=core.useDependency(ISheetBarService),worksheetProtectionRuleModel=core.useDependency(sheets.WorksheetProtectionRuleModel),workbook=ui.useObservable(()=>univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET),null,!1,[]),handleClick=__name(item=>{const{sheetId}=item;!sheetId||!workbook||(item.hidden?commandService.executeCommand(sheets.SetWorksheetShowCommand.id,{unitId:workbook.getUnitId(),subUnitId:sheetId,value:sheetId}):item.selected||commandService.executeCommand(sheets.SetWorksheetActivateCommand.id,{unitId:workbook.getUnitId(),subUnitId:sheetId}),setVisible(!1))},"handleClick"),statusInit=React.useCallback(()=>{if(!workbook)return;const sheets2=workbook.getSheets(),activeSheet=workbook.getActiveSheet(),worksheetMenuItems=sheets2.map((sheet,index)=>({label:sheet.getName(),index:`${index}`,sheetId:sheet.getSheetId(),hidden:sheet.isSheetHidden()===core.BooleanNumber.TRUE,selected:activeSheet===sheet}));setMenu(worksheetMenuItems)},[workbook,worksheetProtectionRuleModel]),setupStatusUpdate=React.useCallback(()=>commandService.onCommandExecuted(commandInfo=>{switch(commandInfo.id){case sheets.SetWorksheetHideMutation.id:case sheets.RemoveSheetMutation.id:case sheets.SetWorksheetNameMutation.id:case sheets.InsertSheetMutation.id:case sheets.SetWorksheetOrderMutation.id:case sheets.SetWorksheetActiveOperation.id:statusInit();break}}),[commandService,statusInit]);function handleSheetBarMenu(){setVisible(!0)}__name(handleSheetBarMenu,"handleSheetBarMenu");const onVisibleChange=__name(visible2=>{setVisible(visible2)},"onVisibleChange");return React.useEffect(()=>{statusInit();const disposables=new core.DisposableCollection;return disposables.add(setupStatusUpdate()),disposables.add(sheetBarService.registerSheetBarMenuHandler({handleSheetBarMenu})),()=>disposables.dispose()},[setupStatusUpdate,sheetBarService,statusInit,workbook]),jsxRuntime.jsx(design.DropdownLegacy,{placement:"topLeft",trigger:["click"],overlay:jsxRuntime.jsx("ul",{className:styles$b.sheetBarMenu,style:{...style},children:menu.map(item=>jsxRuntime.jsxs("li",{onClick:__name(()=>handleClick(item),"onClick"),className:item.selected?`
44
44
  ${styles$b.sheetBarMenuItem}
45
45
  ${styles$b.sheetBarMenuItemSelect}
46
46
  `:item.hidden?`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-ui",
3
- "version": "0.5.5-nightly.202501231606",
3
+ "version": "0.5.5-nightly.202501241606",
4
4
  "private": false,
5
5
  "description": "UniverSheet normal ui-plugin-sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -62,16 +62,16 @@
62
62
  "@univerjs/icons": "^0.2.14",
63
63
  "@univerjs/protocol": "0.1.43",
64
64
  "clsx": "^2.1.1",
65
- "@univerjs/core": "0.5.5-nightly.202501231606",
66
- "@univerjs/design": "0.5.5-nightly.202501231606",
67
- "@univerjs/docs": "0.5.5-nightly.202501231606",
68
- "@univerjs/engine-formula": "0.5.5-nightly.202501231606",
69
- "@univerjs/docs-ui": "0.5.5-nightly.202501231606",
70
- "@univerjs/engine-numfmt": "0.5.5-nightly.202501231606",
71
- "@univerjs/telemetry": "0.5.5-nightly.202501231606",
72
- "@univerjs/sheets": "0.5.5-nightly.202501231606",
73
- "@univerjs/ui": "0.5.5-nightly.202501231606",
74
- "@univerjs/engine-render": "0.5.5-nightly.202501231606"
65
+ "@univerjs/core": "0.5.5-nightly.202501241606",
66
+ "@univerjs/design": "0.5.5-nightly.202501241606",
67
+ "@univerjs/docs": "0.5.5-nightly.202501241606",
68
+ "@univerjs/engine-formula": "0.5.5-nightly.202501241606",
69
+ "@univerjs/docs-ui": "0.5.5-nightly.202501241606",
70
+ "@univerjs/engine-numfmt": "0.5.5-nightly.202501241606",
71
+ "@univerjs/engine-render": "0.5.5-nightly.202501241606",
72
+ "@univerjs/sheets": "0.5.5-nightly.202501241606",
73
+ "@univerjs/telemetry": "0.5.5-nightly.202501241606",
74
+ "@univerjs/ui": "0.5.5-nightly.202501241606"
75
75
  },
76
76
  "devDependencies": {
77
77
  "less": "^4.2.1",