@univerjs/sheets-data-validation-ui 0.7.0-nightly.202505091607 → 0.7.0-nightly.202505111606

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/umd/index.js CHANGED
@@ -30,16 +30,15 @@
30
30
  hover:univer-bg-primary-600/5
31
31
  `,onClick:se,children:[v.jsx(ft,{className:"univer-mr-1"}),T.t("dataValidation.list.add")]})]})})]})}const Jt=[[f.CUSTOM_FORMULA_INPUT_NAME,kt],[f.BASE_FORMULA_INPUT_NAME,Ut],[f.LIST_FORMULA_INPUT_NAME,Zt],[f.CHECKBOX_FORMULA_INPUT_NAME,Ft]];var Qt=Object.getOwnPropertyDescriptor,en=(e,t,r,n)=>{for(var a=n>1?void 0:n?Qt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},tn=(e,t)=>(r,n)=>t(r,n,e);L.BaseSheetDataValidatorView=class{constructor(t){R(this,"canvasRender",null);R(this,"dropdownType");R(this,"optionsInput");R(this,"formulaInput",f.LIST_FORMULA_INPUT_NAME);this.injector=t}},L.BaseSheetDataValidatorView=en([tn(0,o.Inject(o.Injector))],L.BaseSheetDataValidatorView);var nn=Object.getOwnPropertyDescriptor,rn=(e,t,r,n)=>{for(var a=n>1?void 0:n?nn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},It=(e,t)=>(r,n)=>t(r,n,e);let de=class extends o.Disposable{constructor(t,r){super();R(this,"_open$",new te.BehaviorSubject(!1));R(this,"open$",this._open$.pipe(te.distinctUntilChanged()));R(this,"_activeRule");R(this,"_activeRule$",new te.BehaviorSubject(void 0));R(this,"activeRule$",this._activeRule$.asObservable());R(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=r,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(te.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Ne&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};de=rn([It(0,o.IUniverInstanceService),It(1,b.ISidebarService)],de);const Je="sheets-data-validation-ui.config",Le={};var an=Object.getOwnPropertyDescriptor,on=(e,t,r,n)=>{for(var a=n>1?void 0:n?an(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ye=(e,t)=>(r,n)=>t(r,n,e);let we=class extends o.Disposable{constructor(e,t,r,n,a,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=r,this._dialogService=n,this._localeService=a,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept($.VALIDATE_CELL,{handler:async(e,t,r)=>{const n=await e,{row:a,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,a,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(n===!1)return r(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return r(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,a,i)===o.DataValidationStatus.VALID?r(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:a,col:i,unitId:s,subUnitId:d})},footer:{title:V.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),r(Promise.resolve(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:V.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};we=on([ye(0,o.Inject($.SheetInterceptorService)),ye(1,o.Inject(f.SheetDataValidationModel)),ye(2,o.Inject(Y.DataValidatorRegistryService)),ye(3,b.IDialogService),ye(4,o.Inject(o.LocaleService)),ye(5,o.Inject(f.SheetsDataValidationValidatorService))],we);var sn=Object.getOwnPropertyDescriptor,ln=(e,t,r,n)=>{for(var a=n>1?void 0:n?sn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ie=(e,t)=>(r,n)=>t(r,n,e);const Qe=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function dn(e,t){const r=Nt.getPatternType(t);if(e===r)return t;switch(e){case"datetime":return"yyyy-MM-dd hh:mm:ss";case"date":return"yyyy-MM-dd";case"time":return"HH:mm:ss"}}let fe=class extends o.Disposable{constructor(t,r,n,a,i,s,d,l,c,h,p){super();R(this,"_activeDropdown");R(this,"_activeDropdown$",new te.Subject);R(this,"_currentPopup",null);R(this,"activeDropdown$",this._activeDropdown$.asObservable());R(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=r,this._zenZoneService=n,this._dataValidationModel=a,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=p,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,r,n,a){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=r?i.getSheetBySheetId(r):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,a);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(r=>!(r.primary&&this._getDropdownByCell(r.primary.unitId,r.primary.sheetId,r.primary.actualRow,r.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var O,T,m,C;const{location:r}=t,{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=r;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,n,a);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let p;const u=async(S,y)=>{var j,B,A;if(!S)return!0;const D=S,w=l.getCell(n,a),E=D.format(y==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),F=(j=o.numfmt.parseDate(E))==null?void 0:j.v,x=y==="time"?F%1:F,P=d.getStyles().getStyleByCell(w),k=(A=(B=P==null?void 0:P.n)==null?void 0:B.pattern)!=null?A:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:x,unitId:i,subUnitId:s,row:n,column:a,worksheet:l,workbook:d,interceptValue:E.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:N.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),await this._commandService.executeCommand($.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:x,t:2,p:null,f:null,si:null,s:{n:{pattern:dn(y,k)}}}}),!0):(this._injector.has(we)&&this._injector.get(we).showReject(h.getRuleFinalError(c,{row:n,col:a,unitId:i,subUnitId:s})),!1)};let _;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const S=f.getCellValueOrigin(l.getCellRaw(n,a)),y=Qe(S),D=!!((O=c.bizInfo)!=null&&O.showTime);_={location:r,type:"datepicker",props:{showTime:D,onChange:w=>u(w,D?"datetime":"date"),defaultValue:y,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const S=f.getCellValueOrigin(l.getCellRaw(n,a)),y=Qe(S);_={location:r,type:"datepicker",props:{onChange:D=>u(D,"time"),defaultValue:y,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const S=f.getCellValueOrigin(l.getCellRaw(n,a)),y=Qe(S);_={location:r,type:"datepicker",props:{onChange:D=>u(D,"datetime"),defaultValue:y,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const S=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,y=async P=>{const k=f.serializeListOptions(P),j={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:k,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:N.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.executeCommand($.SetRangeValuesCommand.id,j),!S},D=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,w=h.getListWithColor(c,i,s),E=f.getDataValidationCellValue(l.getCellRaw(n,a)),F=()=>{this._commandService.executeCommand(me.id,{ruleId:c.uid}),p==null||p.dispose()},x=w.map(P=>({label:P.label,value:P.label,color:D||P.color?P.color:"transparent"}));_={location:r,type:"list",props:{onChange:P=>y(P),options:x,onEdit:F,defaultValue:E,multiple:S,showEdit:(m=(T=this._configService.getConfig(Je))==null?void 0:T.showEditOnDropdown)!=null?m:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{_={type:"cascader",props:{onChange:y=>{const D={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:y.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:N.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,D),!0},defaultValue:f.getDataValidationCellValue(l.getCellRaw(n,a)).split("/"),options:JSON.parse((C=c.formula1)!=null?C:"[]")},location:r};break}case Y.DataValidatorDropdownType.COLOR:{_={type:"color",props:{onChange:y=>{const D={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:y,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:N.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,D),!0},defaultValue:f.getDataValidationCellValue(l.getCellRaw(n,a))},location:r};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(p=this._cellDropdownManagerService.showDropdown(_),!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const g=new o.DisposableCollection;g.add(p),g.add({dispose:()=>{var S,y;(y=(S=this._activeDropdown)==null?void 0:S.onHide)==null||y.call(S)}}),this._currentPopup=g}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,r,n,a,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(r);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,a);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:a,unitId:t,subUnitId:r},onHide:i})}};fe=ln([ie(0,o.IUniverInstanceService),ie(1,o.Inject(Y.DataValidatorRegistryService)),ie(2,b.IZenZoneService),ie(3,o.Inject(f.SheetDataValidationModel)),ie(4,o.Inject($.SheetsSelectionsService)),ie(5,o.Inject(H.ISheetCellDropdownManagerService)),ie(6,o.Inject(f.SheetDataValidationModel)),ie(7,o.ICommandService),ie(8,H.IEditorBridgeService),ie(9,o.Inject(o.Injector)),ie(10,o.IConfigService)],fe);const Ne="DataValidationPanel",me={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:r,isAdd:n}=t,a=e.get(de),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(b.ISidebarService),l=$.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,p=r?i.getRuleById(c,h,r):void 0;a.open(),a.setActiveRule(p&&{unitId:c,subUnitId:h,rule:p});const u=d.open({id:Ne,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ne},width:312,onClose:()=>a.close()});return a.setCloseDisposable(u),!0}},et={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(de).close(),!0}},Ct={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),r=e.get(de);return r.open(),r.isOpen?t.executeCommand(et.id):t.executeCommand(me.id),!0}},Ue={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const r=e.get(fe),{unitId:n,subUnitId:a,row:i,column:s}=t,d=r.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===a&&l.row===i&&l.col===s||r.showDataValidationDropdown(n,a,i,s),!0}},yt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Fe={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),r=$.getSheetCommandTarget(t);if(!r)return!1;const{workbook:n,worksheet:a}=r,i=f.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=a.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(f.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(me.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var cn=Object.getOwnPropertyDescriptor,un=(e,t,r,n)=>{for(var a=n>1?void 0:n?cn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},De=(e,t)=>(r,n)=>t(r,n,e);const Se="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends o.Disposable{constructor(e,t,r,n,a,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=r,this._localeService=n,this._zenZoneService=a,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(te.debounceTime(100)).subscribe(e=>{var t;if(e){const r=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=r.getSheetBySheetId(e.location.subUnitId);if(!n)return;const a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(Se);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:r,worksheet:n})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Se),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Se);return}const l=this._dataValidationModel.getValidator(a.type);if(!l){this._cellAlertManagerService.removeAlert(Se);return}this._cellAlertManagerService.showAlert({type:H.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(a,e.location),location:e.location,width:200,height:74,key:Se});return}}this._cellAlertManagerService.removeAlert(Se)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Se)}))}};Pe=un([De(0,o.Inject(H.HoverManagerService)),De(1,o.Inject(H.CellAlertManagerService)),De(2,o.IUniverInstanceService),De(3,o.Inject(o.LocaleService)),De(4,b.IZenZoneService),De(5,o.Inject(f.SheetDataValidationModel))],Pe);var hn=Object.getOwnPropertyDescriptor,vn=(e,t,r,n)=>{for(var a=n>1?void 0:n?hn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},tt=(e,t)=>(r,n)=>t(r,n,e);let Ee=class extends o.Disposable{constructor(e,t,r){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=r,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,a)=>{const{source:i,target:s,unitId:d,subUnitId:l}=n,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=H.virtualizeDiscreteRanges([i,s]),[p,u]=h.ranges,{mapFunc:_}=h,g={row:p.startRow,col:p.startColumn},O=H.getAutoFillRepeatRange(p,u),T=new o.ObjectMatrix,m=new Set;O.forEach(w=>{const E=w.repeatStartCell,F=w.relativeRange,x={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},P={startRow:E.row,startColumn:E.col,endColumn:E.col,endRow:E.row};o.Range.foreach(F,(k,j)=>{const B=o.Rectangle.getPositionRange({startRow:k,startColumn:j,endColumn:j,endRow:k},x),{row:A,col:X}=_(B.startRow,B.startColumn),z=this._sheetDataValidationModel.getRuleIdByLocation(d,l,A,X)||"",Z=o.Rectangle.getPositionRange({startRow:k,startColumn:j,endColumn:j,endRow:k},P),{row:Q,col:J}=_(Z.startRow,Z.startColumn);T.setValue(Q,J,z),m.add(z)})});const C=Array.from(m).map(w=>({id:w,ranges:o.queryObjectMatrix(T,E=>E===w)}));c.addRangeRules(C);const S=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:y,undoMutations:D}=f.getDataValidationDiffMutations(d,l,S,this._injector,"patched",a===H.APPLY_TYPE.ONLY_FORMAT);return{undos:D,redos:y}},r={id:f.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:a,unitId:i,subUnitId:s}=n;for(const d of a.rows)for(const l of a.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(H.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,a,i)=>i===H.APPLY_TYPE.COPY||i===H.APPLY_TYPE.ONLY_FORMAT||i===H.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(r))}};Ee=vn([tt(0,H.IAutoFillService),tt(1,o.Inject(f.SheetDataValidationModel)),tt(2,o.Inject(o.Injector))],Ee);var pn=Object.getOwnPropertyDescriptor,gn=(e,t,r,n)=>{for(var a=n>1?void 0:n?pn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},nt=(e,t)=>(r,n)=>t(r,n,e);let Me=class extends o.Disposable{constructor(t,r,n){super();R(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=r,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:f.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,r,n)=>this._collect(t,r,n),onPasteCells:(t,r,n,a)=>{const{copyType:i=H.COPY_TYPE.COPY,pasteType:s}=a,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=r;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,r,n){const a=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:r,matrix:a};const i=this._injector.invoke(l=>$.rangeToDiscreteRange(n,l,t,r));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,p)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,r,l,h);a.setValue(c,p,u!=null?u:"")})})}_generateMutations(t,r){if(!this._copyInfo)return{redos:[],undos:[]};if(r.copyType===H.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!r.copyRange)return{redos:[],undos:[]};if([H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{unitId:a,subUnitId:i}=this._copyInfo;if(r.unitId!==a||i!==r.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(r.unitId,r.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=H.virtualizeDiscreteRanges([r.copyRange,t]),u=H.getRepeatRange(c,h,!0),_=new Map;u.forEach(({startRange:m})=>{var C;(C=this._copyInfo)==null||C.matrix.forValue((S,y,D)=>{const w=o.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:y,endColumn:y},m),E=`${i}-${D}`,F=this._sheetDataValidationModel.getRuleById(a,i,D);!this._sheetDataValidationModel.getRuleById(r.unitId,r.subUnitId,E)&&F&&_.set(E,{...F,uid:E});const{row:x,col:P}=p(w.startRow,w.startColumn);l.add(E),d.setValue(x,P,E)})});const g=Array.from(l).map(m=>({id:m,ranges:o.queryObjectMatrix(d,C=>C===m)}));s.addRangeRules(g);const{redoMutations:O,undoMutations:T}=f.getDataValidationDiffMutations(r.unitId,r.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(r.unitId,r.subUnitId),_.values()),this._injector,"patched",!1);return{redos:O,undos:T}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(a,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=H.virtualizeDiscreteRanges([r.copyRange,t]);H.getRepeatRange(c,h,!0).forEach(({startRange:T})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((C,S,y)=>{const D=o.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:S,endColumn:S},T),{row:w,col:E}=p(D.startRow,D.startColumn);d.setValue(w,E,y),l.add(y)})});const _=Array.from(l).map(T=>({id:T,ranges:o.queryObjectMatrix(d,m=>m===T)}));s.addRangeRules(_);const{redoMutations:g,undoMutations:O}=f.getDataValidationDiffMutations(a,i,s.diff(this._sheetDataValidationModel.getRules(a,i)),this._injector,"patched",!1);return{redos:g,undos:O}}}};Me=gn([nt(0,H.ISheetClipboardService),nt(1,o.Inject(f.SheetDataValidationModel)),nt(2,o.Inject(o.Injector))],Me);var fn=Object.getOwnPropertyDescriptor,mn=(e,t,r,n)=>{for(var a=n>1?void 0:n?fn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},rt=(e,t)=>(r,n)=>t(r,n,e);let be=class extends o.Disposable{constructor(e,t,r){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=r,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===f.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===f.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};be=mn([rt(0,o.Inject(o.LocaleService)),rt(1,o.ICommandService),rt(2,o.Inject($.SheetPermissionCheckController))],be);const wt="data-validation-single",Dt="sheet.menu.data-validation";function Sn(e){return{id:Dt,type:b.MenuItemType.SUBITEMS,icon:wt,tooltip:"dataValidation.title",hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(e,{workbookTypes:[$.WorkbookEditablePermission],worksheetTypes:[$.WorksheetSetCellStylePermission,$.WorksheetEditPermission],rangeTypes:[$.RangeProtectionPermissionEditPoint]})}}function _n(e){return{id:me.id,title:"dataValidation.panel.title",type:b.MenuItemType.BUTTON}}function In(e){return{id:Fe.id,title:"dataValidation.panel.add",type:b.MenuItemType.BUTTON}}const Cn={[b.RibbonStartGroup.FORMULAS_INSERT]:{[Dt]:{order:9,menuItemFactory:Sn,[me.id]:{order:0,menuItemFactory:_n},[Fe.id]:{order:1,menuItemFactory:In}}}};var yn=Object.getOwnPropertyDescriptor,Et=(e,t,r,n)=>{for(var a=n>1?void 0:n?yn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},q=(e,t)=>(r,n)=>t(r,n,e);const Mt={tr:{size:6,color:"#fe4b4b"}};let Te=class extends o.RxDisposable{constructor(e,t,r,n,a,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=r,this._univerInstanceService=n,this._autoHeightController=a,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Cn)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var r;if(!e.visible){((r=this._dropdownManagerService.activeDropdown)==null?void 0:r.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:a,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,a,i,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,u=p==null?void 0:p.location;if(u&&u.unitId===n&&u.subUnitId===a&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:a,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var m,C,S,y,D;const{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,a);if(!c)return r(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return r(e);const p=(m=this._dataValidationCacheService.getValue(i,s,n,a))!=null?m:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),_=t.rawData;let g;const O={get value(){var w;return g!==void 0||(g=(w=f.getCellValueOrigin(_))!=null?w:null),g}},T={get value(){var w;return`${(w=O.value)!=null?w:""}`}};return r({...e,markers:{...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Mt:null},customRender:[...(C=e==null?void 0:e.customRender)!=null?C:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((y=u==null?void 0:u.skipDefaultFontRender)==null?void 0:y.call(u,h,O.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T.value,{get style(){const w=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?w.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},interceptorAutoHeight:()=>{var x,P,k,j,B,A;const w=(P=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:P.skeleton;if(!w)return;const E=w.worksheet.getMergedCell(n,a),F={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((k=E==null?void 0:E.startRow)!=null?k:n,(j=E==null?void 0:E.startColumn)!=null?j:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(A=(B=u==null?void 0:u.canvasRender)==null?void 0:B.calcCellAutoHeight)==null?void 0:A.call(B,F)},interceptorAutoWidth:()=>{var x,P,k,j,B,A;const w=(P=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:P.skeleton;if(!w)return;const E=w.worksheet.getMergedCell(n,a),F={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((k=E==null?void 0:E.startRow)!=null?k:n,(j=E==null?void 0:E.startColumn)!=null?j:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(A=(B=u==null?void 0:u.canvasRender)==null?void 0:B.calcCellAutoWidth)==null?void 0:A.call(B,F)},coverable:((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(te.filter(e=>e.source==="command"),te.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(r=>{var n;(r.rule.type===o.DataValidationType.LIST_MULTIPLE||r.rule.type===o.DataValidationType.LIST)&&(n=r.rule)!=null&&n.ranges&&t.push(...r.rule.ranges)}),t.length){const r=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(r.redos,this._commandService)}})}};Te=Et([q(0,o.ICommandService),q(1,b.IMenuManagerService),q(2,N.IRenderManagerService),q(3,o.IUniverInstanceService),q(4,o.Inject(H.AutoHeightController)),q(5,o.Inject(fe)),q(6,o.Inject(f.SheetDataValidationModel)),q(7,o.Inject(Y.DataValidatorRegistryService)),q(8,o.Inject($.SheetInterceptorService)),q(9,o.Inject(f.DataValidationCacheService)),q(10,o.Optional(H.IEditorBridgeService))],Te);let bt=class extends o.RxDisposable{constructor(e,t,r,n,a,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=r,this._dataValidatorRegistryService=n,this._sheetInterceptorService=a,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var T,m,C,S,y;const{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,a);if(!c)return r(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return r(e);const p=(T=this._dataValidationCacheService.getValue(i,s,n,a))!=null?T:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),_=l.getCellRaw(n,a),g=f.getCellValueOrigin(_),O=`${g!=null?g:""}`;return r({...e,markers:{...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Mt:null},customRender:[...(m=e==null?void 0:e.customRender)!=null?m:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((C=e==null?void 0:e.fontRenderExtension)==null?void 0:C.isSkip)||((S=u==null?void 0:u.skipDefaultFontRender)==null?void 0:S.call(u,h,g,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,O,{get style(){const D=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?D.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},interceptorAutoHeight:()=>{var F,x,P,k,j,B;const D=(x=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!D)return;const w=D.worksheet.getMergedCell(n,a),E={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((P=w==null?void 0:w.startRow)!=null?P:n,(k=w==null?void 0:w.startColumn)!=null?k:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(B=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:B.call(j,E)},coverable:((y=e==null?void 0:e.coverable)!=null?y:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(te.filter(e=>e.source==="command"),te.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(r=>{var n;(n=r.rule)!=null&&n.ranges&&t.push(...r.rule.ranges)}),t.length){const r=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(r.redos,this._commandService)}})}};bt=Et([q(0,o.ICommandService),q(1,N.IRenderManagerService),q(2,o.Inject(H.AutoHeightController)),q(3,o.Inject(Y.DataValidatorRegistryService)),q(4,o.Inject($.SheetInterceptorService)),q(5,o.Inject(f.SheetDataValidationModel)),q(6,o.Inject(f.DataValidationCacheService))],bt);var wn=Object.getOwnPropertyDescriptor,Dn=(e,t,r,n)=>{for(var a=n>1?void 0:n?wn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Tt=(e,t)=>(r,n)=>t(r,n,e);let ke=class extends o.Disposable{constructor(e,t,r){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const r=new Set;t.forEach(a=>{r.add(a.subUnitId)}),r.forEach(a=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(a))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};ke=Dn([Tt(1,o.Inject(f.SheetDataValidationModel)),Tt(2,o.Inject(H.SheetSkeletonManagerService))],ke);function En(e){var c;const t=b.useDependency(o.LocaleService),r=b.useDependency(b.ComponentManager),{value:n,onChange:a,extraComponent:i}=e,[s,d]=V.useState(!1),l=i?r.get(i):null;return v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:`
