@univerjs/preset-sheets-data-validation 0.15.4 → 0.15.5
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 +2 -2
- package/package.json +6 -6
package/lib/umd/index.js
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
// @univerjs/sheets-data-validation-ui/index
|
|
14
|
-
(function(U,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/data-validation"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/data-validation","@univerjs/ui","rxjs","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/design","react","react/jsx-runtime","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],o):(U=typeof globalThis<"u"?globalThis:U||self,o(U.UniverSheetsDataValidationUi={},U.UniverCore,U.UniverEngineRender,U.UniverSheets,U.UniverSheetsDataValidation,U.UniverDataValidation,U.UniverUi,U.rxjs,U.UniverSheetsNumfmt,U.UniverSheetsUi,U.UniverDesign,U.React,U.React,U.UniverEngineFormula,U.UniverSheetsFormulaUi))})(this,(function(U,o,O,Y,I,X,M,ae,At,B,E,R,p,Xe,ze){"use strict";var lr=Object.defineProperty;var dr=(U,o,O)=>o in U?lr(U,o,{enumerable:!0,configurable:!0,writable:!0,value:O}):U[o]=O;var P=(U,o,O)=>dr(U,typeof o!="symbol"?o+"":o,O);var Ye;var Lt=Object.getOwnPropertyDescriptor,Pt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Lt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ht=(e,t)=>(n,r)=>t(n,r,e);let de=class extends o.Disposable{constructor(t,n){super();P(this,"_open$",new ae.BehaviorSubject(!1));P(this,"open$",this._open$.pipe(ae.distinctUntilChanged()));P(this,"_activeRule");P(this,"_activeRule$",new ae.BehaviorSubject(void 0));P(this,"activeRule$",this._activeRule$.asObservable());P(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ae.filter(r=>!r)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(r=>{r.id===Ue&&(r.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=Pt([ht(0,o.IUniverInstanceService),ht(1,M.ISidebarService)],de);const ve="#ECECEC",Le="sheets-data-validation-ui.config",Pe={};var Ut=Object.getOwnPropertyDescriptor,Ft=(e,t,n,r)=>{for(var a=r>1?void 0:r?Ut(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ie=(e,t)=>(n,r)=>t(n,r,e);let Ce=class extends o.Disposable{constructor(e,t,n,r,a,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=r,this._localeService=a,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(Y.VALIDATE_CELL,{handler:async(e,t,n)=>{const r=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(r===!1)return n(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,a,i)===o.DataValidationStatus.VALID?n(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:R.createElement(E.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(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:R.createElement(E.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Ce=Ft([Ie(0,o.Inject(Y.SheetInterceptorService)),Ie(1,o.Inject(I.SheetDataValidationModel)),Ie(2,o.Inject(X.DataValidatorRegistryService)),Ie(3,M.IDialogService),Ie(4,o.Inject(o.LocaleService)),Ie(5,o.Inject(I.SheetsDataValidationValidatorService))],Ce);var kt=Object.getOwnPropertyDescriptor,Nt=(e,t,n,r)=>{for(var a=r>1?void 0:r?kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},oe=(e,t)=>(n,r)=>t(n,r,e);const Ke=e=>{if(e==null||typeof e=="boolean")return;if(e==="")return o.dayjs();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 jt(e,t){const n=At.getPatternType(t);if(e===n)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 ge=class extends o.Disposable{constructor(t,n,r,a,i,s,d,l,c,h,f){super();P(this,"_activeDropdown");P(this,"_activeDropdown$",new ae.Subject);P(this,"_currentPopup",null);P(this,"activeDropdown$",this._activeDropdown$.asObservable());P(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=r,this._dataValidationModel=a,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=f,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,n,r,a){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=n?i.getSheetBySheetId(n):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),r,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(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var L,b,w,y,D,A;const{location:n}=t,{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,r,a);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let f;const u=async(m,g)=>{var N,K,G;if(!m)return!0;const C=m,j=l.getCell(r,a),$=C.format(g==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),x=(N=o.numfmt.parseDate($))==null?void 0:N.v,W=g==="time"?x%1:x,T=d.getStyles().getStyleByCell(j),F=(G=(K=T==null?void 0:T.n)==null?void 0:K.pattern)!=null?G:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:W,unitId:i,subUnitId:s,row:r,column:a,worksheet:l,workbook:d,interceptValue:$.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(Y.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:jt(g,F)}}}}),await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:M.KeyCode.ESC}),!0):(this._injector.has(Ce)&&this._injector.get(Ce).showReject(h.getRuleFinalError(c,{row:r,col:a,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case X.DataValidatorDropdownType.DATE:{const m=I.getCellValueOrigin(l.getCellRaw(r,a)),g=Ke(m),C=!!((L=c.bizInfo)!=null&&L.showTime);S={location:n,type:"datepicker",props:{showTime:C,onChange:j=>u(j,C?"datetime":"date"),defaultValue:g,patternType:"date"}};break}case X.DataValidatorDropdownType.TIME:{const m=I.getCellValueOrigin(l.getCellRaw(r,a)),g=Ke(m);S={location:n,type:"datepicker",props:{onChange:C=>u(C,"time"),defaultValue:g,patternType:"time"}};break}case X.DataValidatorDropdownType.DATETIME:{const m=I.getCellValueOrigin(l.getCellRaw(r,a)),g=Ke(m);S={location:n,type:"datepicker",props:{onChange:C=>u(C,"datetime"),defaultValue:g,patternType:"datetime"}};break}case X.DataValidatorDropdownType.LIST:case X.DataValidatorDropdownType.MULTIPLE_LIST:{const m=h.dropdownType===X.DataValidatorDropdownType.MULTIPLE_LIST,g=async T=>{const F=I.serializeListOptions(T),N={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:F,p:null,f:null,si:null}};return this._commandService.executeCommand(Y.SetRangeValuesCommand.id,N),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:M.KeyCode.ESC}),!m},C=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,j=h.getListWithColor(c,i,s),$=I.getDataValidationCellValue(l.getCellRaw(r,a)),x=()=>{this._commandService.executeCommand(fe.id,{ruleId:c.uid}),f==null||f.dispose()},W=j.map(T=>({label:T.label,value:T.label,color:C||T.color?T.color||ve:"transparent"}));S={location:n,type:"list",props:{onChange:T=>g(T),options:W,onEdit:x,defaultValue:$,multiple:m,showEdit:(w=(b=this._configService.getConfig(Le))==null?void 0:b.showEditOnDropdown)!=null?w:!0,showSearch:(D=(y=this._configService.getConfig(Le))==null?void 0:y.showSearchOnDropdown)!=null?D:!0}};break}case X.DataValidatorDropdownType.CASCADE:{S={type:"cascader",props:{onChange:g=>{const C={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:g.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(Y.SetRangeValuesCommand.id,C),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:M.KeyCode.ESC}),!0},defaultValue:I.getDataValidationCellValue(l.getCellRaw(r,a)).split("/"),options:JSON.parse((A=c.formula1)!=null?A:"[]")},location:n};break}case X.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:g=>{const C={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:g,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(Y.SetRangeValuesCommand.id,C),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:M.KeyCode.ESC}),!0},defaultValue:I.getDataValidationCellValue(l.getCellRaw(r,a))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(f=this._cellDropdownManagerService.showDropdown({...S,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!f)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new o.DisposableCollection;v.add(f),v.add({dispose:()=>{var m,g;(g=(m=this._activeDropdown)==null?void 0:m.onHide)==null||g.call(m)}}),this._currentPopup=v}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,r,a,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(n);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),r,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:r,col:a,unitId:t,subUnitId:n},onHide:i})}};ge=Nt([oe(0,o.IUniverInstanceService),oe(1,o.Inject(X.DataValidatorRegistryService)),oe(2,M.IZenZoneService),oe(3,o.Inject(I.SheetDataValidationModel)),oe(4,o.Inject(Y.SheetsSelectionsService)),oe(5,o.Inject(B.ISheetCellDropdownManagerService)),oe(6,o.Inject(I.SheetDataValidationModel)),oe(7,o.ICommandService),oe(8,B.IEditorBridgeService),oe(9,o.Inject(o.Injector)),oe(10,o.IConfigService)],ge);const Ue="DataValidationPanel",fe={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:r}=t,a=e.get(de),i=e.get(X.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(M.ISidebarService),l=Y.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,f=n?i.getRuleById(c,h,n):void 0;a.open(),a.setActiveRule(f&&{unitId:c,subUnitId:h,rule:f});const u=d.open({id:Ue,header:{title:r?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ue},width:312,onClose:()=>a.close()});return a.setCloseDisposable(u),!0}},Ze={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(de).close(),!0}},pt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),n=e.get(de);return n.open(),n.isOpen?t.executeCommand(Ze.id):t.executeCommand(fe.id),!0}},Fe={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(ge),{unitId:r,subUnitId:a,row:i,column:s}=t,d=n.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===r&&l.subUnitId===a&&l.row===i&&l.col===s||n.showDataValidationDropdown(r,a,i,s),!0}},vt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(ge).hideDropdown(),!0):!1}},ke={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),n=Y.getSheetCommandTarget(t);if(!n)return!1;const{workbook:r,worksheet:a}=n,i=I.createDefaultNewRule(e),s=e.get(o.ICommandService),d=r.getUnitId(),l=a.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(I.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(fe.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Bt=Object.getOwnPropertyDescriptor,Wt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Bt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ye=(e,t)=>(n,r)=>t(n,r,e);const me="SHEET_DATA_VALIDATION_ALERT";let Oe=class extends o.Disposable{constructor(e,t,n,r,a,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=r,this._zenZoneService=a,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ae.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),r=n.getSheetBySheetId(e.location.subUnitId);if(!r)return;const a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(me);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:n,worksheet:r})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(me),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(me);return}const l=this._dataValidationModel.getValidator(a.type);if(!l){this._cellAlertManagerService.removeAlert(me);return}this._cellAlertManagerService.showAlert({type:B.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:me});return}}this._cellAlertManagerService.removeAlert(me)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(me)}))}};Oe=Wt([ye(0,o.Inject(B.HoverManagerService)),ye(1,o.Inject(B.CellAlertManagerService)),ye(2,o.IUniverInstanceService),ye(3,o.Inject(o.LocaleService)),ye(4,M.IZenZoneService),ye(5,o.Inject(I.SheetDataValidationModel))],Oe);var $t=Object.getOwnPropertyDescriptor,Ht=(e,t,n,r)=>{for(var a=r>1?void 0:r?$t(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ge=(e,t)=>(n,r)=>t(n,r,e);let we=class extends o.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(r,a)=>{const{source:i,target:s,unitId:d,subUnitId:l}=r,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=B.virtualizeDiscreteRanges([i,s]),[f,u]=h.ranges,{mapFunc:S}=h,v={row:f.startRow,col:f.startColumn},L=B.getAutoFillRepeatRange(f,u),b=new o.ObjectMatrix,w=new Set;L.forEach(g=>{const C=g.repeatStartCell,j=g.relativeRange,$={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},x={startRow:C.row,startColumn:C.col,endColumn:C.col,endRow:C.row};o.Range.foreach(j,(W,T)=>{const F=o.Rectangle.getPositionRange({startRow:W,startColumn:T,endColumn:T,endRow:W},$),{row:N,col:K}=S(F.startRow,F.startColumn),G=this._sheetDataValidationModel.getRuleIdByLocation(d,l,N,K)||"",ee=o.Rectangle.getPositionRange({startRow:W,startColumn:T,endColumn:T,endRow:W},x),{row:Z,col:re}=S(ee.startRow,ee.startColumn);b.setValue(Z,re,G),w.add(G)})});const y=Array.from(w).map(g=>({id:g,ranges:o.queryObjectMatrix(b,C=>C===g)}));c.addRangeRules(y);const D=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:A,undoMutations:m}=I.getDataValidationDiffMutations(d,l,D,this._injector,"patched",a===B.APPLY_TYPE.ONLY_FORMAT);return{undos:m,redos:A}},n={id:I.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:r=>{const{source:a,unitId:i,subUnitId:s}=r;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(B.APPLY_TYPE.SERIES,!0);return}}},onFillData:(r,a,i)=>i===B.APPLY_TYPE.COPY||i===B.APPLY_TYPE.ONLY_FORMAT||i===B.APPLY_TYPE.SERIES?t(r,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};we=Ht([Ge(0,B.IAutoFillService),Ge(1,o.Inject(I.SheetDataValidationModel)),Ge(2,o.Inject(o.Injector))],we);var xt=Object.getOwnPropertyDescriptor,Yt=(e,t,n,r)=>{for(var a=r>1?void 0:r?xt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},qe=(e,t)=>(n,r)=>t(n,r,e);let De=class extends o.Disposable{constructor(t,n,r){super();P(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=r,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:I.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,r)=>this._collect(t,n,r),onPasteCells:(t,n,r,a)=>{const{copyType:i=B.COPY_TYPE.COPY,pasteType:s}=a,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=n;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,n,r){const a=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:a};const i=this._injector.invoke(l=>Y.rangeToDiscreteRange(r,l,t,n));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,f)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);a.setValue(c,f,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===B.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([B.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,B.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,B.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,B.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:a,subUnitId:i}=this._copyInfo;if(n.unitId!==a||i!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:f}=B.virtualizeDiscreteRanges([n.copyRange,t]),u=B.getRepeatRange(c,h,!0),S=new Map;u.forEach(({startRange:w})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((D,A,m)=>{const g=o.Rectangle.getPositionRange({startRow:D,endRow:D,startColumn:A,endColumn:A},w),C=`${i}-${m}`,j=this._sheetDataValidationModel.getRuleById(a,i,m);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,C)&&j&&S.set(C,{...j,uid:C});const{row:$,col:x}=f(g.startRow,g.startColumn);l.add(C),d.setValue($,x,C)})});const v=Array.from(l).map(w=>({id:w,ranges:o.queryObjectMatrix(d,y=>y===w)}));s.addRangeRules(v);const{redoMutations:L,undoMutations:b}=I.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),S.values()),this._injector,"patched",!1);return{redos:L,undos:b}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(a,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:f}=B.virtualizeDiscreteRanges([n.copyRange,t]);B.getRepeatRange(c,h,!0).forEach(({startRange:b})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((y,D,A)=>{const m=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:D,endColumn:D},b),{row:g,col:C}=f(m.startRow,m.startColumn);d.setValue(g,C,A),l.add(A)})});const S=Array.from(l).map(b=>({id:b,ranges:o.queryObjectMatrix(d,w=>w===b)}));s.addRangeRules(S);const{redoMutations:v,undoMutations:L}=I.getDataValidationDiffMutations(a,i,s.diff(this._sheetDataValidationModel.getRules(a,i)),this._injector,"patched",!1);return{redos:v,undos:L}}}};De=Yt([qe(0,B.ISheetClipboardService),qe(1,o.Inject(I.SheetDataValidationModel)),qe(2,o.Inject(o.Injector))],De);var Xt=Object.getOwnPropertyDescriptor,zt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Xt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Je=(e,t)=>(n,r)=>t(n,r,e);let Ee=class extends o.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===I.AddSheetDataValidationCommand.id){const{unitId:t,subUnitId:n,rule:{ranges:r}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}if(e.id===I.UpdateSheetDataValidationRangeCommand.id){const{unitId:t,subUnitId:n,ranges:r}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Ee=zt([Je(0,o.Inject(o.LocaleService)),Je(1,o.ICommandService),Je(2,o.Inject(Y.SheetPermissionCheckController))],Ee);const gt="sheet.menu.data-validation";function Kt(e){return{id:gt,type:M.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:M.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(e,{workbookTypes:[Y.WorkbookEditablePermission],worksheetTypes:[Y.WorksheetSetCellStylePermission,Y.WorksheetEditPermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint]})}}function Zt(e){return{id:fe.id,title:"dataValidation.panel.title",type:M.MenuItemType.BUTTON}}function Gt(e){return{id:ke.id,title:"dataValidation.panel.add",type:M.MenuItemType.BUTTON}}const qt={[M.RibbonDataGroup.RULES]:{[gt]:{order:0,menuItemFactory:Kt,[fe.id]:{order:0,menuItemFactory:Zt},[ke.id]:{order:1,menuItemFactory:Gt}}}};var Jt=Object.getOwnPropertyDescriptor,ft=(e,t,n,r)=>{for(var a=r>1?void 0:r?Jt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},q=(e,t)=>(n,r)=>t(n,r,e);const mt={tr:{size:6,color:"#fe4b4b"}};let Me=class extends o.RxDisposable{constructor(e,t,n,r,a,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,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(qt)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:r,sheetId:a,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(r);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(r,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 f=this._dropdownManagerService.activeDropdown,u=f==null?void 0:f.location;if(u&&u.unitId===r&&u.subUnitId===a&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:r,subUnitId:a,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var w,y,D,A,m;const{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,r,a);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return n(e);const f=(w=this._dataValidationCacheService.getValue(i,s,r,a))!=null?w:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=t.rawData;let v;const L={get value(){var g;return v!==void 0||(v=(g=I.getCellValueOrigin(S))!=null?g:null),v}},b={get value(){var g;return`${(g=L.value)!=null?g:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...f===o.DataValidationStatus.INVALID?mt:null},e.customRender=[...(y=e==null?void 0:e.customRender)!=null?y:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((D=e==null?void 0:e.fontRenderExtension)==null?void 0:D.isSkip)||((A=u==null?void 0:u.skipDefaultFontRender)==null?void 0:A.call(u,h,L.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,b.value,{get style(){const g=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?g.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},r,a)},e.interceptorAutoHeight=()=>{var $,x,W,T,F,N;const g=(x=($=this._renderManagerService.getRenderById(i))==null?void 0:$.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!g)return;const C=g.worksheet.getMergedCell(r,a),j={data:e,style:g.getStyles().getStyleByCell(e),primaryWithCoord:g.getCellWithCoordByIndex((W=C==null?void 0:C.startRow)!=null?W:r,(T=C==null?void 0:C.startColumn)!=null?T:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(N=(F=u==null?void 0:u.canvasRender)==null?void 0:F.calcCellAutoHeight)==null?void 0:N.call(F,j)},e.interceptorAutoWidth=()=>{var $,x,W,T,F,N;const g=(x=($=this._renderManagerService.getRenderById(i))==null?void 0:$.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!g)return;const C=g.worksheet.getMergedCell(r,a),j={data:e,style:g.getStyles().getStyleByCell(e),primaryWithCoord:g.getCellWithCoordByIndex((W=C==null?void 0:C.startRow)!=null?W:r,(T=C==null?void 0:C.startColumn)!=null?T:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(N=(F=u==null?void 0:u.canvasRender)==null?void 0:F.calcCellAutoWidth)==null?void 0:N.call(F,j)},e.coverable=((m=e==null?void 0:e.coverable)!=null?m:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var r;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(r=n.rule)!=null&&r.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};Me=ft([q(0,o.ICommandService),q(1,M.IMenuManagerService),q(2,O.IRenderManagerService),q(3,o.IUniverInstanceService),q(4,o.Inject(B.AutoHeightController)),q(5,o.Inject(ge)),q(6,o.Inject(I.SheetDataValidationModel)),q(7,o.Inject(X.DataValidatorRegistryService)),q(8,o.Inject(Y.SheetInterceptorService)),q(9,o.Inject(I.DataValidationCacheService)),q(10,o.Optional(B.IEditorBridgeService))],Me);let St=class extends o.RxDisposable{constructor(e,t,n,r,a,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=r,this._sheetInterceptorService=a,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var b,w,y,D,A;const{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,r,a);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return n(e);const f=(b=this._dataValidationCacheService.getValue(i,s,r,a))!=null?b:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=l.getCellRaw(r,a),v=I.getCellValueOrigin(S),L=`${v!=null?v:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...f===o.DataValidationStatus.INVALID?mt:null},e.customRender=[...(w=e==null?void 0:e.customRender)!=null?w:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,v,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,L,{get style(){const m=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?m.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},r,a)},e.interceptorAutoHeight=()=>{var j,$,x,W,T,F;const m=($=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!m)return;const g=m.worksheet.getMergedCell(r,a),C={data:e,style:m.getStyles().getStyleByCell(e),primaryWithCoord:m.getCellWithCoordByIndex((x=g==null?void 0:g.startRow)!=null?x:r,(W=g==null?void 0:g.startColumn)!=null?W:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(F=(T=u==null?void 0:u.canvasRender)==null?void 0:T.calcCellAutoHeight)==null?void 0:F.call(T,C)},e.interceptorAutoWidth=()=>{var j,$,x,W,T,F;const m=($=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!m)return;const g=m.worksheet.getMergedCell(r,a),C={data:e,style:m.getStyles().getStyleByCell(e),primaryWithCoord:m.getCellWithCoordByIndex((x=g==null?void 0:g.startRow)!=null?x:r,(W=g==null?void 0:g.startColumn)!=null?W:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(F=(T=u==null?void 0:u.canvasRender)==null?void 0:T.calcCellAutoWidth)==null?void 0:F.call(T,C)},e.coverable=((A=e==null?void 0:e.coverable)!=null?A:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var r;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(r=n.rule)!=null&&r.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};St=ft([q(0,o.ICommandService),q(1,O.IRenderManagerService),q(2,o.Inject(B.AutoHeightController)),q(3,o.Inject(X.DataValidatorRegistryService)),q(4,o.Inject(Y.SheetInterceptorService)),q(5,o.Inject(I.SheetDataValidationModel)),q(6,o.Inject(I.DataValidationCacheService))],St);var Qt=Object.getOwnPropertyDescriptor,en=(e,t,n,r)=>{for(var a=r>1?void 0:r?Qt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},_t=(e,t)=>(n,r)=>t(n,r,e);let Ne=class extends o.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var r;if(!t.length)return;const n=new Set;t.forEach(a=>{n.add(a.subUnitId)}),n.forEach(a=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(a))==null||i.skeleton.makeDirty(!0)}),(r=this._context.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};Ne=en([_t(1,o.Inject(I.SheetDataValidationModel)),_t(2,o.Inject(B.SheetSkeletonManagerService))],Ne);function Se({ref:e,...t}){const{icon:n,id:r,className:a,extend:i,...s}=t,d=`univerjs-icon univerjs-icon-${r} ${a||""}`.trim(),l=R.useRef(`_${rn()}`);return It(n,`${r}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:d,...s},i)}function It(e,t,n,r,a){return R.createElement(e.tag,{key:t,...tn(e,n,a),...r},(nn(e,n).children||[]).map((i,s)=>It(i,`${t}-${e.tag}-${s}`,n,void 0,a)))}function tn(e,t,n){const r={...e.attrs};n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),e.tag==="mask"&&r.id&&(r.id=r.id+t.idSuffix),Object.entries(r).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(r[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:a}=t;return!a||a.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(([i,s])=>{typeof s=="string"&&(r[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function nn(e,t){var r;const{defIds:n}=t;return!n||n.length===0?e:e.tag==="defs"&&((r=e.children)!=null&&r.length)?{...e,children:e.children.map(a=>typeof a.attrs.id=="string"&&n&&n.includes(a.attrs.id)?{...a,attrs:{...a.attrs,id:a.attrs.id+t.idSuffix}}:a)}:e}function rn(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";const an={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062C8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767L13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217L14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046C13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703L10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046C9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217L9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746C9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732L13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ct=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"data-validation-icon",ref:n,icon:an}))});Ct.displayName="DataValidationIcon";const on={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Qe=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"delete-icon",ref:n,icon:on}))});Qe.displayName="DeleteIcon";const sn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},yt=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"increase-icon",ref:n,icon:sn}))});yt.displayName="IncreaseIcon";const ln={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},et=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"more-down-icon",ref:n,icon:ln}))});et.displayName="MoreDownIcon";const dn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},wt=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"more-up-icon",ref:n,icon:dn}))});wt.displayName="MoreUpIcon";const cn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},Dt=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"sequence-icon",ref:n,icon:cn}))});Dt.displayName="SequenceIcon";function un(e){var c;const t=M.useDependency(o.LocaleService),n=M.useDependency(M.ComponentManager),{value:r,onChange:a,extraComponent:i}=e,[s,d]=R.useState(!1),l=i?n.get(i):null;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?p.jsx(wt,{className:"univer-ml-1"}):p.jsx(et,{className:"univer-ml-1"})]}),s&&p.jsxs(p.Fragment,{children:[l?p.jsx(l,{value:r,onChange:a}):null,p.jsx(E.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:p.jsxs(E.RadioGroup,{value:`${(c=r.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>a({...r,errorStyle:+h}),children:[p.jsx(E.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),p.jsx(E.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),p.jsx(E.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:p.jsx(E.Checkbox,{checked:r.showErrorMessage,onChange:()=>a({...r,showErrorMessage:!r.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),r.showErrorMessage?p.jsx(E.FormLayout,{children:p.jsx(E.Input,{value:r.error,onChange:h=>a({...r,error:h})})}):null]})]})}const hn=e=>o.debounce(async(t,n,r,a)=>{const i=await e.executeCommand(t,n,r);a==null||a(i)},1e3);function pn(e,t,n){var r,a,i,s;return t?((a=(r=e.getUnit(t))==null?void 0:r.getSheetBySheetName(n))==null?void 0:a.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function vn(){var V,H;const[e,t]=R.useState(0),n=M.useDependency(de),r=M.useObservable(n.activeRule$,n.activeRule),{unitId:a,subUnitId:i,rule:s}=r||{},d=s.uid,l=M.useDependency(X.DataValidatorRegistryService),c=M.useDependency(o.IUniverInstanceService),h=M.useDependency(M.ComponentManager),f=M.useDependency(o.ICommandService),u=M.useDependency(X.DataValidationModel),S=M.useDependency(o.LocaleService),[v,L]=R.useState(s),b=l.getValidatorItem(v.type),[w,y]=R.useState(!1),D=l.getValidatorsByScope(X.DataValidatorRegistryScope.SHEET),[A,m]=R.useState(()=>v.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),g=R.useMemo(()=>hn(f),[f]),[C,j]=R.useState(!1),[$,x]=R.useState(!1),W=R.useRef(null),T=M.useDependency(Y.SheetsSelectionsService);if(R.useEffect(()=>()=>{const _=T.getCurrentLastSelection();_&&T.setSelections([_])},[T]),R.useEffect(()=>{f.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const k=u.getRuleById(a,i,d);t(z=>z+1),k&&(L(k),m(k.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[f,u,d,i,a]),!b)return null;const F=b.operators,N=b.operatorNames,K=v.operator?X.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,G=()=>{var _,k,z;(k=(_=W.current)==null?void 0:_.editor)!=null&&k.isFocus()&&ee((z=W.current)==null?void 0:z.getValue()),!(!v.ranges.length||C)&&(b.validatorFormula(v,a,i).success?n.setActiveRule(null):y(!0))},ee=M.useEvent(_=>{const k=_.split(",").filter(Boolean).map(Xe.deserializeRangeWithSheet).map(ne=>{const Ot=ne.sheetName;if(Ot){const sr=pn(c,ne.unitId,Ot);return{...ne,sheetId:sr}}return{...ne,sheetId:""}});if(o.isUnitRangesEqual(k,A))return;m(k);const z=k.filter(ne=>(!ne.unitId||ne.unitId===a)&&(!ne.sheetId||ne.sheetId===i)).map(ne=>ne.range);if(L({...v,ranges:z}),z.length===0)return;const le={unitId:a,subUnitId:i,ruleId:d,ranges:z};g(I.UpdateSheetDataValidationRangeCommand.id,le)}),Z=_=>{if(o.shallowEqual(_,X.getRuleSetting(v)))return;L({...v,..._});const k={unitId:a,subUnitId:i,ruleId:d,setting:_};g(I.UpdateSheetDataValidationSettingCommand.id,k,void 0)},re=async()=>{await f.executeCommand(I.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:a,subUnitId:i}),n.setActiveRule(null)},ie={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},he=_=>{const k=l.getValidatorItem(_);if(!k)return;const z=k.operators,le=u.getRuleById(a,i,d),ne=_===(le==null?void 0:le.type)||_.includes("list")&&(le!=null&&le.type.includes("list"))?{...le,type:_}:{...v,type:_,operator:z[0],formula1:void 0,formula2:void 0};L(ne),f.executeCommand(I.UpdateSheetDataValidationSettingCommand.id,{unitId:a,subUnitId:i,ruleId:v.uid,setting:X.getRuleSetting(ne)})},pe=h.get(b.formulaInput),te=R.useMemo(()=>A.map(_=>Xe.serializeRange(_.range)).join(","),[]),J=X.getRuleOptions(v),ce=_=>{o.shallowEqual(_,X.getRuleOptions(v))||(L({...v,..._}),g(I.UpdateSheetDataValidationOptionsCommand.id,{unitId:a,subUnitId:i,ruleId:d,options:_}))},Q=F.length&&!v.operator;return p.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[p.jsx(E.FormLayout,{label:S.t("dataValidation.panel.range"),error:!v.ranges.length||C?S.t("dataValidation.panel.rangeError"):"",children:p.jsx(ze.RangeSelector,{selectorRef:W,unitId:a,subUnitId:i,initialValue:te,onChange:(_,k)=>{var z;!$&&((z=W.current)!=null&&z.verify())&&ee(k)},onFocusChange:(_,k)=>{var z;x(_),!_&&k&&((z=W.current)!=null&&z.verify())&&ee(k)},onVerify:_=>j(!_)})}),p.jsx(E.FormLayout,{label:S.t("dataValidation.panel.type"),children:p.jsx(E.Select,{className:"univer-w-full",value:v.type,options:(V=D==null?void 0:D.sort((_,k)=>_.order-k.order))==null?void 0:V.map(_=>({label:S.t(_.title),value:_.id})),onChange:he})}),F!=null&&F.length?p.jsx(E.FormLayout,{label:S.t("dataValidation.panel.operator"),children:p.jsx(E.Select,{className:"univer-w-full",value:`${v.operator}`,options:[{value:"",label:S.t("dataValidation.operators.legal")},...F.map((_,k)=>({value:`${_}`,label:N[k]}))],onChange:_=>{Z({...ie,operator:_})}})}):null,pe&&!Q?p.jsx(pe,{isTwoFormula:K,value:{formula1:v.formula1,formula2:v.formula2},onChange:_=>{Z({...ie,..._})},showError:w,validResult:b.validatorFormula(v,a,i),unitId:a,subUnitId:i,ruleId:d},e+v.type):null,p.jsx(E.FormLayout,{children:p.jsx(E.Checkbox,{checked:(H=v.allowBlank)!=null?H:!0,onChange:()=>{var _;return Z({...ie,allowBlank:!((_=v.allowBlank)==null||_)})},children:S.t("dataValidation.panel.allowBlank")})}),p.jsx(un,{value:J,onChange:ce,extraComponent:b.optionsInput}),p.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[p.jsx(E.Button,{className:"univer-ml-3",onClick:re,children:S.t("dataValidation.panel.removeRule")}),p.jsx(E.Button,{className:"univer-ml-3",variant:"primary",onClick:G,children:S.t("dataValidation.panel.done")})]})]})}const gn=e=>{const{rule:t,onClick:n,unitId:r,subUnitId:a,disable:i}=e,s=M.useDependency(X.DataValidatorRegistryService),d=M.useDependency(o.ICommandService),l=M.useDependency(B.IMarkSelectionService),c=s.getValidatorItem(t.type),h=R.useRef(void 0),[f,u]=R.useState(!1),S=M.useDependency(o.ThemeService),v=M.useObservable(S.currentTheme$),L=R.useMemo(()=>{var m;const w=S.getColorFromTheme("primary.600"),y=S.getColorFromTheme("loop-color.2"),D=(m=S.getColorFromTheme(y))!=null?m:w,A=new o.ColorKit(D).toRgb();return{fill:`rgba(${A.r}, ${A.g}, ${A.b}, 0.1)`,stroke:D}},[v]),b=w=>{d.executeCommand(I.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:r,subUnitId:a}),w.stopPropagation()};return R.useEffect(()=>()=>{var w;h.current&&((w=h.current)==null||w.forEach(y=>{y&&l.removeShape(y)}))},[l]),p.jsxs("div",{className:E.clsx(`
|
|
14
|
+
(function(U,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/data-validation"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/data-validation","@univerjs/ui","rxjs","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/design","react","react/jsx-runtime","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],o):(U=typeof globalThis<"u"?globalThis:U||self,o(U.UniverSheetsDataValidationUi={},U.UniverCore,U.UniverEngineRender,U.UniverSheets,U.UniverSheetsDataValidation,U.UniverDataValidation,U.UniverUi,U.rxjs,U.UniverSheetsNumfmt,U.UniverSheetsUi,U.UniverDesign,U.React,U.React,U.UniverEngineFormula,U.UniverSheetsFormulaUi))})(this,(function(U,o,O,k,_,X,E,oe,Ut,x,M,R,p,Ze,Ge){"use strict";var ur=Object.defineProperty;var hr=(U,o,O)=>o in U?ur(U,o,{enumerable:!0,configurable:!0,writable:!0,value:O}):U[o]=O;var P=(U,o,O)=>hr(U,typeof o!="symbol"?o+"":o,O);var Ke;var Ft=Object.getOwnPropertyDescriptor,Nt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Ft(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},gt=(e,t)=>(n,r)=>t(n,r,e);let ue=class extends o.Disposable{constructor(t,n){super();P(this,"_open$",new oe.BehaviorSubject(!1));P(this,"open$",this._open$.pipe(oe.distinctUntilChanged()));P(this,"_activeRule");P(this,"_activeRule$",new oe.BehaviorSubject(void 0));P(this,"activeRule$",this._activeRule$.asObservable());P(this,"_closeDisposable",null);P(this,"_focusFormulaEditorActiveRuleSubUnitId",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(oe.filter(r=>!r)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(r=>{r.id===ke&&(r.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)}setFocusFormulaEditorActiveRuleSubUnitId(t){this._focusFormulaEditorActiveRuleSubUnitId=t}getFocusFormulaEditorActiveRuleSubUnitId(){return this._focusFormulaEditorActiveRuleSubUnitId}};ue=Nt([gt(0,o.IUniverInstanceService),gt(1,E.ISidebarService)],ue);const me="#ECECEC",Fe="sheets-data-validation-ui.config",Ne={};var kt=Object.getOwnPropertyDescriptor,jt=(e,t,n,r)=>{for(var a=r>1?void 0:r?kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},we=(e,t)=>(n,r)=>t(n,r,e);let Ee=class extends o.Disposable{constructor(e,t,n,r,a,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=r,this._localeService=a,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(k.VALIDATE_CELL,{handler:async(e,t,n)=>{const r=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(r===!1)return n(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,a,i)===o.DataValidationStatus.VALID?n(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:R.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")}}),n(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:R.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")}})}};Ee=jt([we(0,o.Inject(k.SheetInterceptorService)),we(1,o.Inject(_.SheetDataValidationModel)),we(2,o.Inject(X.DataValidatorRegistryService)),we(3,E.IDialogService),we(4,o.Inject(o.LocaleService)),we(5,o.Inject(_.SheetsDataValidationValidatorService))],Ee);var Bt=Object.getOwnPropertyDescriptor,Wt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Bt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},he=(e,t)=>(n,r)=>t(n,r,e);const qe=e=>{if(e==null||typeof e=="boolean")return;if(e==="")return o.dayjs();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 $t(e,t){const n=Ut.getPatternType(t);if(e===n)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 Se=class extends o.Disposable{constructor(t,n,r,a,i,s,d,l,c,h,v){super();P(this,"_activeDropdown");P(this,"_activeDropdown$",new oe.Subject);P(this,"_currentPopup",null);P(this,"activeDropdown$",this._activeDropdown$.asObservable());P(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=r,this._dataValidationModel=a,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=v,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,n,r,a){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=n?i.getSheetBySheetId(n):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),r,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(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var L,m,y,I,D,A;const{location:n}=t,{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,r,a);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let v;const u=async(f,g)=>{var Y,$,K;if(!f)return!0;const C=f,F=l.getCell(r,a),j=C.format(g==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),B=(Y=o.numfmt.parseDate(j))==null?void 0:Y.v,W=g==="time"?B%1:B,T=d.getStyles().getStyleByCell(F),N=(K=($=T==null?void 0:T.n)==null?void 0:$.pattern)!=null?K:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:W,unitId:i,subUnitId:s,row:r,column:a,worksheet:l,workbook:d,interceptValue:j.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(k.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:$t(g,N)}}}}),await this._commandService.executeCommand(x.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0):(this._injector.has(Ee)&&this._injector.get(Ee).showReject(h.getRuleFinalError(c,{row:r,col:a,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case X.DataValidatorDropdownType.DATE:{const f=_.getCellValueOrigin(l.getCellRaw(r,a)),g=qe(f),C=!!((L=c.bizInfo)!=null&&L.showTime);S={location:n,type:"datepicker",props:{showTime:C,onChange:F=>u(F,C?"datetime":"date"),defaultValue:g,patternType:"date"}};break}case X.DataValidatorDropdownType.TIME:{const f=_.getCellValueOrigin(l.getCellRaw(r,a)),g=qe(f);S={location:n,type:"datepicker",props:{onChange:C=>u(C,"time"),defaultValue:g,patternType:"time"}};break}case X.DataValidatorDropdownType.DATETIME:{const f=_.getCellValueOrigin(l.getCellRaw(r,a)),g=qe(f);S={location:n,type:"datepicker",props:{onChange:C=>u(C,"datetime"),defaultValue:g,patternType:"datetime"}};break}case X.DataValidatorDropdownType.LIST:case X.DataValidatorDropdownType.MULTIPLE_LIST:{const f=h.dropdownType===X.DataValidatorDropdownType.MULTIPLE_LIST,g=async T=>{const N=_.serializeListOptions(T),Y={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:N,p:null,f:null,si:null}};return this._commandService.executeCommand(k.SetRangeValuesCommand.id,Y),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(x.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!f},C=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,F=h.getListWithColor(c,i,s),j=_.getDataValidationCellValue(l.getCellRaw(r,a)),B=()=>{this._commandService.executeCommand(_e.id,{ruleId:c.uid}),v==null||v.dispose()},W=F.map(T=>({label:T.label,value:T.label,color:C||T.color?T.color||me:"transparent"}));S={location:n,type:"list",props:{onChange:T=>g(T),options:W,onEdit:B,defaultValue:j,multiple:f,showEdit:(y=(m=this._configService.getConfig(Fe))==null?void 0:m.showEditOnDropdown)!=null?y:!0,showSearch:(D=(I=this._configService.getConfig(Fe))==null?void 0:I.showSearchOnDropdown)!=null?D:!0}};break}case X.DataValidatorDropdownType.CASCADE:{S={type:"cascader",props:{onChange:g=>{const C={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:g.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(k.SetRangeValuesCommand.id,C),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(x.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(r,a)).split("/"),options:JSON.parse((A=c.formula1)!=null?A:"[]")},location:n};break}case X.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:g=>{const C={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:g,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(k.SetRangeValuesCommand.id,C),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(x.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(r,a))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(v=this._cellDropdownManagerService.showDropdown({...S,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!v)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const w=new o.DisposableCollection;w.add(v),w.add({dispose:()=>{var f,g;(g=(f=this._activeDropdown)==null?void 0:f.onHide)==null||g.call(f)}}),this._currentPopup=w}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,r,a,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(n);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),r,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:r,col:a,unitId:t,subUnitId:n},onHide:i})}};Se=Wt([he(0,o.IUniverInstanceService),he(1,o.Inject(X.DataValidatorRegistryService)),he(2,E.IZenZoneService),he(3,o.Inject(_.SheetDataValidationModel)),he(4,o.Inject(k.SheetsSelectionsService)),he(5,o.Inject(x.ISheetCellDropdownManagerService)),he(6,o.Inject(_.SheetDataValidationModel)),he(7,o.ICommandService),he(8,x.IEditorBridgeService),he(9,o.Inject(o.Injector)),he(10,o.IConfigService)],Se);const ke="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:r}=t,a=e.get(ue),i=e.get(X.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(E.ISidebarService),l=k.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,v=n?i.getRuleById(c,h,n):void 0;a.open(),a.setActiveRule(v&&{unitId:c,subUnitId:h,rule:v});const u=d.open({id:ke,header:{title:r?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:ke},width:312,onClose:()=>a.close()});return a.setCloseDisposable(u),!0}},Je={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},ft={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),n=e.get(ue);return n.open(),n.isOpen?t.executeCommand(Je.id):t.executeCommand(_e.id),!0}},je={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(Se),{unitId:r,subUnitId:a,row:i,column:s}=t,d=n.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===r&&l.subUnitId===a&&l.row===i&&l.col===s||n.showDataValidationDropdown(r,a,i,s),!0}},mt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(Se).hideDropdown(),!0):!1}},Be={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),n=k.getSheetCommandTarget(t);if(!n)return!1;const{workbook:r,worksheet:a}=n,i=_.createDefaultNewRule(e),s=e.get(o.ICommandService),d=r.getUnitId(),l=a.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(_.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(_e.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Ht=Object.getOwnPropertyDescriptor,xt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Ht(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},De=(e,t)=>(n,r)=>t(n,r,e);const Ie="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends o.Disposable{constructor(e,t,n,r,a,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=r,this._zenZoneService=a,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(oe.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),r=n.getSheetBySheetId(e.location.subUnitId);if(!r)return;const a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(Ie);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:n,worksheet:r})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Ie),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(Ie);return}const l=this._dataValidationModel.getValidator(a.type);if(!l){this._cellAlertManagerService.removeAlert(Ie);return}this._cellAlertManagerService.showAlert({type:x.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:Ie});return}}this._cellAlertManagerService.removeAlert(Ie)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Ie)}))}};Pe=xt([De(0,o.Inject(x.HoverManagerService)),De(1,o.Inject(x.CellAlertManagerService)),De(2,o.IUniverInstanceService),De(3,o.Inject(o.LocaleService)),De(4,E.IZenZoneService),De(5,o.Inject(_.SheetDataValidationModel))],Pe);var Yt=Object.getOwnPropertyDescriptor,Xt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Yt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Qe=(e,t)=>(n,r)=>t(n,r,e);let Me=class extends o.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(r,a)=>{const{source:i,target:s,unitId:d,subUnitId:l}=r,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=x.virtualizeDiscreteRanges([i,s]),[v,u]=h.ranges,{mapFunc:S}=h,w={row:v.startRow,col:v.startColumn},L=k.AutoFillTools.getAutoFillRepeatRange(v,u),m=new o.ObjectMatrix,y=new Set;L.forEach(g=>{const C=g.repeatStartCell,F=g.relativeRange,j={startRow:w.row,startColumn:w.col,endColumn:w.col,endRow:w.row},B={startRow:C.row,startColumn:C.col,endColumn:C.col,endRow:C.row};o.Range.foreach(F,(W,T)=>{const N=o.Rectangle.getPositionRange({startRow:W,startColumn:T,endColumn:T,endRow:W},j),{row:Y,col:$}=S(N.startRow,N.startColumn),K=this._sheetDataValidationModel.getRuleIdByLocation(d,l,Y,$)||"",ae=o.Rectangle.getPositionRange({startRow:W,startColumn:T,endColumn:T,endRow:W},B),{row:G,col:se}=S(ae.startRow,ae.startColumn);m.setValue(G,se,K),y.add(K)})});const I=Array.from(y).map(g=>({id:g,ranges:o.queryObjectMatrix(m,C=>C===g)}));c.addRangeRules(I);const D=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:A,undoMutations:f}=_.getDataValidationDiffMutations(d,l,D,this._injector,"patched",a===k.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT);return{undos:f,redos:A}},n={id:_.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:r=>{const{source:a,unitId:i,subUnitId:s}=r;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(k.AUTO_FILL_APPLY_TYPE.SERIES,!0);return}}},onFillData:(r,a,i)=>i===k.AUTO_FILL_APPLY_TYPE.COPY||i===k.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||i===k.AUTO_FILL_APPLY_TYPE.SERIES?t(r,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Me=Xt([Qe(0,k.IAutoFillService),Qe(1,o.Inject(_.SheetDataValidationModel)),Qe(2,o.Inject(o.Injector))],Me);var zt=Object.getOwnPropertyDescriptor,Kt=(e,t,n,r)=>{for(var a=r>1?void 0:r?zt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},et=(e,t)=>(n,r)=>t(n,r,e);let be=class extends o.Disposable{constructor(t,n,r){super();P(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=r,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:_.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,r)=>this._collect(t,n,r),onPasteCells:(t,n,r,a)=>{const{copyType:i=x.COPY_TYPE.COPY,pasteType:s}=a,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=n;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,n,r){const a=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:a};const i=this._injector.invoke(l=>k.rangeToDiscreteRange(r,l,t,n));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,v)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);a.setValue(c,v,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===x.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([x.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,x.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,x.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,x.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:a,subUnitId:i}=this._copyInfo;if(n.unitId!==a||i!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:v}=x.virtualizeDiscreteRanges([n.copyRange,t]),u=x.getRepeatRange(c,h,!0),S=new Map;u.forEach(({startRange:y})=>{var I;(I=this._copyInfo)==null||I.matrix.forValue((D,A,f)=>{const g=o.Rectangle.getPositionRange({startRow:D,endRow:D,startColumn:A,endColumn:A},y),C=`${i}-${f}`,F=this._sheetDataValidationModel.getRuleById(a,i,f);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,C)&&F&&S.set(C,{...F,uid:C});const{row:j,col:B}=v(g.startRow,g.startColumn);l.add(C),d.setValue(j,B,C)})});const w=Array.from(l).map(y=>({id:y,ranges:o.queryObjectMatrix(d,I=>I===y)}));s.addRangeRules(w);const{redoMutations:L,undoMutations:m}=_.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),S.values()),this._injector,"patched",!1);return{redos:L,undos:m}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(a,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:v}=x.virtualizeDiscreteRanges([n.copyRange,t]);x.getRepeatRange(c,h,!0).forEach(({startRange:m})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((I,D,A)=>{const f=o.Rectangle.getPositionRange({startRow:I,endRow:I,startColumn:D,endColumn:D},m),{row:g,col:C}=v(f.startRow,f.startColumn);d.setValue(g,C,A),l.add(A)})});const S=Array.from(l).map(m=>({id:m,ranges:o.queryObjectMatrix(d,y=>y===m)}));s.addRangeRules(S);const{redoMutations:w,undoMutations:L}=_.getDataValidationDiffMutations(a,i,s.diff(this._sheetDataValidationModel.getRules(a,i)),this._injector,"patched",!1);return{redos:w,undos:L}}}};be=Kt([et(0,x.ISheetClipboardService),et(1,o.Inject(_.SheetDataValidationModel)),et(2,o.Inject(o.Injector))],be);var Zt=Object.getOwnPropertyDescriptor,Gt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Zt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},tt=(e,t)=>(n,r)=>t(n,r,e);let Te=class extends o.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===_.AddSheetDataValidationCommand.id){const{unitId:t,subUnitId:n,rule:{ranges:r}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[k.WorkbookEditablePermission],rangeTypes:[k.RangeProtectionPermissionEditPoint],worksheetTypes:[k.WorksheetEditPermission,k.WorksheetSetCellStylePermission]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}if(e.id===_.UpdateSheetDataValidationRangeCommand.id){const{unitId:t,subUnitId:n,ranges:r}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[k.WorkbookEditablePermission],rangeTypes:[k.RangeProtectionPermissionEditPoint],worksheetTypes:[k.WorksheetEditPermission,k.WorksheetSetCellStylePermission]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Te=Gt([tt(0,o.Inject(o.LocaleService)),tt(1,o.ICommandService),tt(2,o.Inject(k.SheetPermissionCheckController))],Te);const St="sheet.menu.data-validation";function qt(e){return{id:St,type:E.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:E.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:x.getCurrentRangeDisable$(e,{workbookTypes:[k.WorkbookEditablePermission],worksheetTypes:[k.WorksheetSetCellStylePermission,k.WorksheetEditPermission],rangeTypes:[k.RangeProtectionPermissionEditPoint]})}}function Jt(e){return{id:_e.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function Qt(e){return{id:Be.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const en={[E.RibbonDataGroup.RULES]:{[St]:{order:0,menuItemFactory:qt,[_e.id]:{order:0,menuItemFactory:Jt},[Be.id]:{order:1,menuItemFactory:Qt}}}};var tn=Object.getOwnPropertyDescriptor,_t=(e,t,n,r)=>{for(var a=r>1?void 0:r?tn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},q=(e,t)=>(n,r)=>t(n,r,e);const It={tr:{size:6,color:"#fe4b4b"}};let Re=class extends o.RxDisposable{constructor(e,t,n,r,a,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,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(en)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:r,sheetId:a,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(r);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(r,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 v=this._dropdownManagerService.activeDropdown,u=v==null?void 0:v.location;if(u&&u.unitId===r&&u.subUnitId===a&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:r,subUnitId:a,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(k.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:k.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var y,I,D,A,f;const{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,r,a);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return n(e);const v=(y=this._dataValidationCacheService.getValue(i,s,r,a))!=null?y:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=t.rawData;let w;const L={get value(){var g;return w!==void 0||(w=(g=_.getCellValueOrigin(S))!=null?g:null),w}},m={get value(){var g;return`${(g=L.value)!=null?g:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.DataValidationStatus.INVALID?It:null},e.customRender=[...(I=e==null?void 0:e.customRender)!=null?I:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((D=e==null?void 0:e.fontRenderExtension)==null?void 0:D.isSkip)||((A=u==null?void 0:u.skipDefaultFontRender)==null?void 0:A.call(u,h,L.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,m.value,{get style(){const g=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?g.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},r,a)},e.interceptorAutoHeight=()=>{var j,B,W,T,N,Y;const g=(B=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(x.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!g)return;const C=g.worksheet.getMergedCell(r,a),F={data:e,style:g.getStyles().getStyleByCell(e),primaryWithCoord:g.getCellWithCoordByIndex((W=C==null?void 0:C.startRow)!=null?W:r,(T=C==null?void 0:C.startColumn)!=null?T:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(Y=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoHeight)==null?void 0:Y.call(N,F)},e.interceptorAutoWidth=()=>{var j,B,W,T,N,Y;const g=(B=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(x.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!g)return;const C=g.worksheet.getMergedCell(r,a),F={data:e,style:g.getStyles().getStyleByCell(e),primaryWithCoord:g.getCellWithCoordByIndex((W=C==null?void 0:C.startRow)!=null?W:r,(T=C==null?void 0:C.startColumn)!=null?T:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(Y=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoWidth)==null?void 0:Y.call(N,F)},e.coverable=((f=e==null?void 0:e.coverable)!=null?f:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var r;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(r=n.rule)!=null&&r.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};Re=_t([q(0,o.ICommandService),q(1,E.IMenuManagerService),q(2,O.IRenderManagerService),q(3,o.IUniverInstanceService),q(4,o.Inject(x.AutoHeightController)),q(5,o.Inject(Se)),q(6,o.Inject(_.SheetDataValidationModel)),q(7,o.Inject(X.DataValidatorRegistryService)),q(8,o.Inject(k.SheetInterceptorService)),q(9,o.Inject(_.DataValidationCacheService)),q(10,o.Optional(x.IEditorBridgeService))],Re);let Ct=class extends o.RxDisposable{constructor(e,t,n,r,a,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=r,this._sheetInterceptorService=a,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(k.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:k.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var m,y,I,D,A;const{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,r,a);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return n(e);const v=(m=this._dataValidationCacheService.getValue(i,s,r,a))!=null?m:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=l.getCellRaw(r,a),w=_.getCellValueOrigin(S),L=`${w!=null?w:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.DataValidationStatus.INVALID?It:null},e.customRender=[...(y=e==null?void 0:e.customRender)!=null?y:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((I=e==null?void 0:e.fontRenderExtension)==null?void 0:I.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,w,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,L,{get style(){const f=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?f.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},r,a)},e.interceptorAutoHeight=()=>{var F,j,B,W,T,N;const f=(j=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(x.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:j.skeleton;if(!f)return;const g=f.worksheet.getMergedCell(r,a),C={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex((B=g==null?void 0:g.startRow)!=null?B:r,(W=g==null?void 0:g.startColumn)!=null?W:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(N=(T=u==null?void 0:u.canvasRender)==null?void 0:T.calcCellAutoHeight)==null?void 0:N.call(T,C)},e.interceptorAutoWidth=()=>{var F,j,B,W,T,N;const f=(j=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(x.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:j.skeleton;if(!f)return;const g=f.worksheet.getMergedCell(r,a),C={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex((B=g==null?void 0:g.startRow)!=null?B:r,(W=g==null?void 0:g.startColumn)!=null?W:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(N=(T=u==null?void 0:u.canvasRender)==null?void 0:T.calcCellAutoWidth)==null?void 0:N.call(T,C)},e.coverable=((A=e==null?void 0:e.coverable)!=null?A:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var r;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(r=n.rule)!=null&&r.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};Ct=_t([q(0,o.ICommandService),q(1,O.IRenderManagerService),q(2,o.Inject(x.AutoHeightController)),q(3,o.Inject(X.DataValidatorRegistryService)),q(4,o.Inject(k.SheetInterceptorService)),q(5,o.Inject(_.SheetDataValidationModel)),q(6,o.Inject(_.DataValidationCacheService))],Ct);var nn=Object.getOwnPropertyDescriptor,rn=(e,t,n,r)=>{for(var a=r>1?void 0:r?nn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},yt=(e,t)=>(n,r)=>t(n,r,e);let We=class extends o.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var r;if(!t.length)return;const n=new Set;t.forEach(a=>{n.add(a.subUnitId)}),n.forEach(a=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(a))==null||i.skeleton.makeDirty(!0)}),(r=this._context.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};We=rn([yt(1,o.Inject(_.SheetDataValidationModel)),yt(2,o.Inject(x.SheetSkeletonManagerService))],We);function Ce({ref:e,...t}){const{icon:n,id:r,className:a,extend:i,...s}=t,d=`univerjs-icon univerjs-icon-${r} ${a||""}`.trim(),l=R.useRef(`_${sn()}`);return wt(n,`${r}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:d,...s},i)}function wt(e,t,n,r,a){return R.createElement(e.tag,{key:t,...an(e,n,a),...r},(on(e,n).children||[]).map((i,s)=>wt(i,`${t}-${e.tag}-${s}`,n,void 0,a)))}function an(e,t,n){const r={...e.attrs};n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),e.tag==="mask"&&r.id&&(r.id=r.id+t.idSuffix),Object.entries(r).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(r[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:a}=t;return!a||a.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(([i,s])=>{typeof s=="string"&&(r[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function on(e,t){var r;const{defIds:n}=t;return!n||n.length===0?e:e.tag==="defs"&&((r=e.children)!=null&&r.length)?{...e,children:e.children.map(a=>typeof a.attrs.id=="string"&&n&&n.includes(a.attrs.id)?{...a,attrs:{...a.attrs,id:a.attrs.id+t.idSuffix}}:a)}:e}function sn(){return Math.random().toString(36).substring(2,8)}Ce.displayName="UniverIcon";const ln={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062C8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767L13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217L14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046C13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703L10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046C9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217L9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746C9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732L13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Et=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"data-validation-icon",ref:n,icon:ln}))});Et.displayName="DataValidationIcon";const dn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},nt=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"delete-icon",ref:n,icon:dn}))});nt.displayName="DeleteIcon";const cn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},Dt=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"increase-icon",ref:n,icon:cn}))});Dt.displayName="IncreaseIcon";const un={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},rt=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"more-down-icon",ref:n,icon:un}))});rt.displayName="MoreDownIcon";const hn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Mt=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"more-up-icon",ref:n,icon:hn}))});Mt.displayName="MoreUpIcon";const pn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},bt=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"sequence-icon",ref:n,icon:pn}))});bt.displayName="SequenceIcon";function vn(e){var c;const t=E.useDependency(o.LocaleService),n=E.useDependency(E.ComponentManager),{value:r,onChange:a,extraComponent:i}=e,[s,d]=R.useState(!1),l=i?n.get(i):null;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?p.jsx(Mt,{className:"univer-ml-1"}):p.jsx(rt,{className:"univer-ml-1"})]}),s&&p.jsxs(p.Fragment,{children:[l?p.jsx(l,{value:r,onChange:a}):null,p.jsx(M.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:p.jsxs(M.RadioGroup,{value:`${(c=r.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>a({...r,errorStyle:+h}),children:[p.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),p.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),p.jsx(M.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:p.jsx(M.Checkbox,{checked:r.showErrorMessage,onChange:()=>a({...r,showErrorMessage:!r.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),r.showErrorMessage?p.jsx(M.FormLayout,{children:p.jsx(M.Input,{value:r.error,onChange:h=>a({...r,error:h})})}):null]})]})}const gn=e=>o.debounce(async(t,n,r,a)=>{const i=await e.executeCommand(t,n,r);a==null||a(i)},1e3);function fn(e,t,n){var r,a,i,s;return t?((a=(r=e.getUnit(t))==null?void 0:r.getSheetBySheetName(n))==null?void 0:a.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function mn(){var H,te;const[e,t]=R.useState(0),n=E.useDependency(ue),r=E.useObservable(n.activeRule$,n.activeRule),{unitId:a,subUnitId:i,rule:s}=r||{},d=s.uid,l=E.useDependency(X.DataValidatorRegistryService),c=E.useDependency(o.IUniverInstanceService),h=E.useDependency(E.ComponentManager),v=E.useDependency(o.ICommandService),u=E.useDependency(X.DataValidationModel),S=E.useDependency(o.LocaleService),w=E.useObservable(()=>c.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),L=E.useObservable(()=>{var b;return(b=w==null?void 0:w.activeSheet$)!=null?b:oe.of(null)},void 0,void 0,[]),[m,y]=R.useState(s),I=l.getValidatorItem(m.type),[D,A]=R.useState(!1),f=l.getValidatorsByScope(X.DataValidatorRegistryScope.SHEET),[g,C]=R.useState(()=>m.ranges.map(b=>({unitId:"",sheetId:"",range:b}))),F=R.useMemo(()=>gn(v),[v]),[j,B]=R.useState(!1),[W,T]=R.useState(!1),N=R.useRef(null),Y=E.useDependency(k.SheetsSelectionsService);if(R.useEffect(()=>()=>{const b=Y.getCurrentLastSelection();b&&Y.setSelections([b])},[Y]),R.useEffect(()=>{v.onCommandExecuted(b=>{(b.id===o.UndoCommand.id||b.id===o.RedoCommand.id)&&setTimeout(()=>{const Z=u.getRuleById(a,i,d);t(J=>J+1),Z&&(y(Z),C(Z.ranges.map(J=>({unitId:"",sheetId:"",range:J}))))},20)})},[v,u,d,i,a]),!I)return null;const $=I.operators,K=I.operatorNames,ae=m.operator?X.TWO_FORMULA_OPERATOR_COUNT.includes(m.operator):!1,G=()=>{(L==null?void 0:L.getSheetId())!==i&&v.syncExecuteCommand(k.SetWorksheetActiveOperation.id,{unitId:a,subUnitId:i})},se=()=>{var b,Z,J;(Z=(b=N.current)==null?void 0:b.editor)!=null&&Z.isFocus()&&le((J=N.current)==null?void 0:J.getValue()),!(!m.ranges.length||j)&&(I.validatorFormula(m,a,i).success?n.setActiveRule(null):A(!0),G())},le=E.useEvent(b=>{const Z=b.split(",").filter(Boolean).map(Ze.deserializeRangeWithSheet).map(ie=>{const Pt=ie.sheetName;if(Pt){const cr=fn(c,ie.unitId,Pt);return{...ie,sheetId:cr}}return{...ie,sheetId:""}});if(o.isUnitRangesEqual(Z,g))return;C(Z);const J=Z.filter(ie=>(!ie.unitId||ie.unitId===a)&&(!ie.sheetId||ie.sheetId===i)).map(ie=>ie.range);if(y({...m,ranges:J}),J.length===0)return;const ge={unitId:a,subUnitId:i,ruleId:d,ranges:J};F(_.UpdateSheetDataValidationRangeCommand.id,ge)}),de=b=>{if(o.shallowEqual(b,X.getRuleSetting(m)))return;y({...m,...b});const Z={unitId:a,subUnitId:i,ruleId:d,setting:b};F(_.UpdateSheetDataValidationSettingCommand.id,Z,void 0)},fe=async()=>{await v.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:a,subUnitId:i}),n.setActiveRule(null),G()},ne={type:m.type,operator:m.operator,formula1:m.formula1,formula2:m.formula2,allowBlank:m.allowBlank},Q=b=>{const Z=l.getValidatorItem(b);if(!Z)return;const J=Z.operators,ge=u.getRuleById(a,i,d),ie=b===(ge==null?void 0:ge.type)||b.includes("list")&&(ge!=null&&ge.type.includes("list"))?{...ge,type:b}:{...m,type:b,operator:J[0],formula1:void 0,formula2:void 0};y(ie),v.executeCommand(_.UpdateSheetDataValidationSettingCommand.id,{unitId:a,subUnitId:i,ruleId:m.uid,setting:X.getRuleSetting(ie)})},ce=h.get(I.formulaInput),re=R.useMemo(()=>g.map(b=>Ze.serializeRange(b.range)).join(","),[]),ee=X.getRuleOptions(m),V=b=>{o.shallowEqual(b,X.getRuleOptions(m))||(y({...m,...b}),F(_.UpdateSheetDataValidationOptionsCommand.id,{unitId:a,subUnitId:i,ruleId:d,options:b}))},z=$.length&&!m.operator;return p.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[p.jsx(M.FormLayout,{label:S.t("dataValidation.panel.range"),error:!m.ranges.length||j?S.t("dataValidation.panel.rangeError"):"",children:p.jsx(Ge.RangeSelector,{selectorRef:N,unitId:a,subUnitId:i,initialValue:re,onChange:(b,Z)=>{var J;!W&&((J=N.current)!=null&&J.verify())&&le(Z)},onFocusChange:(b,Z)=>{var J;T(b),!b&&Z&&((J=N.current)!=null&&J.verify())&&le(Z)},onVerify:b=>B(!b)})}),p.jsx(M.FormLayout,{label:S.t("dataValidation.panel.type"),children:p.jsx(M.Select,{className:"univer-w-full",value:m.type,options:(H=f==null?void 0:f.sort((b,Z)=>b.order-Z.order))==null?void 0:H.map(b=>({label:S.t(b.title),value:b.id})),onChange:Q})}),$!=null&&$.length?p.jsx(M.FormLayout,{label:S.t("dataValidation.panel.operator"),children:p.jsx(M.Select,{className:"univer-w-full",value:`${m.operator}`,options:[{value:"",label:S.t("dataValidation.operators.legal")},...$.map((b,Z)=>({value:`${b}`,label:K[Z]}))],onChange:b=>{de({...ne,operator:b})}})}):null,ce&&!z?p.jsx(ce,{isTwoFormula:ae,value:{formula1:m.formula1,formula2:m.formula2},onChange:b=>{de({...ne,...b})},showError:D,validResult:I.validatorFormula(m,a,i),unitId:a,subUnitId:i,ruleId:d},e+m.type):null,p.jsx(M.FormLayout,{children:p.jsx(M.Checkbox,{checked:(te=m.allowBlank)!=null?te:!0,onChange:()=>{var b;return de({...ne,allowBlank:!((b=m.allowBlank)==null||b)})},children:S.t("dataValidation.panel.allowBlank")})}),p.jsx(vn,{value:ee,onChange:V,extraComponent:I.optionsInput}),p.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[p.jsx(M.Button,{className:"univer-ml-3",onClick:fe,children:S.t("dataValidation.panel.removeRule")}),p.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:se,children:S.t("dataValidation.panel.done")})]})]})}const Sn=e=>{const{rule:t,onClick:n,unitId:r,subUnitId:a,disable:i}=e,s=E.useDependency(X.DataValidatorRegistryService),d=E.useDependency(o.ICommandService),l=E.useDependency(x.IMarkSelectionService),c=s.getValidatorItem(t.type),h=R.useRef(void 0),[v,u]=R.useState(!1),S=E.useDependency(o.ThemeService),w=E.useObservable(S.currentTheme$),L=R.useMemo(()=>{var f;const y=S.getColorFromTheme("primary.600"),I=S.getColorFromTheme("loop-color.2"),D=(f=S.getColorFromTheme(I))!=null?f:y,A=new o.ColorKit(D).toRgb();return{fill:`rgba(${A.r}, ${A.g}, ${A.b}, 0.1)`,stroke:D}},[w]),m=y=>{d.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:r,subUnitId:a}),y.stopPropagation()};return R.useEffect(()=>()=>{var y;h.current&&((y=h.current)==null||y.forEach(I=>{I&&l.removeShape(I)}))},[l]),p.jsxs("div",{className:M.clsx(`
|
|
15
15
|
univer-bg-secondary univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px]
|
|
16
16
|
univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md
|
|
17
17
|
univer-p-2 univer-pr-9
|
|
18
|
-
`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:n,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(w=>l.addShape({range:w,style:L,primary:null})))},onMouseLeave:()=>{var w;u(!1),(w=h.current)==null||w.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[p.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:c==null?void 0:c.generateRuleName(t)}),p.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(w=>Xe.serializeRange(w)).join(",")}),f?p.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-size-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",onClick:b,children:p.jsx(Qe,{})}):null]})};function fn(e){const t=M.useDependency(I.SheetDataValidationModel),n=M.useDependency(o.IUniverInstanceService),r=M.useDependency(o.ICommandService),a=M.useDependency(o.Injector),i=M.useDependency(de),s=M.useDependency(o.LocaleService),[d,l]=R.useState([]),{workbook:c}=e,h=M.useObservable(c.activeSheet$,void 0,!0),f=c.getUnitId(),u=h==null?void 0:h.getSheetId();R.useEffect(()=>{l(t.getRules(f,u));const y=t.ruleChange$.subscribe(D=>{D.unitId===f&&D.subUnitId===u&&l(t.getRules(f,u))});return()=>{y.unsubscribe()}},[f,u,t]);const S=async()=>{const y=I.createDefaultNewRule(a),D={unitId:f,subUnitId:u,rule:y};await r.executeCommand(I.AddSheetDataValidationCommand.id,D),i.setActiveRule({unitId:f,subUnitId:u,rule:y})},v=()=>{r.executeCommand(I.RemoveSheetAllDataValidationCommand.id,{unitId:f,subUnitId:u})},b=(y=>{const D=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet(),m=D.getUnitId(),g=A.getSheetId();return y.map(j=>Y.checkRangesEditablePermission(a,m,g,j.ranges)?{...j}:{...j,disable:!0})})(d),w=b==null?void 0:b.some(y=>y.disable);return p.jsxs("div",{className:"univer-pb-4",children:[b==null?void 0:b.map(y=>{var D;return p.jsx(gn,{unitId:f,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:f,subUnitId:u,rule:y})},rule:y,disable:(D=y.disable)!=null?D:!1},y.uid)}),p.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!w?p.jsx(E.Button,{onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,p.jsx(E.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const mn=()=>{const e=M.useDependency(de),t=M.useObservable(e.activeRule$,e.activeRule),n=M.useDependency(o.IUniverInstanceService),r=M.useObservable(()=>n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),a=M.useObservable(()=>{var i;return(i=r==null?void 0:r.activeSheet$)!=null?i:ae.of(null)},void 0,void 0,[]);return!r||!a?null:t&&t.subUnitId===a.getSheetId()?p.jsx(vn,{},t.rule.uid):p.jsx(fn,{workbook:r})},Sn=e=>{const{isTwoFormula:t=!1,value:n,onChange:r,showError:a,validResult:i}=e,s=M.useDependency(o.LocaleService),d=a?i==null?void 0:i.formula1:"",l=a?i==null?void 0:i.formula2:"";return t?p.jsxs(p.Fragment,{children:[p.jsx(E.FormLayout,{error:d,children:p.jsx(E.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{r==null||r({...n,formula1:c})}})}),p.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),p.jsx(E.FormLayout,{error:l,children:p.jsx(E.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:c=>{r==null||r({...n,formula2:c})}})})]}):p.jsx(E.FormLayout,{error:d,children:p.jsx(E.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{r==null||r({formula1:c})}})})};function _n(e){const{value:t,onChange:n,showError:r,validResult:a}=e,i=M.useDependency(o.LocaleService),s=r?a==null?void 0:a.formula1:"",d=r?a==null?void 0:a.formula2:"",[l,c]=R.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return p.jsxs(p.Fragment,{children:[p.jsx(E.FormLayout,{children:p.jsx(E.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?p.jsx(E.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:p.jsx(E.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?p.jsx(E.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:p.jsx(E.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function In(e){var f;const{unitId:t,subUnitId:n,value:r,onChange:a,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=R.useRef(null),[c,h]=R.useState(!1);return M.useSidebarClick(u=>{var v;(v=l.current)!=null&&v.isClickOutSide(u)&&h(!1)}),p.jsx(E.FormLayout,{error:d,children:p.jsx(ze.FormulaEditor,{ref:l,className:E.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",E.borderClassName),initValue:(f=r==null?void 0:r.formula1)!=null?f:"=",unitId:t,subUnitId:n,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(r==null?void 0:r.formula1)&&(a==null||a({...r,formula1:S}))},onFocus:()=>h(!0)})})}const Cn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],yn=e=>{const{value:t,onChange:n,disabled:r}=e,[a,i]=R.useState(!1);return p.jsx(E.Dropdown,{align:"start",disabled:r,open:a,onOpenChange:i,overlay:p.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:Cn.map(s=>p.jsx("div",{className:E.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",E.borderClassName),style:{background:s},onClick:()=>{n(s),i(!1)}},s))}),children:p.jsxs("div",{className:E.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white",E.borderClassName),children:[p.jsx("div",{className:"univer-box-border univer-size-4 univer-rounded univer-text-base",style:{background:t}}),p.jsx(et,{})]})})},Et=e=>{const{item:t,commonProps:n,className:r}=e,{onItemChange:a,onItemDelete:i}=n;return p.jsxs("div",{className:E.clsx("univer-flex univer-items-center univer-gap-2",r),children:[!t.isRef&&p.jsx("div",{className:E.clsx("univer-cursor-move","draggableHandle"),children:p.jsx(Dt,{})}),p.jsx(yn,{value:t.color,onChange:s=>{a(t.id,t.label,s)}}),p.jsx(E.Input,{disabled:t.isRef,value:t.label,onChange:s=>{a(t.id,s,t.color)}}),t.isRef?null:p.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:p.jsx(Qe,{onClick:()=>i(t.id)})})]})};function wn(e){const{value:t,onChange:n=()=>{},unitId:r,subUnitId:a,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,f]=R.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=R.useState(h==="1"?l:"="),[v,L]=R.useState(h==="1"?l:"="),b=M.useDependency(o.LocaleService),w=M.useDependency(X.DataValidatorRegistryService),y=M.useDependency(X.DataValidationModel),D=M.useDependency(I.DataValidationFormulaController),[A,m]=R.useState(()=>c.split(",")),g=w.getValidatorItem(o.DataValidationType.LIST),[C,j]=R.useState([]),[$,x]=R.useState(""),W=s?i==null?void 0:i.formula1:"",T=R.useMemo(()=>y.ruleChange$.pipe(ae.debounceTime(16)),[]),F=M.useObservable(T),N=M.useEvent(n);R.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const V=y.getRuleById(r,a,d),H=V==null?void 0:V.formula1;if(o.isFormulaString(H)&&g&&V){const _=await g.getListAsync(V,r,a);j(_)}})()},[y,F,g,d,a,r]),R.useEffect(()=>{o.isFormulaString(l)&&l!==v&&(S(l),L(v))},[v,l]);const[K,G]=R.useState(()=>{const V=h!=="1"?I.deserializeListOptions(l):[],H=c.split(",");return V.map((_,k)=>({label:_,color:H[k]||ve,isRef:!1,id:o.generateRandomId(4)}))}),ee=(V,H,_)=>{const k=K.find(z=>z.id===V);k&&(k.label=H,k.color=_,G([...K]))},Z=V=>{const H=K.findIndex(_=>_.id===V);H!==-1&&(K.splice(H,1),G([...K]))},re=c.split(","),ie=R.useMemo(()=>C.map((V,H)=>({label:V,color:re[H]||ve,id:`${H}`,isRef:!0})),[re,C]),he=(V,H,_)=>{const k=[...A];k[+V]=_,m(k),N({formula1:l,formula2:k.join(",")})},pe=()=>{G([...K,{label:"",color:ve,isRef:!1,id:o.generateRandomId(4)}])};R.useEffect(()=>{if(h==="1")return;const V=new Set,H=[];K.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:k})=>{k.forEach(z=>{V.has(z)||(V.add(z),H.push({label:z,color:_.color}))})}),N({formula1:I.serializeListOptions(H.map(_=>_.label)),formula2:H.map(_=>_.color===ve?"":_.color).join(",")})},[K,N,h,v,A]);const te=M.useEvent(async V=>{if(!o.isFormulaString(V)){N==null||N({formula1:"",formula2:c});return}D.getFormulaRefCheck(V)?(N==null||N({formula1:o.isFormulaString(V)?V:"",formula2:c}),x("")):(N==null||N({formula1:"",formula2:c}),S("="),x(b.t("dataValidation.validFail.formulaError")))}),J=R.useRef(null),[ce,Q]=R.useState(!1);return M.useSidebarClick(V=>{var _;(_=J.current)!=null&&_.isClickOutSide(V)&&Q(!1)}),p.jsxs(p.Fragment,{children:[p.jsx(E.FormLayout,{label:b.t("dataValidation.list.options"),children:p.jsxs(E.RadioGroup,{value:h,onChange:V=>{f(V),S(v),V==="1"&&N({formula1:v==="="?"":v,formula2:A.join(",")})},children:[p.jsx(E.Radio,{value:"0",children:b.t("dataValidation.list.customOptions")}),p.jsx(E.Radio,{value:"1",children:b.t("dataValidation.list.refOptions")})]})}),h==="1"?p.jsxs(E.FormLayout,{error:W||$||void 0,children:[p.jsx(ze.FormulaEditor,{ref:J,className:E.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",E.borderClassName),initValue:u,unitId:r,subUnitId:a,isFocus:ce,isSupportAcrossSheet:!0,onFocus:()=>Q(!0),onChange:(V="")=>{const H=(V!=null?V:"").trim();L(H),te(H)}}),ie.length>0&&p.jsx("div",{className:"univer-mt-3",children:ie.map(V=>p.jsx(Et,{className:"univer-mb-3",item:V,commonProps:{onItemChange:he}},V.id))})]}):p.jsx(E.FormLayout,{error:W,children:p.jsxs("div",{className:"-univer-mt-3",children:[p.jsx(E.DraggableList,{list:K,onListChange:G,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:V=>p.jsx(Et,{item:V,commonProps:{onItemChange:ee,onItemDelete:Z}},V.id),idKey:"id"}),p.jsxs("a",{className:"univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800",onClick:pe,children:[p.jsx(yt,{className:"univer-mr-1"}),b.t("dataValidation.list.add")]})]})})]})}const Dn=[[I.CUSTOM_FORMULA_INPUT_NAME,In],[I.BASE_FORMULA_INPUT_NAME,Sn],[I.LIST_FORMULA_INPUT_NAME,wn],[I.CHECKBOX_FORMULA_INPUT_NAME,_n]],En="LIST_RENDER_MODE_OPTION_INPUT";function je(e){var a;const{value:t,onChange:n}=e,r=M.useDependency(o.LocaleService);return p.jsx(E.FormLayout,{label:r.t("dataValidation.renderMode.label"),children:p.jsxs(E.RadioGroup,{value:`${(a=t.renderMode)!=null?a:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>n({...t,renderMode:+i}),children:[p.jsx(E.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:r.t("dataValidation.renderMode.chip")}),p.jsx(E.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:r.t("dataValidation.renderMode.arrow")}),p.jsx(E.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:r.t("dataValidation.renderMode.text")})]})})}je.componentKey=En;const Mn="DATE_SHOW_TIME_OPTION";function Be(e){var a;const{value:t,onChange:n}=e,r=M.useDependency(o.LocaleService);return p.jsx(E.FormLayout,{children:p.jsx(E.Checkbox,{checked:(a=t.bizInfo)==null?void 0:a.showTime,onChange:i=>{n({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:r.t("dataValidation.showTime.label")})})}Be.componentKey=Mn;var bn=Object.getOwnPropertyDescriptor,Tn=(e,t,n,r)=>{for(var a=r>1?void 0:r?bn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},be=(e,t)=>(n,r)=>t(n,r,e);const We=6;let tt=class{constructor(e,t,n,r,a,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=r,this._renderManagerService=a,this._dataValidationModel=i}_calc(e,t){var c,h,f;const{vt:n,ht:r}=t||{},a=e.endX-e.startX-We*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(n){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(r){case o.HorizontalAlign.LEFT:d=We;break;case o.HorizontalAlign.RIGHT:d=We+(a-s);break;default:d=We+(a-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((f=t==null?void 0:t.fs)!=null?f:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var c,h,f,u,S,v,L,b,w;const{formula1:r=I.CHECKBOX_FORMULA_1,formula2:a=I.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=I.getFormulaResult((f=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:f[0]),d=I.getFormulaResult((v=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:v[0]),l=I.isLegalFormulaResult(String(s))&&I.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(r)?I.getFormulaResult((w=(b=(L=i==null?void 0:i[0])==null?void 0:L.result)==null?void 0:b[0])==null?void 0:w[0]):r,formula2:o.isFormulaString(a)?d:a,isFormulaValid:l}}drawWith(e,t){var W,T,F,N;const{style:n,primaryWithCoord:r,unitId:a,subUnitId:i,worksheet:s,row:d,col:l}=t,c=r.isMergedMainCell?r.mergeInfo:r,h=I.getCellValueOrigin(s.getCellRaw(d,l)),f=this._dataValidationModel.getRuleByLocation(a,i,d,l);if(!f)return;const u=this._dataValidationModel.getValidator(f.type);if(!u||!((W=u.skipDefaultFontRender)!=null&&W.call(u,f,h,{unitId:a,subUnitId:i,row:d,column:l})))return;const S=u.parseFormulaSync(f,a,i),{formula1:v}=S,L=this._calc(c,n),{a:b,d:w}=e.getTransform(),y=O.fixLineWidthByScale(L.left,b),D=O.fixLineWidthByScale(L.top,w),A=O.Transform.create().composeMatrix({left:y,top:D,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),m=c.endX-c.startX,g=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,m,g),e.clip();const C=A.getMatrix();e.transform(C[0],C[1],C[2],C[3],C[4],C[5]);const j=((T=n==null?void 0:n.fs)!=null?T:10)*1.6,$=String(h)===String(v),x=this._themeService.getColorFromTheme("primary.600");O.CheckboxShape.drawWith(e,{checked:$,width:j,height:j,fill:(N=(F=n==null?void 0:n.cl)==null?void 0:F.rgb)!=null?N:x}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,r=this._calc(n,t.style),a=r.top,i=r.top+r.height,s=r.left,d=r.left+r.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=a}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:n,unitId:r,subUnitId:a,worksheet:i,row:s,col:d}=e,l=I.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(r,a,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,c,l,{unitId:r,subUnitId:a,row:s,column:d})))return;const{formula1:f,formula2:u}=await this._parseFormula(c,r,a),S={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===I.transformCheckboxValue(String(f))?u:f,p:null}};this._commandService.executeCommand(Y.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.DEFAULT)}};tt=Tn([be(0,o.ICommandService),be(1,o.IUniverInstanceService),be(2,o.Inject(I.DataValidationFormulaService)),be(3,o.Inject(o.ThemeService)),be(4,o.Inject(O.IRenderManagerService)),be(5,o.Inject(I.SheetDataValidationModel))],tt);var Vn=Object.getOwnPropertyDescriptor,Rn=(e,t,n,r)=>{for(var a=r>1?void 0:r?Vn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},On=(e,t)=>(n,r)=>t(n,r,e);U.BaseSheetDataValidatorView=class{constructor(t){P(this,"canvasRender",null);P(this,"dropdownType");P(this,"optionsInput");P(this,"formulaInput",I.LIST_FORMULA_INPUT_NAME);this.injector=t}},U.BaseSheetDataValidatorView=Rn([On(0,o.Inject(o.Injector))],U.BaseSheetDataValidatorView);class An extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.CHECKBOX);P(this,"canvasRender",this.injector.createInstance(tt));P(this,"formulaInput",I.CHECKBOX_FORMULA_INPUT_NAME)}}class Ln extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.CUSTOM);P(this,"formulaInput",I.CUSTOM_FORMULA_INPUT_NAME)}}const Pn="data-validation.formula-input";class Un extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.DATE);P(this,"formulaInput",Pn);P(this,"optionsInput",Be.componentKey);P(this,"dropdownType",X.DataValidatorDropdownType.DATE)}}class Fn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.DECIMAL);P(this,"formulaInput",I.BASE_FORMULA_INPUT_NAME)}}const Mt=4,kn=0,nt=4,bt=4,rt=6,$e=6,_e=14;function Nn(e,t){const n=O.FontCache.getTextSize(e,t),r=n.width+Mt*2,{ba:a,bd:i}=n,s=a+i;return{width:r,height:s+kn*2,ba:a}}function at(e,t,n,r){const a=_e+rt*2,i=n-a,s=r-$e*2,d=e.map(u=>({layout:Nn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:S}=u,{width:v,height:L}=S;!l||l.width+v+nt>i?(l={width:v,height:L,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+nt}),l.width=l.width+v+nt)});let h=0,f=0;return c.forEach((u,S)=>{f=Math.max(f,u.width),S===c.length-1?h+=u.height:h+=u.height+bt}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+$e*2,calcAutoWidth:f+a}}const jn=8;class Bn extends O.Shape{static drawWith(t,n){const{fontString:r,info:a,fill:i,color:s}=n,{layout:d,text:l}=a;t.save(),O.Rect.drawWith(t,{width:d.width,height:d.height,radius:jn,fill:i||ve}),t.translateWithPrecision(Mt,d.ba),t.font=r,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Wn=Object.getOwnPropertyDescriptor,$n=(e,t,n,r)=>{for(var a=r>1?void 0:r?Wn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},He=(e,t)=>(n,r)=>t(n,r,e);const Hn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let it=class{constructor(e,t,n,r){P(this,"zIndex");P(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,r,a){const i=n-_e+4;let s=4;switch(a){case o.VerticalAlign.MIDDLE:s=(r-_e)/2+4;break;case o.VerticalAlign.BOTTOM:s=r-_e+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Hn),e.restore()}drawWith(e,t,n,r){var ie,he;const{primaryWithCoord:a,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=a.isMergedMainCell?a.mergeInfo:a,f=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:v=0,downOffset:L=0}=f||{},b=this._ensureMap(c),w=this._generateKey(i,s),y=a.isMergedMainCell?a.mergeInfo.startRow:i,D=a.isMergedMainCell?a.mergeInfo.startColumn:s,A=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,y,D);if(!A)return;const m=this._dataValidationModel.getValidator(A.type);if(!m)return;const g={startX:h.startX+u,endX:h.endX-S,startY:h.startY+v,endY:h.endY-L},C=g.endX-g.startX,j=g.endY-g.startY,{cl:$}=d||{},x=(ie=typeof $=="object"?$==null?void 0:$.rgb:$)!=null?ie:"#000",W=O.getFontStyleString(d!=null?d:void 0),{vt:T,ht:F}=d||{},N=T!=null?T:o.VerticalAlign.MIDDLE,K=(he=I.getCellValueOrigin(l))!=null?he:"",G=m.parseCellValue(K),ee=m.getListWithColorMap(A),Z=at(G,W,C,j);this._drawDownIcon(e,g,C,j,N),e.save(),e.translateWithPrecision(g.startX,g.startY),e.beginPath(),e.rect(0,0,C-_e,j),e.clip(),e.translateWithPrecision(rt,$e);let re=0;switch(N){case o.VerticalAlign.MIDDLE:re=(Z.contentHeight-Z.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:re=Z.contentHeight-Z.totalHeight;break}e.translateWithPrecision(0,re),Z.lines.forEach((pe,te)=>{e.save();const{width:J,height:ce,items:Q}=pe;let V=0;switch(F){case o.HorizontalAlign.RIGHT:V=Z.contentWidth-J;break;case o.HorizontalAlign.CENTER:V=(Z.contentWidth-J)/2;break}e.translate(V,te*(ce+bt)),Q.forEach(H=>{e.save(),e.translateWithPrecision(H.left,0),Bn.drawWith(e,{...W,info:H,color:x,fill:ee[H.text]}),e.restore()}),e.restore()}),e.restore(),b.set(w,{left:g.startX,top:g.startY,width:Z.contentWidth+rt+_e,height:Z.contentHeight+$e*2})}calcCellAutoHeight(e){var m;const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=r==null?void 0:r.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},f=t.isMergedMainCell?t.mergeInfo:t,u={startX:f.startX+d,endX:f.endX-l,startY:f.startY+c,endY:f.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const L=u.endX-u.startX,b=u.endY-u.startY,w=(m=I.getCellValueOrigin(r))!=null?m:"",y=v.parseCellValue(w),D=O.getFontStyleString(n!=null?n:void 0);return at(y,D,L,b).cellAutoHeight}calcCellAutoWidth(e){var m;const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=r==null?void 0:r.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},f=t.isMergedMainCell?t.mergeInfo:t,u={startX:f.startX+d,endX:f.endX-l,startY:f.startY+c,endY:f.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const L=u.endX-u.startX,b=u.endY-u.startY,w=(m=I.getCellValueOrigin(r))!=null?m:"",y=v.parseCellValue(w),D=O.getFontStyleString(n!=null?n:void 0);return at(y,D,L,b).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,r=n.isMergedMainCell?n.mergeInfo:n,{endX:a}=r,{x:i}=e;return i>=a-_e&&i<=a}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:r,row:a,col:i}=e,s={unitId:n,subUnitId:r,row:a,column:i};this._commandService.executeCommand(Fe.id,s)}onPointerEnter(e,t){var n,r;return(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;return(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:r.setCursor(O.CURSOR_TYPE.DEFAULT)}};it=$n([He(0,o.ICommandService),He(1,o.IUniverInstanceService),He(2,o.Inject(O.IRenderManagerService)),He(3,o.Inject(I.SheetDataValidationModel))],it);class xn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.LIST_MULTIPLE);P(this,"canvasRender",this.injector.createInstance(it));P(this,"dropdownType",X.DataValidatorDropdownType.MULTIPLE_LIST)}}var Yn=Object.getOwnPropertyDescriptor,Xn=(e,t,n,r)=>{for(var a=r>1?void 0:r?Yn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ae=(e,t)=>(n,r)=>t(n,r,e);const Te=4,xe=4,se=14,ot=1,ue=6,Ve=3,st=8,zn="#565656",Tt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function Vt(e,t,n,r,a,i,s=!0){let d=0;const l=s?Ve:0;switch(a){case o.VerticalAlign.BOTTOM:d=t-r-l;break;case o.VerticalAlign.MIDDLE:d=(t-r)/2;break;default:d=l;break}d=Math.max(Ve,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-n)/2;break;case o.HorizontalAlign.RIGHT:c=e-n;break}return c=Math.max(ue,c),{paddingLeft:c,paddingTop:d}}let lt=class{constructor(e,t,n,r,a){P(this,"_dropdownInfoMap",new Map);P(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=r,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,r,a,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=n-se;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(r-xe)/2;break;case o.VerticalAlign.BOTTOM:h=r-l-a-Ve+(a/2-xe/2);break;default:h=d+Ve+(a/2-xe/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Tt),e.restore()}drawWith(e,t,n){var ee,Z,re,ie,he,pe;const{primaryWithCoord:r,row:a,col:i,style:s,data:d,subUnitId:l}=t,c=r.isMergedMainCell?r.mergeInfo:r,h=r.isMergedMainCell?r.mergeInfo.startRow:a,f=r.isMergedMainCell?r.mergeInfo.startColumn:i,u=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,h,f);if(!u)return;const S=this._dataValidationModel.getValidator(u.type);if(!S)return;const v=d==null?void 0:d.fontRenderExtension,{leftOffset:L=0,rightOffset:b=0,topOffset:w=0,downOffset:y=0}=v||{};if(!u||!S||!S||S.id.indexOf(o.DataValidationType.LIST)!==0||!S.skipDefaultFontRender(u))return;const D={startX:c.startX+L,endX:c.endX-b,startY:c.startY+w,endY:c.endY-y},A=D.endX-D.startX,m=D.endY-D.startY,g=this._ensureMap(l),C=this._generateKey(a,i),j=S.getListWithColorMap(u),$=I.getCellValueOrigin(d),x=`${$!=null?$:""}`,W=j[x];let{tb:T,vt:F,ht:N,pd:K}=s||{};T=T!=null?T:o.WrapStrategy.WRAP,F=F!=null?F:o.VerticalAlign.BOTTOM,N=N!=null?N:o.DEFAULT_STYLES.ht,K=K!=null?K:o.DEFAULT_STYLES.pd;const G=O.getFontStyleString(s).fontCache;if(u.renderMode===o.DataValidationRenderMode.ARROW){const{l:te=o.DEFAULT_STYLES.pd.l,t:J=o.DEFAULT_STYLES.pd.t,r:ce=o.DEFAULT_STYLES.pd.r,b:Q=o.DEFAULT_STYLES.pd.b}=K,V=A-te-ce-se-4,H=new O.DocSimpleSkeleton(x,G,T===o.WrapStrategy.WRAP,V,1/0);H.calculate();const _=H.getTotalWidth(),k=H.getTotalHeight(),{paddingTop:z,paddingLeft:le}=Vt(V,m-J-Q,_,k,F,N,!0);this._drawDownIcon(e,D,A,m,k,F,K),e.save(),e.translateWithPrecision(D.startX+te,D.startY+J),e.beginPath(),e.rect(0,0,A-te-ce,m-J-Q),e.clip(),e.translateWithPrecision(0,z),e.save(),e.translateWithPrecision(le,0),e.beginPath(),e.rect(0,0,V,k),e.clip(),O.Text.drawWith(e,{text:x,fontStyle:G,width:V,height:k,color:(ee=s==null?void 0:s.cl)==null?void 0:ee.rgb,strokeLine:!!((Z=s==null?void 0:s.st)!=null&&Z.s),underline:!!((re=s==null?void 0:s.ul)!=null&&re.s),warp:T===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},H),e.restore(),e.restore(),g.set(C,{left:D.endX-se+n.rowHeaderWidth,top:D.startY+J+n.columnHeaderHeight,width:se,height:m-J-Q})}else{e.save(),e.translateWithPrecision(D.startX,D.startY),e.beginPath(),e.rect(0,0,A,m),e.clip();const te=A-ue*2-Te-se-4,J=new O.DocSimpleSkeleton(x,G,T===o.WrapStrategy.WRAP,te,1/0);J.calculate();const ce=J.getTotalWidth(),Q=J.getTotalHeight(),V=Q+ot*2,H=Math.max(A-ue*2,1),{paddingTop:_}=Vt(H,m,ce,V,F,N);e.translateWithPrecision(ue,_),O.Rect.drawWith(e,{width:H,height:V,fill:W||ve,radius:st}),e.save(),e.translateWithPrecision(Te,ot),e.beginPath(),e.rect(0,0,te,Q),e.clip(),O.Text.drawWith(e,{text:x,fontStyle:G,width:te,height:Q,color:(ie=s==null?void 0:s.cl)==null?void 0:ie.rgb,strokeLine:!!((he=s==null?void 0:s.st)!=null&&he.s),underline:!!((pe=s==null?void 0:s.ul)!=null&&pe.s),warp:T===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},J),e.restore(),e.translateWithPrecision(te+Te+4,(Q-xe)/2),e.fillStyle=zn,e.fill(Tt),e.restore(),g.set(C,{left:D.startX+ue+n.rowHeaderWidth,top:D.startY+_+n.columnHeaderHeight,width:H,height:V})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=r==null?void 0:r.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:f=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-f},v=S.endX-S.startX,L=I.getCellValueOrigin(r),b=`${L!=null?L:""}`;let{tb:w,pd:y}=n||{};const{t:D=o.DEFAULT_STYLES.pd.t,b:A=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(w=w!=null?w:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:m=o.DEFAULT_STYLES.pd.l,r:g=o.DEFAULT_STYLES.pd.r}=y!=null?y:{},C=v-m-g-se-4,j=new O.DocSimpleSkeleton(b,O.getFontStyleString(n).fontCache,w===o.WrapStrategy.WRAP,C,1/0);return j.calculate(),j.getTotalHeight()+D+A+Ve*2}else{const m=Math.max(v-ue*2-Te-se-4,10),g=new O.DocSimpleSkeleton(b,O.getFontStyleString(n).fontCache,w===o.WrapStrategy.WRAP,m,1/0);return g.calculate(),g.getTotalHeight()+Ve*2+ot*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=r==null?void 0:r.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:f=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-f},v=S.endX-S.startX,L=I.getCellValueOrigin(r),b=`${L!=null?L:""}`;let{tb:w,pd:y}=n||{};const{l:D=o.DEFAULT_STYLES.pd.l,r:A=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};w=w!=null?w:o.WrapStrategy.WRAP;let m=ue*2+se;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:m=se+4+A+D;break;case o.DataValidationRenderMode.CUSTOM:m=se+ue*2+Te*2+A+D+st/2+1;break;default:m=se+ue*2+Te*2+A+D+st/2+1}const g=v-m,C=new O.DocSimpleSkeleton(b,O.getFontStyleString(n).fontCache,w===o.WrapStrategy.WRAP,g,1/0);return C.calculate(),C.getTotalWidth()+m}isHit(e,t){const{subUnitId:n,row:r,col:a}=t,s=this._ensureMap(n).get(this._generateKey(r,a)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,a);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:f}=s,{x:u,y:S}=e;return u>=c&&u<=c+h&&S>=l&&S<=l+f}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:r,row:a,col:i}=e,s={unitId:n,subUnitId:r,row:a,column:i};this._commandService.executeCommand(Fe.id,s)}onPointerEnter(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.DEFAULT)}};lt=Xn([Ae(0,o.IUniverInstanceService),Ae(1,o.Inject(o.LocaleService)),Ae(2,o.ICommandService),Ae(3,o.Inject(O.IRenderManagerService)),Ae(4,o.Inject(I.SheetDataValidationModel))],lt);class Kn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.LIST);P(this,"canvasRender",this.injector.createInstance(lt));P(this,"dropdownType",X.DataValidatorDropdownType.LIST);P(this,"optionsInput",je.componentKey);P(this,"formulaInput",I.LIST_FORMULA_INPUT_NAME)}}class Zn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.TEXT_LENGTH);P(this,"formulaInput",I.BASE_FORMULA_INPUT_NAME)}}class Gn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.WHOLE);P(this,"formulaInput",I.BASE_FORMULA_INPUT_NAME)}}var qn=Object.getOwnPropertyDescriptor,Jn=(e,t,n,r)=>{for(var a=r>1?void 0:r?qn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},dt=(e,t)=>(n,r)=>t(n,r,e);let Re=class extends o.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",Ct],[Ue,mn],[je.componentKey,je],[Be.componentKey,Be],...Dn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Fn,Gn,Zn,Un,An,Kn,xn,Ln].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Re=Jn([dt(0,o.Inject(o.Injector)),dt(1,o.Inject(M.ComponentManager)),dt(2,o.Inject(X.DataValidatorRegistryService))],Re);var Qn=Object.getOwnPropertyDescriptor,er=(e,t,n,r)=>{for(var a=r>1?void 0:r?Qn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ct=(e,t)=>(n,r)=>t(n,r,e);const tr="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationMobileUIPlugin=(Ye=class extends o.Plugin{constructor(t=Pe,n,r,a){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=a;const{menu:i,...s}=o.merge({},Pe,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Le,s)}onStarting(){[[de],[ge],[Oe],[we],[Me],[Ee],[De],[Re]].forEach(t=>{this._injector.add(t)}),[ke,Fe,vt,Ze,fe,pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(De),this._injector.get(Ee),this._injector.get(O.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Ne])}onRendered(){this._injector.get(Re),this._injector.get(Me)}onSteady(){this._injector.get(we)}},P(Ye,"pluginName",tr),P(Ye,"type",o.UniverInstanceType.UNIVER_SHEET),Ye),U.UniverSheetsDataValidationMobileUIPlugin=er([ct(1,o.Inject(o.Injector)),ct(2,o.ICommandService),ct(3,o.IConfigService)],U.UniverSheetsDataValidationMobileUIPlugin);var nr=Object.defineProperty,rr=Object.getOwnPropertyDescriptor,ar=(e,t,n)=>t in e?nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ir=(e,t,n,r)=>{for(var a=r>1?void 0:r?rr(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ut=(e,t)=>(n,r)=>t(n,r,e),Rt=(e,t,n)=>ar(e,typeof t!="symbol"?t+"":t,n);const or="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Pe,n,r,a){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=a;const{menu:i,...s}=o.merge({},Pe,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Le,s)}onStarting(){[[de],[ge],[Oe],[we],[Me],[Ee],[De],[Ce],[Re]].forEach(t=>{this._injector.add(t)}),[ke,Fe,vt,Ze,fe,pt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(De),this._injector.get(Ee),this._injector.get(Ce),this._injector.get(Oe),this._injector.get(O.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Ne])}onRendered(){this._injector.get(Re),this._injector.get(Me)}onSteady(){this._injector.get(we)}},Rt(U.UniverSheetsDataValidationUIPlugin,"pluginName",or),Rt(U.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),U.UniverSheetsDataValidationUIPlugin=ir([o.DependentOn(I.UniverSheetsDataValidationPlugin),ut(1,o.Inject(o.Injector)),ut(2,o.ICommandService),ut(3,o.IConfigService)],U.UniverSheetsDataValidationUIPlugin),Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})}));
|
|
18
|
+
`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:n,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(y=>l.addShape({range:y,style:L,primary:null})))},onMouseLeave:()=>{var y;u(!1),(y=h.current)==null||y.forEach(I=>{I&&l.removeShape(I)}),h.current=void 0},children:[p.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:c==null?void 0:c.generateRuleName(t)}),p.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(y=>Ze.serializeRange(y)).join(",")}),v?p.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-size-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700",onClick:m,children:p.jsx(nt,{})}):null]})};function _n(e){const t=E.useDependency(_.SheetDataValidationModel),n=E.useDependency(o.IUniverInstanceService),r=E.useDependency(o.ICommandService),a=E.useDependency(o.Injector),i=E.useDependency(ue),s=E.useDependency(o.LocaleService),[d,l]=R.useState([]),{workbook:c}=e,h=E.useObservable(c.activeSheet$,void 0,!0),v=c.getUnitId(),u=h==null?void 0:h.getSheetId();R.useEffect(()=>{l(t.getRules(v,u));const I=t.ruleChange$.subscribe(D=>{D.unitId===v&&D.subUnitId===u&&l(t.getRules(v,u))});return()=>{I.unsubscribe()}},[v,u,t]);const S=async()=>{const I=_.createDefaultNewRule(a),D={unitId:v,subUnitId:u,rule:I};await r.executeCommand(_.AddSheetDataValidationCommand.id,D),i.setActiveRule({unitId:v,subUnitId:u,rule:I})},w=()=>{r.executeCommand(_.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:u})},m=(I=>{const D=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet(),f=D.getUnitId(),g=A.getSheetId();return I.map(F=>k.checkRangesEditablePermission(a,f,g,F.ranges)?{...F}:{...F,disable:!0})})(d),y=m==null?void 0:m.some(I=>I.disable);return p.jsxs("div",{className:"univer-pb-4",children:[m==null?void 0:m.map(I=>{var D;return p.jsx(Sn,{unitId:v,subUnitId:u,onClick:()=>{I.disable||i.setActiveRule({unitId:v,subUnitId:u,rule:I})},rule:I,disable:(D=I.disable)!=null?D:!1},I.uid)}),p.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!y?p.jsx(M.Button,{onClick:w,children:s.t("dataValidation.panel.removeAll")}):null,p.jsx(M.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const In=()=>{const e=E.useDependency(ue),t=E.useObservable(e.activeRule$,e.activeRule),n=E.useDependency(o.IUniverInstanceService),r=E.useObservable(()=>n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),a=E.useObservable(()=>{var i;return(i=r==null?void 0:r.activeSheet$)!=null?i:oe.of(null)},void 0,void 0,[]);return!r||!a?null:t&&(t.subUnitId===a.getSheetId()||t.subUnitId===e.getFocusFormulaEditorActiveRuleSubUnitId())?p.jsx(mn,{},t.rule.uid):p.jsx(_n,{workbook:r})},Cn=e=>{const{isTwoFormula:t=!1,value:n,onChange:r,showError:a,validResult:i}=e,s=E.useDependency(o.LocaleService),d=a?i==null?void 0:i.formula1:"",l=a?i==null?void 0:i.formula2:"";return t?p.jsxs(p.Fragment,{children:[p.jsx(M.FormLayout,{error:d,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{r==null||r({...n,formula1:c})}})}),p.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),p.jsx(M.FormLayout,{error:l,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:c=>{r==null||r({...n,formula2:c})}})})]}):p.jsx(M.FormLayout,{error:d,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{r==null||r({formula1:c})}})})};function yn(e){const{value:t,onChange:n,showError:r,validResult:a}=e,i=E.useDependency(o.LocaleService),s=r?a==null?void 0:a.formula1:"",d=r?a==null?void 0:a.formula2:"",[l,c]=R.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return p.jsxs(p.Fragment,{children:[p.jsx(M.FormLayout,{children:p.jsx(M.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?p.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?p.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:p.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function wn(e){var v;const{unitId:t,subUnitId:n,value:r,onChange:a,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=R.useRef(null),[c,h]=R.useState(!1);return E.useSidebarClick(u=>{var w;(w=l.current)!=null&&w.isClickOutSide(u)&&h(!1)}),p.jsx(M.FormLayout,{error:d,children:p.jsx(Ge.FormulaEditor,{ref:l,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:(v=r==null?void 0:r.formula1)!=null?v:"=",unitId:t,subUnitId:n,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(r==null?void 0:r.formula1)&&(a==null||a({...r,formula1:S}))},onFocus:()=>h(!0)})})}const En=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Dn=e=>{const{value:t,onChange:n,disabled:r}=e,[a,i]=R.useState(!1);return p.jsx(M.Dropdown,{align:"start",disabled:r,open:a,onOpenChange:i,overlay:p.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:En.map(s=>p.jsx("div",{className:M.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",M.borderClassName),style:{background:s},onClick:()=>{n(s),i(!1)}},s))}),children:p.jsxs("div",{className:M.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white",M.borderClassName),children:[p.jsx("div",{className:"univer-box-border univer-size-4 univer-rounded univer-text-base",style:{background:t}}),p.jsx(rt,{})]})})},Tt=e=>{const{item:t,commonProps:n,className:r}=e,{onItemChange:a,onItemDelete:i}=n;return p.jsxs("div",{className:M.clsx("univer-flex univer-items-center univer-gap-2",r),children:[!t.isRef&&p.jsx("div",{className:M.clsx("univer-cursor-move","draggableHandle"),children:p.jsx(bt,{})}),p.jsx(Dn,{value:t.color,onChange:s=>{a(t.id,t.label,s)}}),p.jsx(M.Input,{disabled:t.isRef,value:t.label,onChange:s=>{a(t.id,s,t.color)}}),t.isRef?null:p.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:p.jsx(nt,{onClick:()=>i(t.id)})})]})};function Mn(e){const{value:t,onChange:n=()=>{},unitId:r,subUnitId:a,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,v]=R.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=R.useState(h==="1"?l:"="),[w,L]=R.useState(h==="1"?l:"="),m=E.useDependency(o.LocaleService),y=E.useDependency(X.DataValidatorRegistryService),I=E.useDependency(X.DataValidationModel),D=E.useDependency(_.DataValidationFormulaController),A=E.useDependency(ue),[f,g]=R.useState(()=>c.split(",")),C=y.getValidatorItem(o.DataValidationType.LIST),[F,j]=R.useState([]),[B,W]=R.useState(""),T=s?i==null?void 0:i.formula1:"",N=R.useMemo(()=>I.ruleChange$.pipe(oe.debounceTime(16)),[]),Y=E.useObservable(N),$=E.useEvent(n);R.useEffect(()=>{(async()=>{await new Promise(H=>{setTimeout(()=>H(!0),100)});const V=I.getRuleById(r,a,d),z=V==null?void 0:V.formula1;if(o.isFormulaString(z)&&C&&V){const H=await C.getListAsync(V,r,a);j(H)}})()},[I,Y,C,d,a,r]),R.useEffect(()=>{o.isFormulaString(l)&&l!==w&&(S(l),L(w))},[w,l]);const[K,ae]=R.useState(()=>{const V=h!=="1"?_.deserializeListOptions(l):[],z=c.split(",");return V.map((H,te)=>({label:H,color:z[te]||me,isRef:!1,id:o.generateRandomId(4)}))}),G=(V,z,H)=>{const te=K.find(b=>b.id===V);te&&(te.label=z,te.color=H,ae([...K]))},se=V=>{const z=K.findIndex(H=>H.id===V);z!==-1&&(K.splice(z,1),ae([...K]))},le=c.split(","),de=R.useMemo(()=>F.map((V,z)=>({label:V,color:le[z]||me,id:`${z}`,isRef:!0})),[le,F]),fe=(V,z,H)=>{const te=[...f];te[+V]=H,g(te),$({formula1:l,formula2:te.join(",")})},ne=()=>{ae([...K,{label:"",color:me,isRef:!1,id:o.generateRandomId(4)}])};R.useEffect(()=>{if(h==="1")return;const V=new Set,z=[];K.map(H=>({labelList:H.label.split(","),item:H})).forEach(({item:H,labelList:te})=>{te.forEach(b=>{V.has(b)||(V.add(b),z.push({label:b,color:H.color}))})}),$({formula1:_.serializeListOptions(z.map(H=>H.label)),formula2:z.map(H=>H.color===me?"":H.color).join(",")})},[K,$,h,w,f]);const Q=E.useEvent(async V=>{if(!o.isFormulaString(V)){$==null||$({formula1:"",formula2:c});return}D.getFormulaRefCheck(V)?($==null||$({formula1:o.isFormulaString(V)?V:"",formula2:c}),W("")):($==null||$({formula1:"",formula2:c}),S("="),W(m.t("dataValidation.validFail.formulaError")))}),ce=R.useRef(null),[re,ee]=R.useState(!1);return E.useSidebarClick(V=>{var H;(H=ce.current)!=null&&H.isClickOutSide(V)&&ee(!1)}),R.useEffect(()=>{re?A.setFocusFormulaEditorActiveRuleSubUnitId(a):A.setFocusFormulaEditorActiveRuleSubUnitId(null)},[re,a,A]),p.jsxs(p.Fragment,{children:[p.jsx(M.FormLayout,{label:m.t("dataValidation.list.options"),children:p.jsxs(M.RadioGroup,{value:h,onChange:V=>{v(V),S(w),V==="1"&&$({formula1:w==="="?"":w,formula2:f.join(",")})},children:[p.jsx(M.Radio,{value:"0",children:m.t("dataValidation.list.customOptions")}),p.jsx(M.Radio,{value:"1",children:m.t("dataValidation.list.refOptions")})]})}),h==="1"?p.jsxs(M.FormLayout,{error:T||B||void 0,children:[p.jsx(Ge.FormulaEditor,{ref:ce,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:u,unitId:r,subUnitId:a,isFocus:re,isSupportAcrossSheet:!0,onFocus:()=>ee(!0),onChange:(V="")=>{const z=(V!=null?V:"").trim();L(z),Q(z)}}),de.length>0&&p.jsx("div",{className:"univer-mt-3",children:de.map(V=>p.jsx(Tt,{className:"univer-mb-3",item:V,commonProps:{onItemChange:fe}},V.id))})]}):p.jsx(M.FormLayout,{error:T,children:p.jsxs("div",{className:"-univer-mt-3",children:[p.jsx(M.DraggableList,{list:K,onListChange:ae,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:V=>p.jsx(Tt,{item:V,commonProps:{onItemChange:G,onItemDelete:se}},V.id),idKey:"id"}),p.jsxs("a",{className:"univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800",onClick:ne,children:[p.jsx(Dt,{className:"univer-mr-1"}),m.t("dataValidation.list.add")]})]})})]})}const bn=[[_.CUSTOM_FORMULA_INPUT_NAME,wn],[_.BASE_FORMULA_INPUT_NAME,Cn],[_.LIST_FORMULA_INPUT_NAME,Mn],[_.CHECKBOX_FORMULA_INPUT_NAME,yn]],Tn="LIST_RENDER_MODE_OPTION_INPUT";function $e(e){var a;const{value:t,onChange:n}=e,r=E.useDependency(o.LocaleService);return p.jsx(M.FormLayout,{label:r.t("dataValidation.renderMode.label"),children:p.jsxs(M.RadioGroup,{value:`${(a=t.renderMode)!=null?a:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>n({...t,renderMode:+i}),children:[p.jsx(M.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:r.t("dataValidation.renderMode.chip")}),p.jsx(M.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:r.t("dataValidation.renderMode.arrow")}),p.jsx(M.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:r.t("dataValidation.renderMode.text")})]})})}$e.componentKey=Tn;const Rn="DATE_SHOW_TIME_OPTION";function He(e){var a;const{value:t,onChange:n}=e,r=E.useDependency(o.LocaleService);return p.jsx(M.FormLayout,{children:p.jsx(M.Checkbox,{checked:(a=t.bizInfo)==null?void 0:a.showTime,onChange:i=>{n({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:r.t("dataValidation.showTime.label")})})}He.componentKey=Rn;var Vn=Object.getOwnPropertyDescriptor,On=(e,t,n,r)=>{for(var a=r>1?void 0:r?Vn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ve=(e,t)=>(n,r)=>t(n,r,e);const xe=6;let at=class{constructor(e,t,n,r,a,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=r,this._renderManagerService=a,this._dataValidationModel=i}_calc(e,t){var c,h,v;const{vt:n,ht:r}=t||{},a=e.endX-e.startX-xe*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(n){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(r){case o.HorizontalAlign.LEFT:d=xe;break;case o.HorizontalAlign.RIGHT:d=xe+(a-s);break;default:d=xe+(a-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((v=t==null?void 0:t.fs)!=null?v:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var c,h,v,u,S,w,L,m,y;const{formula1:r=_.CHECKBOX_FORMULA_1,formula2:a=_.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=_.getFormulaResult((v=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:v[0]),d=_.getFormulaResult((w=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:w[0]),l=_.isLegalFormulaResult(String(s))&&_.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(r)?_.getFormulaResult((y=(m=(L=i==null?void 0:i[0])==null?void 0:L.result)==null?void 0:m[0])==null?void 0:y[0]):r,formula2:o.isFormulaString(a)?d:a,isFormulaValid:l}}drawWith(e,t){var W,T,N,Y;const{style:n,primaryWithCoord:r,unitId:a,subUnitId:i,worksheet:s,row:d,col:l}=t,c=r.isMergedMainCell?r.mergeInfo:r,h=_.getCellValueOrigin(s.getCellRaw(d,l)),v=this._dataValidationModel.getRuleByLocation(a,i,d,l);if(!v)return;const u=this._dataValidationModel.getValidator(v.type);if(!u||!((W=u.skipDefaultFontRender)!=null&&W.call(u,v,h,{unitId:a,subUnitId:i,row:d,column:l})))return;const S=u.parseFormulaSync(v,a,i),{formula1:w}=S,L=this._calc(c,n),{a:m,d:y}=e.getTransform(),I=O.fixLineWidthByScale(L.left,m),D=O.fixLineWidthByScale(L.top,y),A=O.Transform.create().composeMatrix({left:I,top:D,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),f=c.endX-c.startX,g=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,f,g),e.clip();const C=A.getMatrix();e.transform(C[0],C[1],C[2],C[3],C[4],C[5]);const F=((T=n==null?void 0:n.fs)!=null?T:10)*1.6,j=String(h)===String(w),B=this._themeService.getColorFromTheme("primary.600");O.CheckboxShape.drawWith(e,{checked:j,width:F,height:F,fill:(Y=(N=n==null?void 0:n.cl)==null?void 0:N.rgb)!=null?Y:B}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,r=this._calc(n,t.style),a=r.top,i=r.top+r.height,s=r.left,d=r.left+r.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=a}async onPointerDown(e,t){var w;if(t.button===2)return;const{primaryWithCoord:n,unitId:r,subUnitId:a,worksheet:i,row:s,col:d}=e,l=_.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(r,a,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((w=h.skipDefaultFontRender)!=null&&w.call(h,c,l,{unitId:r,subUnitId:a,row:s,column:d})))return;const{formula1:v,formula2:u}=await this._parseFormula(c,r,a),S={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===_.transformCheckboxValue(String(v))?u:v,p:null}};this._commandService.executeCommand(k.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.DEFAULT)}};at=On([Ve(0,o.ICommandService),Ve(1,o.IUniverInstanceService),Ve(2,o.Inject(_.DataValidationFormulaService)),Ve(3,o.Inject(o.ThemeService)),Ve(4,o.Inject(O.IRenderManagerService)),Ve(5,o.Inject(_.SheetDataValidationModel))],at);var An=Object.getOwnPropertyDescriptor,Ln=(e,t,n,r)=>{for(var a=r>1?void 0:r?An(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Pn=(e,t)=>(n,r)=>t(n,r,e);U.BaseSheetDataValidatorView=class{constructor(t){P(this,"canvasRender",null);P(this,"dropdownType");P(this,"optionsInput");P(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME);this.injector=t}},U.BaseSheetDataValidatorView=Ln([Pn(0,o.Inject(o.Injector))],U.BaseSheetDataValidatorView);class Un extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.CHECKBOX);P(this,"canvasRender",this.injector.createInstance(at));P(this,"formulaInput",_.CHECKBOX_FORMULA_INPUT_NAME)}}class Fn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.CUSTOM);P(this,"formulaInput",_.CUSTOM_FORMULA_INPUT_NAME)}}const Nn="data-validation.formula-input";class kn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.DATE);P(this,"formulaInput",Nn);P(this,"optionsInput",He.componentKey);P(this,"dropdownType",X.DataValidatorDropdownType.DATE)}}class jn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.DECIMAL);P(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}const Rt=4,Bn=0,it=4,Vt=4,ot=6,Ye=6,ye=14;function Wn(e,t){const n=O.FontCache.getTextSize(e,t),r=n.width+Rt*2,{ba:a,bd:i}=n,s=a+i;return{width:r,height:s+Bn*2,ba:a}}function st(e,t,n,r){const a=ye+ot*2,i=n-a,s=r-Ye*2,d=e.map(u=>({layout:Wn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:S}=u,{width:w,height:L}=S;!l||l.width+w+it>i?(l={width:w,height:L,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+it}),l.width=l.width+w+it)});let h=0,v=0;return c.forEach((u,S)=>{v=Math.max(v,u.width),S===c.length-1?h+=u.height:h+=u.height+Vt}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+Ye*2,calcAutoWidth:v+a}}const $n=8;class Hn extends O.Shape{static drawWith(t,n){const{fontString:r,info:a,fill:i,color:s}=n,{layout:d,text:l}=a;t.save(),O.Rect.drawWith(t,{width:d.width,height:d.height,radius:$n,fill:i||me}),t.translateWithPrecision(Rt,d.ba),t.font=r,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var xn=Object.getOwnPropertyDescriptor,Yn=(e,t,n,r)=>{for(var a=r>1?void 0:r?xn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Xe=(e,t)=>(n,r)=>t(n,r,e);const Xn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let lt=class{constructor(e,t,n,r){P(this,"zIndex");P(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,r,a){const i=n-ye+4;let s=4;switch(a){case o.VerticalAlign.MIDDLE:s=(r-ye)/2+4;break;case o.VerticalAlign.BOTTOM:s=r-ye+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Xn),e.restore()}drawWith(e,t,n,r){var le,de;const{primaryWithCoord:a,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=a.isMergedMainCell?a.mergeInfo:a,v=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:w=0,downOffset:L=0}=v||{},m=this._ensureMap(c),y=this._generateKey(i,s),I=a.isMergedMainCell?a.mergeInfo.startRow:i,D=a.isMergedMainCell?a.mergeInfo.startColumn:s,A=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,I,D);if(!A)return;const f=this._dataValidationModel.getValidator(A.type);if(!f)return;const g={startX:h.startX+u,endX:h.endX-S,startY:h.startY+w,endY:h.endY-L},C=g.endX-g.startX,F=g.endY-g.startY,{cl:j}=d||{},B=(le=typeof j=="object"?j==null?void 0:j.rgb:j)!=null?le:"#000",W=O.getFontStyleString(d!=null?d:void 0),{vt:T,ht:N}=d||{},Y=T!=null?T:o.VerticalAlign.MIDDLE,$=(de=_.getCellValueOrigin(l))!=null?de:"",K=f.parseCellValue($),ae=f.getListWithColorMap(A),G=st(K,W,C,F);this._drawDownIcon(e,g,C,F,Y),e.save(),e.translateWithPrecision(g.startX,g.startY),e.beginPath(),e.rect(0,0,C-ye,F),e.clip(),e.translateWithPrecision(ot,Ye);let se=0;switch(Y){case o.VerticalAlign.MIDDLE:se=(G.contentHeight-G.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:se=G.contentHeight-G.totalHeight;break}e.translateWithPrecision(0,se),G.lines.forEach((fe,ne)=>{e.save();const{width:Q,height:ce,items:re}=fe;let ee=0;switch(N){case o.HorizontalAlign.RIGHT:ee=G.contentWidth-Q;break;case o.HorizontalAlign.CENTER:ee=(G.contentWidth-Q)/2;break}e.translate(ee,ne*(ce+Vt)),re.forEach(V=>{e.save(),e.translateWithPrecision(V.left,0),Hn.drawWith(e,{...W,info:V,color:B,fill:ae[V.text]}),e.restore()}),e.restore()}),e.restore(),m.set(y,{left:g.startX,top:g.startY,width:G.contentWidth+ot+ye,height:G.contentHeight+Ye*2})}calcCellAutoHeight(e){var f;const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=r==null?void 0:r.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+d,endX:v.endX-l,startY:v.startY+c,endY:v.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!S)return;const w=this._dataValidationModel.getValidator(S.type);if(!w)return;const L=u.endX-u.startX,m=u.endY-u.startY,y=(f=_.getCellValueOrigin(r))!=null?f:"",I=w.parseCellValue(y),D=O.getFontStyleString(n!=null?n:void 0);return st(I,D,L,m).cellAutoHeight}calcCellAutoWidth(e){var f;const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=r==null?void 0:r.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+d,endX:v.endX-l,startY:v.startY+c,endY:v.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!S)return;const w=this._dataValidationModel.getValidator(S.type);if(!w)return;const L=u.endX-u.startX,m=u.endY-u.startY,y=(f=_.getCellValueOrigin(r))!=null?f:"",I=w.parseCellValue(y),D=O.getFontStyleString(n!=null?n:void 0);return st(I,D,L,m).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,r=n.isMergedMainCell?n.mergeInfo:n,{endX:a}=r,{x:i}=e;return i>=a-ye&&i<=a}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:r,row:a,col:i}=e,s={unitId:n,subUnitId:r,row:a,column:i};this._commandService.executeCommand(je.id,s)}onPointerEnter(e,t){var n,r;return(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;return(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:r.setCursor(O.CURSOR_TYPE.DEFAULT)}};lt=Yn([Xe(0,o.ICommandService),Xe(1,o.IUniverInstanceService),Xe(2,o.Inject(O.IRenderManagerService)),Xe(3,o.Inject(_.SheetDataValidationModel))],lt);class zn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.LIST_MULTIPLE);P(this,"canvasRender",this.injector.createInstance(lt));P(this,"dropdownType",X.DataValidatorDropdownType.MULTIPLE_LIST)}}var Kn=Object.getOwnPropertyDescriptor,Zn=(e,t,n,r)=>{for(var a=r>1?void 0:r?Kn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ue=(e,t)=>(n,r)=>t(n,r,e);const Oe=4,ze=4,pe=14,dt=1,ve=6,Ae=3,ct=8,Gn="#565656",Ot=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function At(e,t,n,r,a,i,s=!0){let d=0;const l=s?Ae:0;switch(a){case o.VerticalAlign.BOTTOM:d=t-r-l;break;case o.VerticalAlign.MIDDLE:d=(t-r)/2;break;default:d=l;break}d=Math.max(Ae,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-n)/2;break;case o.HorizontalAlign.RIGHT:c=e-n;break}return c=Math.max(ve,c),{paddingLeft:c,paddingTop:d}}let ut=class{constructor(e,t,n,r,a){P(this,"_dropdownInfoMap",new Map);P(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=r,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,r,a,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=n-pe;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(r-ze)/2;break;case o.VerticalAlign.BOTTOM:h=r-l-a-Ae+(a/2-ze/2);break;default:h=d+Ae+(a/2-ze/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Ot),e.restore()}drawWith(e,t,n){var ae,G,se,le,de,fe;const{primaryWithCoord:r,row:a,col:i,style:s,data:d,subUnitId:l}=t,c=r.isMergedMainCell?r.mergeInfo:r,h=r.isMergedMainCell?r.mergeInfo.startRow:a,v=r.isMergedMainCell?r.mergeInfo.startColumn:i,u=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,h,v);if(!u)return;const S=this._dataValidationModel.getValidator(u.type);if(!S)return;const w=d==null?void 0:d.fontRenderExtension,{leftOffset:L=0,rightOffset:m=0,topOffset:y=0,downOffset:I=0}=w||{};if(!u||!S||!S||S.id.indexOf(o.DataValidationType.LIST)!==0||!S.skipDefaultFontRender(u))return;const D={startX:c.startX+L,endX:c.endX-m,startY:c.startY+y,endY:c.endY-I},A=D.endX-D.startX,f=D.endY-D.startY,g=this._ensureMap(l),C=this._generateKey(a,i),F=S.getListWithColorMap(u),j=_.getCellValueOrigin(d),B=`${j!=null?j:""}`,W=F[B];let{tb:T,vt:N,ht:Y,pd:$}=s||{};T=T!=null?T:o.WrapStrategy.WRAP,N=N!=null?N:o.VerticalAlign.BOTTOM,Y=Y!=null?Y:o.DEFAULT_STYLES.ht,$=$!=null?$:o.DEFAULT_STYLES.pd;const K=O.getFontStyleString(s).fontCache;if(u.renderMode===o.DataValidationRenderMode.ARROW){const{l:ne=o.DEFAULT_STYLES.pd.l,t:Q=o.DEFAULT_STYLES.pd.t,r:ce=o.DEFAULT_STYLES.pd.r,b:re=o.DEFAULT_STYLES.pd.b}=$,ee=A-ne-ce-pe-4,V=new O.DocSimpleSkeleton(B,K,T===o.WrapStrategy.WRAP,ee,1/0);V.calculate();const z=V.getTotalWidth(),H=V.getTotalHeight(),{paddingTop:te,paddingLeft:b}=At(ee,f-Q-re,z,H,N,Y,!0);this._drawDownIcon(e,D,A,f,H,N,$),e.save(),e.translateWithPrecision(D.startX+ne,D.startY+Q),e.beginPath(),e.rect(0,0,A-ne-ce,f-Q-re),e.clip(),e.translateWithPrecision(0,te),e.save(),e.translateWithPrecision(b,0),e.beginPath(),e.rect(0,0,ee,H),e.clip(),O.Text.drawWith(e,{text:B,fontStyle:K,width:ee,height:H,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((G=s==null?void 0:s.st)!=null&&G.s),underline:!!((se=s==null?void 0:s.ul)!=null&&se.s),warp:T===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},V),e.restore(),e.restore(),g.set(C,{left:D.endX-pe+n.rowHeaderWidth,top:D.startY+Q+n.columnHeaderHeight,width:pe,height:f-Q-re})}else{e.save(),e.translateWithPrecision(D.startX,D.startY),e.beginPath(),e.rect(0,0,A,f),e.clip();const ne=A-ve*2-Oe-pe-4,Q=new O.DocSimpleSkeleton(B,K,T===o.WrapStrategy.WRAP,ne,1/0);Q.calculate();const ce=Q.getTotalWidth(),re=Q.getTotalHeight(),ee=re+dt*2,V=Math.max(A-ve*2,1),{paddingTop:z}=At(V,f,ce,ee,N,Y);e.translateWithPrecision(ve,z),O.Rect.drawWith(e,{width:V,height:ee,fill:W||me,radius:ct}),e.save(),e.translateWithPrecision(Oe,dt),e.beginPath(),e.rect(0,0,ne,re),e.clip(),O.Text.drawWith(e,{text:B,fontStyle:K,width:ne,height:re,color:(le=s==null?void 0:s.cl)==null?void 0:le.rgb,strokeLine:!!((de=s==null?void 0:s.st)!=null&&de.s),underline:!!((fe=s==null?void 0:s.ul)!=null&&fe.s),warp:T===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},Q),e.restore(),e.translateWithPrecision(ne+Oe+4,(re-ze)/2),e.fillStyle=Gn,e.fill(Ot),e.restore(),g.set(C,{left:D.startX+ve+n.rowHeaderWidth,top:D.startY+z+n.columnHeaderHeight,width:V,height:ee})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=r==null?void 0:r.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:v=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-v},w=S.endX-S.startX,L=_.getCellValueOrigin(r),m=`${L!=null?L:""}`;let{tb:y,pd:I}=n||{};const{t:D=o.DEFAULT_STYLES.pd.t,b:A=o.DEFAULT_STYLES.pd.b}=I!=null?I:{};if(y=y!=null?y:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:f=o.DEFAULT_STYLES.pd.l,r:g=o.DEFAULT_STYLES.pd.r}=I!=null?I:{},C=w-f-g-pe-4,F=new O.DocSimpleSkeleton(m,O.getFontStyleString(n).fontCache,y===o.WrapStrategy.WRAP,C,1/0);return F.calculate(),F.getTotalHeight()+D+A+Ae*2}else{const f=Math.max(w-ve*2-Oe-pe-4,10),g=new O.DocSimpleSkeleton(m,O.getFontStyleString(n).fontCache,y===o.WrapStrategy.WRAP,f,1/0);return g.calculate(),g.getTotalHeight()+Ae*2+dt*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:r,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=r==null?void 0:r.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:v=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-v},w=S.endX-S.startX,L=_.getCellValueOrigin(r),m=`${L!=null?L:""}`;let{tb:y,pd:I}=n||{};const{l:D=o.DEFAULT_STYLES.pd.l,r:A=o.DEFAULT_STYLES.pd.r}=I!=null?I:{};y=y!=null?y:o.WrapStrategy.WRAP;let f=ve*2+pe;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:f=pe+4+A+D;break;case o.DataValidationRenderMode.CUSTOM:f=pe+ve*2+Oe*2+A+D+ct/2+1;break;default:f=pe+ve*2+Oe*2+A+D+ct/2+1}const g=w-f,C=new O.DocSimpleSkeleton(m,O.getFontStyleString(n).fontCache,y===o.WrapStrategy.WRAP,g,1/0);return C.calculate(),C.getTotalWidth()+f}isHit(e,t){const{subUnitId:n,row:r,col:a}=t,s=this._ensureMap(n).get(this._generateKey(r,a)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,a);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:v}=s,{x:u,y:S}=e;return u>=c&&u<=c+h&&S>=l&&S<=l+v}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:r,row:a,col:i}=e,s={unitId:n,subUnitId:r,row:a,column:i};this._commandService.executeCommand(je.id,s)}onPointerEnter(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,r;(r=(n=O.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||r.setCursor(O.CURSOR_TYPE.DEFAULT)}};ut=Zn([Ue(0,o.IUniverInstanceService),Ue(1,o.Inject(o.LocaleService)),Ue(2,o.ICommandService),Ue(3,o.Inject(O.IRenderManagerService)),Ue(4,o.Inject(_.SheetDataValidationModel))],ut);class qn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.LIST);P(this,"canvasRender",this.injector.createInstance(ut));P(this,"dropdownType",X.DataValidatorDropdownType.LIST);P(this,"optionsInput",$e.componentKey);P(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME)}}class Jn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.TEXT_LENGTH);P(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}class Qn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);P(this,"id",o.DataValidationType.WHOLE);P(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}var er=Object.getOwnPropertyDescriptor,tr=(e,t,n,r)=>{for(var a=r>1?void 0:r?er(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ht=(e,t)=>(n,r)=>t(n,r,e);let Le=class extends o.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",Et],[ke,In],[$e.componentKey,$e],[He.componentKey,He],...bn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[jn,Qn,Jn,kn,Un,qn,zn,Fn].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Le=tr([ht(0,o.Inject(o.Injector)),ht(1,o.Inject(E.ComponentManager)),ht(2,o.Inject(X.DataValidatorRegistryService))],Le);var nr=Object.getOwnPropertyDescriptor,rr=(e,t,n,r)=>{for(var a=r>1?void 0:r?nr(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},pt=(e,t)=>(n,r)=>t(n,r,e);const ar="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationMobileUIPlugin=(Ke=class extends o.Plugin{constructor(t=Ne,n,r,a){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=a;const{menu:i,...s}=o.merge({},Ne,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Fe,s)}onStarting(){[[ue],[Se],[Pe],[Me],[Re],[Te],[be],[Le]].forEach(t=>{this._injector.add(t)}),[Be,je,mt,Je,_e,ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(be),this._injector.get(Te),this._injector.get(O.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[We])}onRendered(){this._injector.get(Le),this._injector.get(Re)}onSteady(){this._injector.get(Me)}},P(Ke,"pluginName",ar),P(Ke,"type",o.UniverInstanceType.UNIVER_SHEET),Ke),U.UniverSheetsDataValidationMobileUIPlugin=rr([pt(1,o.Inject(o.Injector)),pt(2,o.ICommandService),pt(3,o.IConfigService)],U.UniverSheetsDataValidationMobileUIPlugin);var ir=Object.defineProperty,or=Object.getOwnPropertyDescriptor,sr=(e,t,n)=>t in e?ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lr=(e,t,n,r)=>{for(var a=r>1?void 0:r?or(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},vt=(e,t)=>(n,r)=>t(n,r,e),Lt=(e,t,n)=>sr(e,typeof t!="symbol"?t+"":t,n);const dr="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Ne,n,r,a){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=a;const{menu:i,...s}=o.merge({},Ne,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Fe,s)}onStarting(){[[ue],[Se],[Pe],[Me],[Re],[Te],[be],[Ee],[Le]].forEach(t=>{this._injector.add(t)}),[Be,je,mt,Je,_e,ft].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(be),this._injector.get(Te),this._injector.get(Ee),this._injector.get(Pe),this._injector.get(O.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[We])}onRendered(){this._injector.get(Le),this._injector.get(Re)}onSteady(){this._injector.get(Me)}},Lt(U.UniverSheetsDataValidationUIPlugin,"pluginName",dr),Lt(U.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),U.UniverSheetsDataValidationUIPlugin=lr([o.DependentOn(_.UniverSheetsDataValidationPlugin),vt(1,o.Inject(o.Injector)),vt(2,o.ICommandService),vt(3,o.IConfigService)],U.UniverSheetsDataValidationUIPlugin),Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})}));
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
// index
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/preset-sheets-data-validation",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,17 +58,17 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/data-validation": "0.15.
|
|
62
|
-
"@univerjs/sheets-data-validation": "0.15.
|
|
63
|
-
"@univerjs/sheets-data-validation-ui": "0.15.
|
|
61
|
+
"@univerjs/data-validation": "0.15.5",
|
|
62
|
+
"@univerjs/sheets-data-validation": "0.15.5",
|
|
63
|
+
"@univerjs/sheets-data-validation-ui": "0.15.5"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@univerjs/core": "0.15.
|
|
66
|
+
"@univerjs/core": "0.15.5",
|
|
67
67
|
"react": "18.3.1",
|
|
68
68
|
"react-dom": "18.3.1",
|
|
69
69
|
"rxjs": "7.8.2",
|
|
70
70
|
"typescript": "^5.9.3",
|
|
71
|
-
"@univerjs-infra/shared": "0.15.
|
|
71
|
+
"@univerjs-infra/shared": "0.15.5"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"prebuild:preset": "tsx prepare.ts",
|