32
32
  univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900
33
+ dark:univer-text-white
33
34
  `,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?v.jsx(mt,{className:"univer-ml-1"}):v.jsx(Ze,{className:"univer-ml-1"})]}),s&&v.jsxs(v.Fragment,{children:[l?v.jsx(l,{value:n,onChange:a}):null,v.jsx(M.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:v.jsxs(M.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>a({...n,errorStyle:+h}),children:[v.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),v.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),v.jsx(M.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:v.jsx(M.Checkbox,{checked:n.showErrorMessage,onChange:()=>a({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?v.jsx(M.FormLayout,{children:v.jsx(M.Input,{value:n.error,onChange:h=>a({...n,error:h})})}):null]})]})}const Mn=e=>o.debounce(async(t,r,n,a)=>{const i=await e.executeCommand(t,r,n);a==null||a(i)},1e3);function bn(e,t,r){var n,a,i,s;return t?((a=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(r))==null?void 0:a.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(r))==null?void 0:s.getSheetId())||""}function Tn(){var U,G;const[e,t]=V.useState(0),r=b.useDependency(de),n=b.useObservable(r.activeRule$,r.activeRule),{unitId:a,subUnitId:i,rule:s}=n||{},d=s.uid,l=b.useDependency(Y.DataValidatorRegistryService),c=b.useDependency(o.IUniverInstanceService),h=b.useDependency(b.ComponentManager),p=b.useDependency(o.ICommandService),u=b.useDependency(Y.DataValidationModel),_=b.useDependency(o.LocaleService),[g,O]=V.useState(s),T=l.getValidatorItem(g.type),[m,C]=V.useState(!1),S=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[y,D]=V.useState(()=>g.ranges.map(I=>({unitId:"",sheetId:"",range:I}))),w=V.useMemo(()=>Mn(p),[p]),[E,F]=V.useState(!1),[x,P]=V.useState(!1),k=V.useRef(null),j=b.useDependency($.SheetsSelectionsService);if(V.useEffect(()=>()=>{const I=j.getCurrentLastSelection();I&&j.setSelections([I])},[j]),V.useEffect(()=>{p.onCommandExecuted(I=>{(I.id===o.UndoCommand.id||I.id===o.RedoCommand.id)&&setTimeout(()=>{const W=u.getRuleById(a,i,d);t(K=>K+1),W&&(O(W),D(W.ranges.map(K=>({unitId:"",sheetId:"",range:K}))))},20)})},[p,u,d,i,a]),!T)return null;const B=T.operators,A=T.operatorNames,X=g.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,z=()=>{var I,W,K;(W=(I=k.current)==null?void 0:I.editor)!=null&&W.isFocus()&&Z((K=k.current)==null?void 0:K.getValue()),!(!g.ranges.length||E)&&(T.validatorFormula(g,a,i).success?r.setActiveRule(null):C(!0))},Z=b.useEvent(I=>{const W=I.split(",").filter(Boolean).map(Ge.deserializeRangeWithSheet).map(ee=>{const Lt=ee.sheetName;if(Lt){const cr=bn(c,ee.unitId,Lt);return{...ee,sheetId:cr}}return{...ee,sheetId:""}});if(o.isUnitRangesEqual(W,y))return;D(W);const K=W.filter(ee=>(!ee.unitId||ee.unitId===a)&&(!ee.sheetId||ee.sheetId===i)).map(ee=>ee.range);if(O({...g,ranges:K}),K.length===0)return;const pe={unitId:a,subUnitId:i,ruleId:d,ranges:K};w(f.UpdateSheetDataValidationRangeCommand.id,pe)}),Q=I=>{if(o.shallowEqual(I,Y.getRuleSetting(g)))return;O({...g,...I});const W={unitId:a,subUnitId:i,ruleId:d,setting:I};w(f.UpdateSheetDataValidationSettingCommand.id,W,void 0)},J=async()=>{await p.executeCommand(f.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:a,subUnitId:i}),r.setActiveRule(null)},re={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},ue=I=>{const W=l.getValidatorItem(I);if(!W)return;const K=W.operators,pe=u.getRuleById(a,i,d),ee=I===(pe==null?void 0:pe.type)||I.includes("list")&&(pe!=null&&pe.type.includes("list"))?{...pe,type:I}:{...g,type:I,operator:K[0],formula1:void 0,formula2:void 0};O(ee),p.executeCommand(f.UpdateSheetDataValidationSettingCommand.id,{unitId:a,subUnitId:i,ruleId:g.uid,setting:Y.getRuleSetting(ee)})},se=h.get(T.formulaInput),ae=V.useMemo(()=>y.map(I=>Ge.serializeRange(I.range)).join(","),[]),le=Y.getRuleOptions(g),ve=I=>{o.shallowEqual(I,Y.getRuleOptions(g))||(O({...g,...I}),w(f.UpdateSheetDataValidationOptionsCommand.id,{unitId:a,subUnitId:i,ruleId:d,options:I}))},he=B.length&&!g.operator;return v.jsxs("div",{className:"univer-py-4",children:[v.jsx(M.FormLayout,{label:_.t("dataValidation.panel.range"),error:!g.ranges.length||E?_.t("dataValidation.panel.rangeError"):"",children:v.jsx(Ke.RangeSelector,{selectorRef:k,unitId:a,subUnitId:i,initialValue:ae,onChange:(I,W)=>{var K;!x&&((K=k.current)!=null&&K.verify())&&Z(W)},onFocusChange:(I,W)=>{var K;P(I),!I&&W&&((K=k.current)!=null&&K.verify())&&Z(W)},onVerify:I=>F(!I)})}),v.jsx(M.FormLayout,{label:_.t("dataValidation.panel.type"),children:v.jsx(M.Select,{className:"univer-w-full",value:g.type,options:(U=S==null?void 0:S.sort((I,W)=>I.order-W.order))==null?void 0:U.map(I=>({label:_.t(I.title),value:I.id})),onChange:ue})}),B!=null&&B.length?v.jsx(M.FormLayout,{label:_.t("dataValidation.panel.operator"),children:v.jsx(M.Select,{className:"univer-w-full",value:`${g.operator}`,options:[{value:"",label:_.t("dataValidation.operators.legal")},...B.map((I,W)=>({value:`${I}`,label:A[W]}))],onChange:I=>{Q({...re,operator:I})}})}):null,se&&!he?v.jsx(se,{isTwoFormula:X,value:{formula1:g.formula1,formula2:g.formula2},onChange:I=>{Q({...re,...I})},showError:m,validResult:T.validatorFormula(g,a,i),unitId:a,subUnitId:i,ruleId:d},e+g.type):null,v.jsx(M.FormLayout,{children:v.jsx(M.Checkbox,{checked:(G=g.allowBlank)!=null?G:!0,onChange:()=>{var I;return Q({...re,allowBlank:!((I=g.allowBlank)==null||I)})},children:_.t("dataValidation.panel.allowBlank")})}),v.jsx(En,{value:le,onChange:ve,extraComponent:T.optionsInput}),v.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[v.jsx(M.Button,{className:"univer-ml-3",onClick:J,children:_.t("dataValidation.panel.removeRule")}),v.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:z,children:_.t("dataValidation.panel.done")})]})]})}const Vn=e=>{const{rule:t,onClick:r,unitId:n,subUnitId:a,disable:i}=e,s=b.useDependency(Y.DataValidatorRegistryService),d=b.useDependency(o.ICommandService),l=b.useDependency(H.IMarkSelectionService),c=s.getValidatorItem(t.type),h=V.useRef(void 0),[p,u]=V.useState(!1),_=b.useDependency(o.ThemeService),g=b.useObservable(_.currentTheme$),O=V.useMemo(()=>{var D;const m=_.getColorFromTheme("primary.600"),C=_.getColorFromTheme("loop-color.2"),S=(D=_.getColorFromTheme(C))!=null?D:m,y=new o.ColorKit(S).toRgb();return{fill:`rgba(${y.r}, ${y.g}, ${y.b}, 0.1)`,stroke:S}},[g]),T=m=>{d.executeCommand(f.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:a}),m.stopPropagation()};return V.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(C=>{C&&l.removeShape(C)}))},[l]),v.jsxs("div",{className:M.clsx(`
34
35
  univer-rounded-md univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border
35
36
  univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between
36
37
  univer-overflow-hidden univer-p-2 univer-pr-9
37
38
  `,{"hover:univer-bg-gray-50":!i,"univer-opacity-50":i}),onClick:r,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(m=>l.addShape({range:m,style:O,primary:null})))},onMouseLeave:()=>{var m;u(!1),(m=h.current)==null||m.forEach(C=>{C&&l.removeShape(C)}),h.current=void 0},children:[v.jsx("div",{className:`
38
- univer-overflow-hidden univer-text-ellipsis univer-text-sm univer-font-medium univer-leading-[22px]
39
- univer-text-gray-900
40
- `,children:c==null?void 0:c.generateRuleName(t)}),v.jsx("div",{className:`
41
- univer-text-secondary univer-overflow-hidden univer-text-ellipsis univer-text-xs univer-leading-[18px]
42
- `,children:t.ranges.map(m=>Ge.serializeRange(m)).join(",")}),p?v.jsx("div",{className:`
39
+ univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900
40
+ dark:univer-text-white
41
+ `,children:c==null?void 0:c.generateRuleName(t)}),v.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px]",children:t.ranges.map(m=>Ge.serializeRange(m)).join(",")}),p?v.jsx("div",{className:`
43
42
  univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-5
44
43
  univer-items-center univer-justify-center univer-rounded
45
44
  hover:univer-bg-gray-200
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-data-validation-ui",
3
- "version": "0.7.0-nightly.202505091607",
3
+ "version": "0.7.0-nightly.202505111606",
4
4
  "private": false,
5
5
  "description": "Data validation UI for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -56,17 +56,17 @@
56
56
  "dependencies": {
57
57
  "@flatten-js/interval-tree": "^1.1.3",
58
58
  "@univerjs/icons": "^0.3.24",
59
- "@univerjs/core": "0.7.0-nightly.202505091607",
60
- "@univerjs/data-validation": "0.7.0-nightly.202505091607",
61
- "@univerjs/design": "0.7.0-nightly.202505091607",
62
- "@univerjs/engine-formula": "0.7.0-nightly.202505091607",
63
- "@univerjs/sheets-data-validation": "0.7.0-nightly.202505091607",
64
- "@univerjs/sheets": "0.7.0-nightly.202505091607",
65
- "@univerjs/engine-render": "0.7.0-nightly.202505091607",
66
- "@univerjs/sheets-formula-ui": "0.7.0-nightly.202505091607",
67
- "@univerjs/sheets-ui": "0.7.0-nightly.202505091607",
68
- "@univerjs/sheets-numfmt": "0.7.0-nightly.202505091607",
69
- "@univerjs/ui": "0.7.0-nightly.202505091607"
59
+ "@univerjs/core": "0.7.0-nightly.202505111606",
60
+ "@univerjs/data-validation": "0.7.0-nightly.202505111606",
61
+ "@univerjs/design": "0.7.0-nightly.202505111606",
62
+ "@univerjs/engine-render": "0.7.0-nightly.202505111606",
63
+ "@univerjs/sheets-data-validation": "0.7.0-nightly.202505111606",
64
+ "@univerjs/sheets": "0.7.0-nightly.202505111606",
65
+ "@univerjs/sheets-numfmt": "0.7.0-nightly.202505111606",
66
+ "@univerjs/sheets-formula-ui": "0.7.0-nightly.202505111606",
67
+ "@univerjs/sheets-ui": "0.7.0-nightly.202505111606",
68
+ "@univerjs/engine-formula": "0.7.0-nightly.202505111606",
69
+ "@univerjs/ui": "0.7.0-nightly.202505111606"
70
70
  },
71
71
  "devDependencies": {
72
72
  "postcss": "^8.5.3",