@univerjs/sheets-data-validation-ui 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +48 -2
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/sk-SK.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/index.js +48 -3241
- package/lib/es/locale/ca-ES.js +1 -182
- package/lib/es/locale/en-US.js +1 -182
- package/lib/es/locale/es-ES.js +1 -182
- package/lib/es/locale/fa-IR.js +1 -182
- package/lib/es/locale/fr-FR.js +1 -182
- package/lib/es/locale/ja-JP.js +1 -182
- package/lib/es/locale/ko-KR.js +1 -182
- package/lib/es/locale/ru-RU.js +1 -182
- package/lib/es/locale/sk-SK.js +1 -182
- package/lib/es/locale/vi-VN.js +1 -182
- package/lib/es/locale/zh-CN.js +1 -184
- package/lib/es/locale/zh-TW.js +1 -182
- package/lib/index.css +317 -1
- package/lib/index.js +48 -3241
- package/lib/locale/ca-ES.js +1 -182
- package/lib/locale/en-US.js +1 -182
- package/lib/locale/es-ES.js +1 -182
- package/lib/locale/fa-IR.js +1 -182
- package/lib/locale/fr-FR.js +1 -182
- package/lib/locale/ja-JP.js +1 -182
- package/lib/locale/ko-KR.js +1 -182
- package/lib/locale/ru-RU.js +1 -182
- package/lib/locale/sk-SK.js +1 -182
- package/lib/locale/vi-VN.js +1 -182
- package/lib/locale/zh-CN.js +1 -184
- package/lib/locale/zh-TW.js +1 -182
- package/lib/types/commands/commands/data-validation-ui.command.d.ts +16 -1
- package/lib/types/commands/operations/data-validation.operation.d.ts +16 -1
- package/lib/types/config/config.d.ts +16 -1
- package/lib/types/controllers/dv-alert.controller.d.ts +15 -0
- package/lib/types/controllers/dv-auto-fill.controller.d.ts +15 -0
- package/lib/types/controllers/dv-copy-paste.controller.d.ts +15 -0
- package/lib/types/controllers/dv-permission.controller.d.ts +15 -0
- package/lib/types/controllers/dv-reject-input.controller.d.ts +15 -0
- package/lib/types/controllers/dv-render.controller.d.ts +15 -0
- package/lib/types/controllers/dv-rerender.controller.d.ts +18 -2
- package/lib/types/controllers/dv-ui.controller.d.ts +15 -0
- package/lib/types/locale/ca-ES.d.ts +16 -1
- package/lib/types/locale/es-ES.d.ts +16 -1
- package/lib/types/locale/fa-IR.d.ts +16 -1
- package/lib/types/locale/fr-FR.d.ts +16 -1
- package/lib/types/locale/ja-JP.d.ts +16 -1
- package/lib/types/locale/ko-KR.d.ts +16 -1
- package/lib/types/locale/ru-RU.d.ts +16 -1
- package/lib/types/locale/sk-SK.d.ts +16 -1
- package/lib/types/locale/vi-VN.d.ts +16 -1
- package/lib/types/locale/zh-CN.d.ts +16 -1
- package/lib/types/locale/zh-TW.d.ts +16 -1
- package/lib/types/menu/dv.menu.d.ts +17 -2
- package/lib/types/menu/schema.d.ts +16 -1
- package/lib/types/mobile-plugin.d.ts +16 -1
- package/lib/types/plugin.d.ts +16 -1
- package/lib/types/services/data-validation-panel.service.d.ts +19 -3
- package/lib/types/services/dropdown-manager.service.d.ts +20 -3
- package/lib/types/views/components/formula-input/BaseFormulaInput.d.ts +16 -1
- package/lib/types/views/components/formula-input/CheckboxFormulaInput.d.ts +16 -1
- package/lib/types/views/components/formula-input/CustomFormulaInput.d.ts +16 -1
- package/lib/types/views/components/formula-input/ListFormulaInput.d.ts +16 -1
- package/lib/types/views/components/formula-input/formula-input.d.ts +16 -1
- package/lib/types/views/components/formula-input/index.d.ts +16 -1
- package/lib/types/views/components/item/index.d.ts +16 -1
- package/lib/types/views/components/list/index.d.ts +16 -1
- package/lib/types/views/components/options/index.d.ts +16 -1
- package/lib/types/views/components/render-mode/index.d.ts +16 -1
- package/lib/types/views/components/show-time/index.d.ts +16 -1
- package/lib/types/views/validator-views/checkbox-validator-view.d.ts +15 -0
- package/lib/types/views/validator-views/custom-validator-view.d.ts +15 -0
- package/lib/types/views/validator-views/date-validator-view.d.ts +15 -0
- package/lib/types/views/validator-views/decimal-validator-view.d.ts +15 -0
- package/lib/types/views/validator-views/list-multiple-view.d.ts +15 -0
- package/lib/types/views/validator-views/list-validator-view.d.ts +19 -2
- package/lib/types/views/validator-views/sheet-validator-view.d.ts +18 -2
- package/lib/types/views/validator-views/text-length-validator.view.d.ts +15 -0
- package/lib/types/views/validator-views/whole-validator-view.d.ts +15 -0
- package/lib/types/views/widgets/checkbox-widget.d.ts +20 -3
- package/lib/types/views/widgets/dropdown-multiple-widget.d.ts +20 -3
- package/lib/types/views/widgets/dropdown-widget.d.ts +20 -3
- package/lib/types/views/widgets/shape/dropdown.d.ts +18 -2
- package/lib/types/views/widgets/shape/layout.d.ts +18 -3
- package/lib/umd/index.js +48 -2
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +17 -16
package/lib/umd/index.js
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
|
-
(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,N,_,X,E,oe,Ft,x,M,R,p,qe,Je){"use strict";var cr=Object.defineProperty;var ur=(U,o,O)=>o in U?cr(U,o,{enumerable:!0,configurable:!0,writable:!0,value:O}):U[o]=O;var L=(U,o,O)=>ur(U,typeof o!="symbol"?o+"":o,O);var Pe;const ke={name:"@univerjs/sheets-data-validation-ui",version:"0.17.0"};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},mt=(e,t)=>(n,r)=>t(n,r,e);let ue=class extends o.Disposable{constructor(t,n){super();L(this,"_open$",new oe.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(oe.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new oe.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);L(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===Be&&(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([mt(0,o.IUniverInstanceService),mt(1,E.ISidebarService)],ue);const Ne="sheets-data-validation-ui.config",je={},me="#ECECEC";var jt=Object.getOwnPropertyDescriptor,Bt=(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},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(N.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=Bt([we(0,o.Inject(N.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 Wt=Object.getOwnPropertyDescriptor,$t=(e,t,n,r)=>{for(var a=r>1?void 0:r?Wt(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 Ht(e,t){const n=Ft.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();L(this,"_activeDropdown");L(this,"_activeDropdown$",new oe.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(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 P,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),k=(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(N.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:Ht(g,k)}}}}),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=!!((P=c.bizInfo)!=null&&P.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 k=_.serializeListOptions(T),Y={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:k,p:null,f:null,si:null}};return this._commandService.executeCommand(N.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(Ne))==null?void 0:m.showEditOnDropdown)!=null?y:!0,showSearch:(D=(I=this._configService.getConfig(Ne))==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(N.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(N.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=$t([he(0,o.IUniverInstanceService),he(1,o.Inject(X.DataValidatorRegistryService)),he(2,E.IZenZoneService),he(3,o.Inject(_.SheetDataValidationModel)),he(4,o.Inject(N.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 Be="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=N.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:Be,header:{title:r?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Be},width:312,onClose:()=>a.close()});return a.setCloseDisposable(u),!0}},et={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},St={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(et.id):t.executeCommand(_e.id),!0}},We={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}},_t={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(Se).hideDropdown(),!0):!1}},$e={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),n=N.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 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},De=(e,t)=>(n,r)=>t(n,r,e);const Ie="SHEET_DATA_VALIDATION_ALERT";let Ue=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)}))}};Ue=Yt([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))],Ue);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},tt=(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},P=N.AutoFillTools.getAutoFillRepeatRange(v,u),m=new o.ObjectMatrix,y=new Set;P.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 k=o.Rectangle.getPositionRange({startRow:W,startColumn:T,endColumn:T,endRow:W},j),{row:Y,col:$}=S(k.startRow,k.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===N.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(N.AUTO_FILL_APPLY_TYPE.SERIES,!0);return}}},onFillData:(r,a,i)=>i===N.AUTO_FILL_APPLY_TYPE.COPY||i===N.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||i===N.AUTO_FILL_APPLY_TYPE.SERIES?t(r,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Me=zt([tt(0,N.IAutoFillService),tt(1,o.Inject(_.SheetDataValidationModel)),tt(2,o.Inject(o.Injector))],Me);var Kt=Object.getOwnPropertyDescriptor,Zt=(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},nt=(e,t)=>(n,r)=>t(n,r,e);let be=class extends o.Disposable{constructor(t,n,r){super();L(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=>N.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:P,undoMutations:m}=_.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),S.values()),this._injector,"patched",!1);return{redos:P,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:P}=_.getDataValidationDiffMutations(a,i,s.diff(this._sheetDataValidationModel.getRules(a,i)),this._injector,"patched",!1);return{redos:w,undos:P}}}};be=Zt([nt(0,x.ISheetClipboardService),nt(1,o.Inject(_.SheetDataValidationModel)),nt(2,o.Inject(o.Injector))],be);var Gt=Object.getOwnPropertyDescriptor,qt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Gt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},rt=(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:[N.WorkbookEditablePermission],rangeTypes:[N.RangeProtectionPermissionEditPoint],worksheetTypes:[N.WorksheetEditPermission,N.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:[N.WorkbookEditablePermission],rangeTypes:[N.RangeProtectionPermissionEditPoint],worksheetTypes:[N.WorksheetEditPermission,N.WorksheetSetCellStylePermission]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Te=qt([rt(0,o.Inject(o.LocaleService)),rt(1,o.ICommandService),rt(2,o.Inject(N.SheetPermissionCheckController))],Te);const It="sheet.menu.data-validation";function Jt(e){return{id:It,type:E.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:E.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:x.getCurrentRangeDisable$(e,{workbookTypes:[N.WorkbookEditablePermission],worksheetTypes:[N.WorksheetSetCellStylePermission,N.WorksheetEditPermission],rangeTypes:[N.RangeProtectionPermissionEditPoint]})}}function Qt(e){return{id:_e.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function en(e){return{id:$e.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const tn={[E.RibbonDataGroup.RULES]:{[It]:{order:0,menuItemFactory:Jt,[_e.id]:{order:0,menuItemFactory:Qt},[$e.id]:{order:1,menuItemFactory:en}}}};var nn=Object.getOwnPropertyDescriptor,Ct=(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},q=(e,t)=>(n,r)=>t(n,r,e);const yt={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(tn)}_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(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:N.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 P={get value(){var g;return w!==void 0||(w=(g=_.getCellValueOrigin(S))!=null?g:null),w}},m={get value(){var g;return`${(g=P.value)!=null?g:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.DataValidationStatus.INVALID?yt: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,P.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,k,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=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoHeight)==null?void 0:Y.call(k,F)},e.interceptorAutoWidth=()=>{var j,B,W,T,k,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=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoWidth)==null?void 0:Y.call(k,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=Ct([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(N.SheetInterceptorService)),q(9,o.Inject(_.DataValidationCacheService)),q(10,o.Optional(x.IEditorBridgeService))],Re);let wt=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(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:N.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),P=`${w!=null?w:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.DataValidationStatus.INVALID?yt: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,P,{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,k;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(k=(T=u==null?void 0:u.canvasRender)==null?void 0:T.calcCellAutoHeight)==null?void 0:k.call(T,C)},e.interceptorAutoWidth=()=>{var F,j,B,W,T,k;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(k=(T=u==null?void 0:u.canvasRender)==null?void 0:T.calcCellAutoWidth)==null?void 0:k.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)}})}};wt=Ct([q(0,o.ICommandService),q(1,O.IRenderManagerService),q(2,o.Inject(x.AutoHeightController)),q(3,o.Inject(X.DataValidatorRegistryService)),q(4,o.Inject(N.SheetInterceptorService)),q(5,o.Inject(_.SheetDataValidationModel)),q(6,o.Inject(_.DataValidationCacheService))],wt);var rn=Object.getOwnPropertyDescriptor,an=(e,t,n,r)=>{for(var a=r>1?void 0:r?rn(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 He=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))}};He=an([Et(1,o.Inject(_.SheetDataValidationModel)),Et(2,o.Inject(x.SheetSkeletonManagerService))],He);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(`_${ln()}`);return Dt(n,`${r}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:d,...s},i)}function Dt(e,t,n,r,a){return R.createElement(e.tag,{key:t,...on(e,n,a),...r},(sn(e,n).children||[]).map((i,s)=>Dt(i,`${t}-${e.tag}-${s}`,n,void 0,a)))}function on(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 sn(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 ln(){return Math.random().toString(36).substring(2,8)}Ce.displayName="UniverIcon";const dn={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"}}]},Mt=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"data-validation-icon",ref:n,icon:dn}))});Mt.displayName="DataValidationIcon";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:"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"}}]},at=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"delete-icon",ref:n,icon:cn}))});at.displayName="DeleteIcon";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:"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"}}]},bt=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"increase-icon",ref:n,icon:un}))});bt.displayName="IncreaseIcon";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:"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"}}]},it=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"more-down-icon",ref:n,icon:hn}))});it.displayName="MoreDownIcon";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:"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"}}]},Tt=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"more-up-icon",ref:n,icon:pn}))});Tt.displayName="MoreUpIcon";const vn={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"}}]},Rt=R.forwardRef(function(t,n){return R.createElement(Ce,Object.assign({},t,{id:"sequence-icon",ref:n,icon:vn}))});Rt.displayName="SequenceIcon";function gn(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(Tt,{className:"univer-ml-1"}):p.jsx(it,{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 fn=e=>o.debounce(async(t,n,r,a)=>{const i=await e.executeCommand(t,n,r);a==null||a(i)},1e3);function mn(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 Sn(){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,[]),P=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(()=>fn(v),[v]),[j,B]=R.useState(!1),[W,T]=R.useState(!1),k=R.useRef(null),Y=E.useDependency(N.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=()=>{(P==null?void 0:P.getSheetId())!==i&&v.syncExecuteCommand(N.SetWorksheetActiveOperation.id,{unitId:a,subUnitId:i})},se=()=>{var b,Z,J;(Z=(b=k.current)==null?void 0:b.editor)!=null&&Z.isFocus()&&le((J=k.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(qe.deserializeRangeWithSheet).map(ie=>{const Ut=ie.sheetName;if(Ut){const dr=mn(c,ie.unitId,Ut);return{...ie,sheetId:dr}}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=>qe.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(Je.RangeSelector,{selectorRef:k,unitId:a,subUnitId:i,initialValue:re,onChange:(b,Z)=>{var J;!W&&((J=k.current)!=null&&J.verify())&&le(Z)},onFocusChange:(b,Z)=>{var J;T(b),!b&&Z&&((J=k.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(gn,{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 _n=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$),P=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(`
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(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(`@univerjs/engine-formula`),require(`@univerjs/sheets-formula-ui`),require(`react/jsx-runtime`)):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`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDataValidationUi={},e.UniverCore,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsDataValidation,e.UniverDataValidation,e.UniverUi,e.rxjs,e.UniverSheetsNumfmt,e.UniverSheetsUi,e.UniverDesign,e.React,e.UniverEngineFormula,e.UniverSheetsFormulaUi,e.React))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var h=Object.create,g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,v=Object.getOwnPropertyNames,y=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty,x=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=v(t),a=0,o=i.length,s;a<o;a++)s=i[a],!b.call(e,s)&&s!==n&&g(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=_(t,s))||r.enumerable});return e};d=((e,t,n)=>(n=e==null?{}:h(y(e)),x(t||!e||!e.__esModule?g(n,`default`,{value:e,enumerable:!0}):n,e)))(d);var S=`@univerjs/sheets-data-validation-ui`,C=`0.18.0`;function w(e){"@babel/helpers - typeof";return w=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},w(e)}function T(e,t){if(w(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(w(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function E(e){var t=T(e,`string`);return w(t)==`symbol`?t:t+``}function D(e,t,n){return(t=E(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e,t){return function(n,r){t(n,r,e)}}function k(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let A=class extends t.Disposable{get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}constructor(e,n){super(),this._univerInstanceService=e,this._sidebarService=n,D(this,`_open$`,new s.BehaviorSubject(!1)),D(this,`open$`,this._open$.pipe((0,s.distinctUntilChanged)())),D(this,`_activeRule`,void 0),D(this,`_activeRule$`,new s.BehaviorSubject(void 0)),D(this,`activeRule$`,this._activeRule$.asObservable()),D(this,`_closeDisposable`,null),D(this,`_focusFormulaEditorActiveRuleSubUnitId`,null),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,s.filter)(e=>!e)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.id===`DataValidationPanel`&&(e.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}dispose(){var e;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(e=this._closeDisposable)==null||e.dispose()}open(){this._open$.next(!0)}close(){var e;this._open$.next(!1),(e=this._closeDisposable)==null||e.dispose()}setCloseDisposable(e){this._closeDisposable=(0,t.toDisposable)(()=>{e.dispose(),this._closeDisposable=null})}setActiveRule(e){this._activeRule=e,this._activeRule$.next(e)}setFocusFormulaEditorActiveRuleSubUnitId(e){this._focusFormulaEditorActiveRuleSubUnitId=e}getFocusFormulaEditorActiveRuleSubUnitId(){return this._focusFormulaEditorActiveRuleSubUnitId}};A=k([O(0,t.IUniverInstanceService),O(1,o.ISidebarService)],A);let j=`sheets-data-validation-ui.config`;Symbol(j);let M={},N=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=r,this._localeService=i,this._sheetsDataValidationValidatorService=a,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(r.VALIDATE_CELL,{handler:async(e,n,r)=>{let i=await e,{row:a,col:o,unitId:s,subUnitId:c}=n,l=this._dataValidationModel.getRuleIdByLocation(s,c,a,o),f=l?this._dataValidationModel.getRuleById(s,c,l):void 0;if(i===!1)return r(Promise.resolve(!1));if(!f||f.errorStyle!==t.DataValidationErrorStyle.STOP)return r(Promise.resolve(!0));let p=this._dataValidatorRegistryService.getValidatorItem(f.type);return!p||await this._sheetsDataValidationValidatorService.validatorCell(s,c,a,o)===t.DataValidationStatus.VALID?r(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t(`dataValidation.alert.title`)},id:`reject-input-dialog`,children:{title:p.getRuleFinalError(f,{row:a,col:o,unitId:s,subUnitId:c})},footer:{title:(0,d.createElement)(u.Button,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`dataValidation.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}}),r(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t(`dataValidation.alert.title`)},id:`reject-input-dialog`,children:{title:e},footer:{title:(0,d.createElement)(u.Button,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`dataValidation.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}})}};N=k([O(0,(0,t.Inject)(r.SheetInterceptorService)),O(1,(0,t.Inject)(i.SheetDataValidationModel)),O(2,(0,t.Inject)(a.DataValidatorRegistryService)),O(3,o.IDialogService),O(4,(0,t.Inject)(t.LocaleService)),O(5,(0,t.Inject)(i.SheetsDataValidationValidatorService))],N);let P=e=>{if(e==null||typeof e==`boolean`)return;if(e===``)return(0,t.dayjs)();if(typeof e==`number`||!Number.isNaN(+e))return(0,t.dayjs)(t.numfmt.format(`yyyy-MM-dd HH:mm:ss`,Number(e)));let n=(0,t.dayjs)(e);if(n.isValid())return n};function F(e,t){if(e===(0,c.getPatternType)(t))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 I=class extends t.Disposable{get activeDropdown(){return this._activeDropdown}constructor(e,t,n,r,i,a,o,c,l,u,d){super(),this._univerInstanceService=e,this._dataValidatorRegistryService=t,this._zenZoneService=n,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=a,this._sheetDataValidationModel=o,this._commandService=c,this._editorBridgeService=l,this._injector=u,this._configService=d,D(this,`_activeDropdown`,void 0),D(this,`_activeDropdown$`,new s.Subject),D(this,`_currentPopup`,null),D(this,`activeDropdown$`,this._activeDropdown$.asObservable()),D(this,`_zenVisible`,!1),this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{this._zenVisible=e,e&&this.hideDropdown()}))}_getDropdownByCell(e,n,r,i){let a=e?this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!a)return;let o=n?a.getSheetBySheetId(n):a.getActiveSheet();if(!o)return;let s=this._dataValidationModel.getRuleByLocation(a.getUnitId(),o.getSheetId(),r,i);if(!s)return;let c=this._dataValidatorRegistryService.getValidatorItem(s.type);return c==null?void 0:c.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(e=>{e&&e.every(e=>!(e.primary&&this._getDropdownByCell(e.primary.unitId,e.primary.sheetId,e.primary.actualRow,e.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(e){let{location:s}=e,{row:c,col:u,unitId:d,subUnitId:f,workbook:p,worksheet:m}=s;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=e,this._activeDropdown$.next(this._activeDropdown);let h=this._sheetDataValidationModel.getRuleByLocation(d,f,c,u);if(!h)return;let g=this._dataValidatorRegistryService.getValidatorItem(h.type);if(!(g!=null&&g.dropdownType))return;let _,v=async(e,i)=>{var a,s,_;if(!e)return!0;let v=e,y=m.getCell(c,u),b=v.format(i===`date`?`YYYY-MM-DD 00:00:00`:`YYYY-MM-DD HH:mm:ss`),x=(a=t.numfmt.parseDate(b))==null?void 0:a.v,S=i===`time`?x%1:x,C=p.getStyles().getStyleByCell(y),w=(s=C==null||(_=C.n)==null?void 0:_.pattern)==null?``:s;return h.errorStyle!==t.DataValidationErrorStyle.STOP||await g.validator({value:S,unitId:d,subUnitId:f,row:c,column:u,worksheet:m,workbook:p,interceptValue:b.replace(`Z`,``).replace(`T`,` `),t:t.CellValueType.NUMBER},h)?(await this._commandService.executeCommand(r.SetRangeValuesCommand.id,{unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:S,t:2,p:null,f:null,si:null,s:{n:{pattern:F(i,w)}}}}),await this._commandService.executeCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:n.DeviceInputEventType.Keyboard,unitId:d,keycode:o.KeyCode.ESC}),!0):(this._injector.has(N)&&this._injector.get(N).showReject(g.getRuleFinalError(h,{row:c,col:u,unitId:d,subUnitId:f})),!1)},y;switch(g.dropdownType){case a.DataValidatorDropdownType.DATE:{var b;let e=P((0,i.getCellValueOrigin)(m.getCellRaw(c,u))),t=!!((b=h.bizInfo)!=null&&b.showTime);y={location:s,type:`datepicker`,props:{showTime:t,onChange:e=>v(e,t?`datetime`:`date`),defaultValue:e,patternType:`date`}};break}case a.DataValidatorDropdownType.TIME:y={location:s,type:`datepicker`,props:{onChange:e=>v(e,`time`),defaultValue:P((0,i.getCellValueOrigin)(m.getCellRaw(c,u))),patternType:`time`}};break;case a.DataValidatorDropdownType.DATETIME:y={location:s,type:`datepicker`,props:{onChange:e=>v(e,`datetime`),defaultValue:P((0,i.getCellValueOrigin)(m.getCellRaw(c,u))),patternType:`datetime`}};break;case a.DataValidatorDropdownType.LIST:case a.DataValidatorDropdownType.MULTIPLE_LIST:{var x,S,C,w;let e=g.dropdownType===a.DataValidatorDropdownType.MULTIPLE_LIST,p=async t=>{let a=(0,i.serializeListOptions)(t),s={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:a,p:null,f:null,si:null}};return this._commandService.executeCommand(r.SetRangeValuesCommand.id,s),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:n.DeviceInputEventType.Keyboard,unitId:d,keycode:o.KeyCode.ESC}),!e},v=(h==null?void 0:h.renderMode)===t.DataValidationRenderMode.CUSTOM||(h==null?void 0:h.renderMode)===void 0,b=g.getListWithColor(h,d,f),T=(0,i.getDataValidationCellValue)(m.getCellRaw(c,u));y={location:s,type:`list`,props:{onChange:e=>p(e),options:b.map(e=>({label:e.label,value:e.label,color:v||e.color?e.color||`#ECECEC`:`transparent`})),onEdit:()=>{this._commandService.executeCommand(R.id,{ruleId:h.uid}),_==null||_.dispose()},defaultValue:T,multiple:e,showEdit:(x=(S=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:S.showEditOnDropdown)==null?!0:x,showSearch:(C=(w=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:w.showSearchOnDropdown)==null?!0:C}};break}case a.DataValidatorDropdownType.CASCADE:var T;y={type:`cascader`,props:{onChange:e=>{let t={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:e.join(`/`),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(r.SetRangeValuesCommand.id,t),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:n.DeviceInputEventType.Keyboard,unitId:d,keycode:o.KeyCode.ESC}),!0},defaultValue:(0,i.getDataValidationCellValue)(m.getCellRaw(c,u)).split(`/`),options:JSON.parse((T=h.formula1)==null?`[]`:T)},location:s};break;case a.DataValidatorDropdownType.COLOR:y={type:`color`,props:{onChange:e=>{let t={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:e,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(r.SetRangeValuesCommand.id,t),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:n.DeviceInputEventType.Keyboard,unitId:d,keycode:o.KeyCode.ESC}),!0},defaultValue:(0,i.getDataValidationCellValue)(m.getCellRaw(c,u))},location:s};break;default:throw Error(`[DataValidationDropdownManagerService]: unknown type!`)}if(_=this._cellDropdownManagerService.showDropdown({...y,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!_)throw Error(`[DataValidationDropdownManagerService]: cannot show dropdown!`);let E=new t.DisposableCollection;E.add(_),E.add({dispose:()=>{var e,t;(e=this._activeDropdown)==null||(t=e.onHide)==null||t.call(e)}}),this._currentPopup=E}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(e,n,r,i,a){let o=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);if(!o)return;let s=o.getSheetBySheetId(n);if(!s)return;let c=this._dataValidationModel.getRuleByLocation(o.getUnitId(),s.getSheetId(),r,i);if(!c)return;let l=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!l||!l.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:o,worksheet:s,row:r,col:i,unitId:e,subUnitId:n},onHide:a})}};I=k([O(0,t.IUniverInstanceService),O(1,(0,t.Inject)(a.DataValidatorRegistryService)),O(2,o.IZenZoneService),O(3,(0,t.Inject)(i.SheetDataValidationModel)),O(4,(0,t.Inject)(r.SheetsSelectionsService)),O(5,(0,t.Inject)(l.ISheetCellDropdownManagerService)),O(6,(0,t.Inject)(i.SheetDataValidationModel)),O(7,t.ICommandService),O(8,l.IEditorBridgeService),O(9,(0,t.Inject)(t.Injector)),O(10,t.IConfigService)],I);let L=`DataValidationPanel`,R={id:`data-validation.operation.open-validation-panel`,type:t.CommandType.OPERATION,handler(e,n){if(!n)return!1;let{ruleId:i,isAdd:s}=n,c=e.get(A),l=e.get(a.DataValidationModel),u=e.get(t.IUniverInstanceService),d=e.get(o.ISidebarService),f=(0,r.getSheetCommandTarget)(u);if(!f)return!1;let{unitId:p,subUnitId:m}=f,h=i?l.getRuleById(p,m,i):void 0;c.open(),c.setActiveRule(h&&{unitId:p,subUnitId:m,rule:h});let g=d.open({id:L,header:{title:s?`dataValidation.panel.addTitle`:`dataValidation.panel.title`},children:{label:L},width:312,onClose:()=>c.close()});return c.setCloseDisposable(g),!0}},z={id:`data-validation.operation.close-validation-panel`,type:t.CommandType.OPERATION,handler(e){return e.get(A).close(),!0}},B={id:`data-validation.operation.toggle-validation-panel`,type:t.CommandType.OPERATION,handler(e){let n=e.get(t.ICommandService),r=e.get(A);return r.open(),r.isOpen?n.executeCommand(z.id):n.executeCommand(R.id),!0}},V={type:t.CommandType.OPERATION,id:`sheet.operation.show-data-validation-dropdown`,handler(e,t){if(!t)return!1;let n=e.get(I),{unitId:r,subUnitId:i,row:a,column:o}=t,s=n.activeDropdown,c=s==null?void 0:s.location;return c&&c.unitId===r&&c.subUnitId===i&&c.row===a&&c.col===o||n.showDataValidationDropdown(r,i,a,o),!0}},H={type:t.CommandType.OPERATION,id:`sheet.operation.hide-data-validation-dropdown`,handler(e,t){return t?(e.get(I).hideDropdown(),!0):!1}},U={type:t.CommandType.COMMAND,id:`data-validation.command.addRuleAndOpen`,handler(e){let n=(0,r.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!n)return!1;let{workbook:a,worksheet:o}=n,s=(0,i.createDefaultNewRule)(e),c=e.get(t.ICommandService),l={rule:s,unitId:a.getUnitId(),subUnitId:o.getSheetId()};return c.syncExecuteCommand(i.AddSheetDataValidationCommand.id,l)?(c.syncExecuteCommand(R.id,{ruleId:s.uid,isAdd:!0}),!0):!1}},W=`SHEET_DATA_VALIDATION_ALERT`,G=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=r,this._zenZoneService=i,this._dataValidationModel=a,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,s.debounceTime)(100)).subscribe(e=>{if(e){let r=this._univerInstanceService.getUnit(e.location.unitId,t.UniverInstanceType.UNIVER_SHEET),i=r.getSheetBySheetId(e.location.subUnitId);if(!i)return;let a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(W);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:r,worksheet:i})===t.DataValidationStatus.INVALID){var n;let t=this._cellAlertManagerService.currentAlert.get(W),r=t==null||(n=t.alert)==null?void 0:n.location;if(r&&r.row===e.location.row&&r.col===e.location.col&&r.subUnitId===e.location.subUnitId&&r.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(W);return}let i=this._dataValidationModel.getValidator(a.type);if(!i){this._cellAlertManagerService.removeAlert(W);return}this._cellAlertManagerService.showAlert({type:l.CellAlertType.ERROR,title:this._localeService.t(`dataValidation.error.title`),message:i==null?void 0:i.getRuleFinalError(a,e.location),location:e.location,width:200,height:74,key:W});return}}this._cellAlertManagerService.removeAlert(W)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(W)}))}};G=k([O(0,(0,t.Inject)(l.HoverManagerService)),O(1,(0,t.Inject)(l.CellAlertManagerService)),O(2,t.IUniverInstanceService),O(3,(0,t.Inject)(t.LocaleService)),O(4,o.IZenZoneService),O(5,(0,t.Inject)(i.SheetDataValidationModel))],G);let K=class extends t.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),n=(e,n)=>{let{source:a,target:o,unitId:s,subUnitId:c}=e,u=this._sheetDataValidationModel.getRuleObjectMatrix(s,c).clone(),d=(0,l.virtualizeDiscreteRanges)([a,o]),[f,p]=d.ranges,{mapFunc:m}=d,h={row:f.startRow,col:f.startColumn},g=r.AutoFillTools.getAutoFillRepeatRange(f,p),_=new t.ObjectMatrix,v=new Set;g.forEach(e=>{let n=e.repeatStartCell,r=e.relativeRange,i={startRow:h.row,startColumn:h.col,endColumn:h.col,endRow:h.row},a={startRow:n.row,startColumn:n.col,endColumn:n.col,endRow:n.row};t.Range.foreach(r,(e,n)=>{let r=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},i),{row:o,col:l}=m(r.startRow,r.startColumn),u=this._sheetDataValidationModel.getRuleIdByLocation(s,c,o,l)||``,d=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},a),{row:f,col:p}=m(d.startRow,d.startColumn);_.setValue(f,p,u),v.add(u)})});let y=Array.from(v).map(e=>({id:e,ranges:(0,t.queryObjectMatrix)(_,t=>t===e)}));u.addRangeRules(y);let{redoMutations:b,undoMutations:x}=(0,i.getDataValidationDiffMutations)(s,c,u.diff(this._sheetDataValidationModel.getRules(s,c)),this._injector,`patched`,n===r.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT);return{undos:x,redos:b}},a={id:i.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:e=>{let{source:n,unitId:i,subUnitId:a}=e;for(let e of n.rows)for(let o of n.cols){let n=this._sheetDataValidationModel.getRuleByLocation(i,a,e,o);if(n&&n.type===t.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(r.AUTO_FILL_APPLY_TYPE.SERIES,!0);return}}},onFillData:(t,i,a)=>a===r.AUTO_FILL_APPLY_TYPE.COPY||a===r.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||a===r.AUTO_FILL_APPLY_TYPE.SERIES?n(t,a):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};K=k([O(0,r.IAutoFillService),O(1,(0,t.Inject)(i.SheetDataValidationModel)),O(2,(0,t.Inject)(t.Injector))],K);let q=class extends t.Disposable{constructor(e,t,n){super(),this._sheetClipboardService=e,this._sheetDataValidationModel=t,this._injector=n,D(this,`_copyInfo`,void 0),this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:i.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,r)=>{let{copyType:i=l.COPY_TYPE.COPY,pasteType:a}=r,{range:o}=e||{},{range:s,unitId:c,subUnitId:u}=t;return this._generateMutations(s,{copyType:i,pasteType:a,copyRange:o,unitId:c,subUnitId:u})}})}_collect(e,n,i){let a=new t.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:n,matrix:a};let o=this._injector.invoke(t=>(0,r.rangeToDiscreteRange)(i,t,e,n));if(!o)return;let{rows:s,cols:c}=o;s.forEach((t,r)=>{c.forEach((i,o)=>{let s=this._sheetDataValidationModel.getRuleIdByLocation(e,n,t,i);a.setValue(r,o,s==null?``:s)})})}_generateMutations(e,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===l.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange||[l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};let{unitId:r,subUnitId:a}=this._copyInfo;if(n.unitId!==r||a!==n.subUnitId){let o=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),s=new t.ObjectMatrix,c=new Set,{ranges:[u,d],mapFunc:f}=(0,l.virtualizeDiscreteRanges)([n.copyRange,e]),p=(0,l.getRepeatRange)(u,d,!0),m=new Map;p.forEach(({startRange:e})=>{var i;(i=this._copyInfo)==null||i.matrix.forValue((i,o,l)=>{let u=t.Rectangle.getPositionRange({startRow:i,endRow:i,startColumn:o,endColumn:o},e),d=`${a}-${l}`,p=this._sheetDataValidationModel.getRuleById(r,a,l);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,d)&&p&&m.set(d,{...p,uid:d});let{row:h,col:g}=f(u.startRow,u.startColumn);c.add(d),s.setValue(h,g,d)})});let h=Array.from(c).map(e=>({id:e,ranges:(0,t.queryObjectMatrix)(s,t=>t===e)}));o.addRangeRules(h);let{redoMutations:g,undoMutations:_}=(0,i.getDataValidationDiffMutations)(n.unitId,n.subUnitId,o.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),m.values()),this._injector,`patched`,!1);return{redos:g,undos:_}}else{let o=this._sheetDataValidationModel.getRuleObjectMatrix(r,a).clone(),s=new t.ObjectMatrix,c=new Set,{ranges:[u,d],mapFunc:f}=(0,l.virtualizeDiscreteRanges)([n.copyRange,e]);(0,l.getRepeatRange)(u,d,!0).forEach(({startRange:e})=>{var n;(n=this._copyInfo)==null||n.matrix.forValue((n,r,i)=>{let a=t.Rectangle.getPositionRange({startRow:n,endRow:n,startColumn:r,endColumn:r},e),{row:o,col:l}=f(a.startRow,a.startColumn);s.setValue(o,l,i),c.add(i)})});let p=Array.from(c).map(e=>({id:e,ranges:(0,t.queryObjectMatrix)(s,t=>t===e)}));o.addRangeRules(p);let{redoMutations:m,undoMutations:h}=(0,i.getDataValidationDiffMutations)(r,a,o.diff(this._sheetDataValidationModel.getRules(r,a)),this._injector,`patched`,!1);return{redos:m,undos:h}}}};q=k([O(0,l.ISheetClipboardService),O(1,(0,t.Inject)(i.SheetDataValidationModel)),O(2,(0,t.Inject)(t.Injector))],q);let J=class extends t.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){let{unitId:t,subUnitId:n,rule:{ranges:i}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[r.WorkbookEditablePermission],rangeTypes:[r.RangeProtectionPermissionEditPoint],worksheetTypes:[r.WorksheetEditPermission,r.WorksheetSetCellStylePermission]},i,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.setStyleErr`))}if(e.id===i.UpdateSheetDataValidationRangeCommand.id){let{unitId:t,subUnitId:n,ranges:i}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[r.WorkbookEditablePermission],rangeTypes:[r.RangeProtectionPermissionEditPoint],worksheetTypes:[r.WorksheetEditPermission,r.WorksheetSetCellStylePermission]},i,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.setStyleErr`))}}))}};J=k([O(0,(0,t.Inject)(t.LocaleService)),O(1,t.ICommandService),O(2,(0,t.Inject)(r.SheetPermissionCheckController))],J);let ee=`sheet.menu.data-validation`;function te(e){return{id:ee,type:o.MenuItemType.SUBITEMS,icon:`DataValidationIcon`,tooltip:`dataValidation.title`,hidden$:(0,o.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:(0,l.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetSetCellStylePermission,r.WorksheetEditPermission],rangeTypes:[r.RangeProtectionPermissionEditPoint]})}}function ne(e){return{id:R.id,title:`dataValidation.panel.title`,type:o.MenuItemType.BUTTON}}function re(e){return{id:U.id,title:`dataValidation.panel.add`,type:o.MenuItemType.BUTTON}}let ie={[o.RibbonDataGroup.RULES]:{[ee]:{order:0,menuItemFactory:te,[R.id]:{order:0,menuItemFactory:ne},[U.id]:{order:1,menuItemFactory:re}}}},ae={tr:{size:6,color:`#fe4b4b`}},Y=class extends t.RxDisposable{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._autoHeightController=i,this._dropdownManagerService=a,this._sheetDataValidationModel=o,this._dataValidatorRegistryService=s,this._sheetInterceptorService=c,this._dataValidationCacheService=l,this._editorBridgeService=u,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(ie)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{if(!e.visible){var t;((t=this._dropdownManagerService.activeDropdown)==null?void 0:t.trigger)===`editor-bridge`&&this._dropdownManagerService.hideDropdown();return}let n=this._editorBridgeService.getEditCellState();if(n){let{unitId:e,sheetId:t,row:r,column:i}=n,a=this._univerInstanceService.getUniverSheetInstance(e);if(!a)return;let o=this._sheetDataValidationModel.getRuleByLocation(e,t,r,i);if(!o)return;let s=this._dataValidatorRegistryService.getValidatorItem(o.type);if(!(s!=null&&s.dropdownType))return;let c=a.getActiveSheet();if(!c)return;let l=this._dropdownManagerService.activeDropdown,u=l==null?void 0:l.location;if(u&&u.unitId===e&&u.subUnitId===t&&u.row===r&&u.col===i)return;this._dropdownManagerService.showDropdown({location:{unitId:e,subUnitId:t,row:r,col:i,workbook:a,worksheet:c},trigger:`editor-bridge`,closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,priority:r.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,n,r)=>{var a,o,s,c,u;let{row:d,col:f,unitId:p,subUnitId:m,workbook:h,worksheet:g}=n,_=this._sheetDataValidationModel.getRuleIdByLocation(p,m,d,f);if(!_)return r(e);let v=this._sheetDataValidationModel.getRuleById(p,m,_);if(!v)return r(e);let y=(a=this._dataValidationCacheService.getValue(p,m,d,f))==null?t.DataValidationStatus.VALID:a,b=this._dataValidatorRegistryService.getValidatorItem(v.type),x=n.rawData,S,C={get value(){var e;return S===void 0&&(S=(e=(0,i.getCellValueOrigin)(x))==null?null:e),S}},w={get value(){var e;return`${(e=C.value)==null?``:e}`}};return(!e||e===n.rawData)&&(e={...n.rawData}),e.markers={...e==null?void 0:e.markers,...y===t.DataValidationStatus.INVALID?ae:null},e.customRender=[...(o=e==null?void 0:e.customRender)==null?[]:o,...b!=null&&b.canvasRender?[b.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(s=e.fontRenderExtension)==null?void 0:s.isSkip)||(b==null||(c=b.skipDefaultFontRender)==null?void 0:c.call(b,v,C.value,n))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...b==null?void 0:b.getExtraStyle(v,w.value,{get style(){let t=h.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},d,f)},e.interceptorAutoHeight=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoHeight)==null?void 0:a.call(i,c)},e.interceptorAutoWidth=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoWidth)==null?void 0:a.call(i,c)},e.coverable=((u=e==null?void 0:e.coverable)==null?!0:u)&&!(v.type===t.DataValidationType.LIST||v.type===t.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,s.filter)(e=>e.source===`command`),(0,s.bufferTime)(100)).subscribe(e=>{if(e.length===0)return;let n=[];e.forEach(e=>{if(e.rule.type===t.DataValidationType.LIST_MULTIPLE||e.rule.type===t.DataValidationType.LIST){var r;(r=e.rule)!=null&&r.ranges&&n.push(...e.rule.ranges)}}),n.length&&(0,t.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(n).redos,this._commandService)})}};Y=k([O(0,t.ICommandService),O(1,o.IMenuManagerService),O(2,n.IRenderManagerService),O(3,t.IUniverInstanceService),O(4,(0,t.Inject)(l.AutoHeightController)),O(5,(0,t.Inject)(I)),O(6,(0,t.Inject)(i.SheetDataValidationModel)),O(7,(0,t.Inject)(a.DataValidatorRegistryService)),O(8,(0,t.Inject)(r.SheetInterceptorService)),O(9,(0,t.Inject)(i.DataValidationCacheService)),O(10,(0,t.Optional)(l.IEditorBridgeService))],Y);let oe=class extends t.RxDisposable{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=r,this._sheetInterceptorService=i,this._sheetDataValidationModel=a,this._dataValidationCacheService=o,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,priority:r.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,n,r)=>{var a,o,s,c,u;let{row:d,col:f,unitId:p,subUnitId:m,workbook:h,worksheet:g}=n,_=this._sheetDataValidationModel.getRuleIdByLocation(p,m,d,f);if(!_)return r(e);let v=this._sheetDataValidationModel.getRuleById(p,m,_);if(!v)return r(e);let y=(a=this._dataValidationCacheService.getValue(p,m,d,f))==null?t.DataValidationStatus.VALID:a,b=this._dataValidatorRegistryService.getValidatorItem(v.type),x=(0,i.getCellValueOrigin)(g.getCellRaw(d,f)),S=`${x==null?``:x}`;return(!e||e===n.rawData)&&(e={...n.rawData}),e.markers={...e==null?void 0:e.markers,...y===t.DataValidationStatus.INVALID?ae:null},e.customRender=[...(o=e==null?void 0:e.customRender)==null?[]:o,...b!=null&&b.canvasRender?[b.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(s=e.fontRenderExtension)==null?void 0:s.isSkip)||(b==null||(c=b.skipDefaultFontRender)==null?void 0:c.call(b,v,x,n))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...b==null?void 0:b.getExtraStyle(v,S,{get style(){let t=h.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},d,f)},e.interceptorAutoHeight=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoHeight)==null?void 0:a.call(i,c)},e.interceptorAutoWidth=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoWidth)==null?void 0:a.call(i,c)},e.coverable=((u=e==null?void 0:e.coverable)==null?!0:u)&&!(v.type===t.DataValidationType.LIST||v.type===t.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,s.filter)(e=>e.source===`command`),(0,s.bufferTime)(16)).subscribe(e=>{let n=[];e.forEach(e=>{if(e.rule.type===t.DataValidationType.LIST_MULTIPLE||e.rule.type===t.DataValidationType.LIST){var r;(r=e.rule)!=null&&r.ranges&&n.push(...e.rule.ranges)}}),n.length&&(0,t.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(n).redos,this._commandService)})}};oe=k([O(0,t.ICommandService),O(1,n.IRenderManagerService),O(2,(0,t.Inject)(l.AutoHeightController)),O(3,(0,t.Inject)(a.DataValidatorRegistryService)),O(4,(0,t.Inject)(r.SheetInterceptorService)),O(5,(0,t.Inject)(i.SheetDataValidationModel)),O(6,(0,t.Inject)(i.DataValidationCacheService))],oe);let se=class extends t.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe((0,t.bufferDebounceTime)(16)).subscribe(e=>{var t;if(!e.length)return;let n=new Set;e.forEach(e=>{n.add(e.subUnitId)}),n.forEach(e=>{var t;(t=this._sheetSkeletonManagerService.getSkeletonParam(e))==null||t.skeleton.makeDirty(!0)}),(t=this._context.mainComponent)==null||t.makeForceDirty()}))}};se=k([O(1,(0,t.Inject)(i.SheetDataValidationModel)),O(2,(0,t.Inject)(l.SheetSkeletonManagerService))],se);function X({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,d.useRef)(`_${de()}`);return ce(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function ce(e,t,n,r,i){return(0,d.createElement)(e.tag,{key:t,...le(e,n,i),...r},(ue(e,n).children||[]).map((r,a)=>ce(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function le(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function ue(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function de(){return Math.random().toString(36).substring(2,8)}X.displayName=`UniverIcon`;let fe={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`}}]},pe=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(X,Object.assign({},e,{id:`data-validation-icon`,ref:t,icon:fe}))});pe.displayName=`DataValidationIcon`;let me={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`}}]},he=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(X,Object.assign({},e,{id:`delete-icon`,ref:t,icon:me}))});he.displayName=`DeleteIcon`;let ge={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`}}]},_e=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(X,Object.assign({},e,{id:`increase-icon`,ref:t,icon:ge}))});_e.displayName=`IncreaseIcon`;let ve={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`}}]},ye=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(X,Object.assign({},e,{id:`more-down-icon`,ref:t,icon:ve}))});ye.displayName=`MoreDownIcon`;let be={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`}}]},xe=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(X,Object.assign({},e,{id:`more-up-icon`,ref:t,icon:be}))});xe.displayName=`MoreUpIcon`;let Se={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`}}]},Ce=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(X,Object.assign({},e,{id:`sequence-icon`,ref:t,icon:Se}))});Ce.displayName=`SequenceIcon`;function we(e){var n;let r=(0,o.useDependency)(t.LocaleService),i=(0,o.useDependency)(o.ComponentManager),{value:a,onChange:s,extraComponent:c}=e,[l,f]=(0,d.useState)(!1),p=c?i.get(c):null;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`
|
|
2
|
+
univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900
|
|
3
|
+
dark:!univer-text-white
|
|
4
|
+
`,onClick:()=>f(!l),children:[r.t(`dataValidation.panel.options`),l?(0,m.jsx)(xe,{className:`univer-ml-1`}):(0,m.jsx)(ye,{className:`univer-ml-1`})]}),l&&(0,m.jsxs)(m.Fragment,{children:[p?(0,m.jsx)(p,{value:a,onChange:s}):null,(0,m.jsx)(u.FormLayout,{label:r.t(`dataValidation.panel.invalid`),children:(0,m.jsxs)(u.RadioGroup,{value:`${(n=a.errorStyle)==null?t.DataValidationErrorStyle.WARNING:n}`,onChange:e=>s({...a,errorStyle:+e}),children:[(0,m.jsx)(u.Radio,{value:`${t.DataValidationErrorStyle.WARNING}`,children:r.t(`dataValidation.panel.showWarning`)}),(0,m.jsx)(u.Radio,{value:`${t.DataValidationErrorStyle.STOP}`,children:r.t(`dataValidation.panel.rejectInput`)})]})}),(0,m.jsx)(u.FormLayout,{label:r.t(`dataValidation.panel.messageInfo`),children:(0,m.jsx)(u.Checkbox,{checked:a.showErrorMessage,onChange:()=>s({...a,showErrorMessage:!a.showErrorMessage}),children:r.t(`dataValidation.panel.showInfo`)})}),a.showErrorMessage?(0,m.jsx)(u.FormLayout,{children:(0,m.jsx)(u.Input,{value:a.error,onChange:e=>s({...a,error:e})})}):null]})]})}let Te=e=>(0,t.debounce)(async(t,n,r,i)=>{let a=await e.executeCommand(t,n,r);i==null||i(a)},1e3);function Ee(e,n,r){var i;if(n){var a;return((a=e.getUnit(n))==null||(a=a.getSheetBySheetName(r))==null?void 0:a.getSheetId())||``}return((i=e.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null||(i=i.getSheetBySheetName(r))==null?void 0:i.getSheetId())||``}function De(){var e,n;let[c,l]=(0,d.useState)(0),h=(0,o.useDependency)(A),{unitId:g,subUnitId:_,rule:v}=(0,o.useObservable)(h.activeRule$,h.activeRule)||{},y=v.uid,b=(0,o.useDependency)(a.DataValidatorRegistryService),x=(0,o.useDependency)(t.IUniverInstanceService),S=(0,o.useDependency)(o.ComponentManager),C=(0,o.useDependency)(t.ICommandService),w=(0,o.useDependency)(a.DataValidationModel),T=(0,o.useDependency)(t.LocaleService),E=(0,o.useObservable)(()=>x.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),D=(0,o.useObservable)(()=>{var e;return(e=E==null?void 0:E.activeSheet$)==null?(0,s.of)(null):e},void 0,void 0,[]),[O,k]=(0,d.useState)(v),j=b.getValidatorItem(O.type),[M,N]=(0,d.useState)(!1),P=b.getValidatorsByScope(a.DataValidatorRegistryScope.SHEET),[F,I]=(0,d.useState)(()=>O.ranges.map(e=>({unitId:``,sheetId:``,range:e}))),L=(0,d.useMemo)(()=>Te(C),[C]),[R,z]=(0,d.useState)(!1),[B,V]=(0,d.useState)(!1),H=(0,d.useRef)(null),U=(0,o.useDependency)(r.SheetsSelectionsService);if((0,d.useEffect)(()=>()=>{let e=U.getCurrentLastSelection();e&&U.setSelections([e])},[U]),(0,d.useEffect)(()=>{C.onCommandExecuted(e=>{(e.id===t.UndoCommand.id||e.id===t.RedoCommand.id)&&setTimeout(()=>{let e=w.getRuleById(g,_,y);l(e=>e+1),e&&(k(e),I(e.ranges.map(e=>({unitId:``,sheetId:``,range:e}))))},20)})},[C,w,y,_,g]),!j)return null;let W=j.operators,G=j.operatorNames,K=O.operator?a.TWO_FORMULA_OPERATOR_COUNT.includes(O.operator):!1,q=()=>{(D==null?void 0:D.getSheetId())!==_&&C.syncExecuteCommand(r.SetWorksheetActiveOperation.id,{unitId:g,subUnitId:_})},J=()=>{var e;if(!((e=H.current)==null||(e=e.editor)==null)&&e.isFocus()){var t;ee((t=H.current)==null?void 0:t.getValue())}!O.ranges.length||R||(j.validatorFormula(O,g,_).success?h.setActiveRule(null):N(!0),q())},ee=(0,o.useEvent)(e=>{let n=e.split(`,`).filter(Boolean).map(f.deserializeRangeWithSheet).map(e=>{let t=e.sheetName;if(t){let n=Ee(x,e.unitId,t);return{...e,sheetId:n}}return{...e,sheetId:``}});if((0,t.isUnitRangesEqual)(n,F))return;I(n);let r=n.filter(e=>(!e.unitId||e.unitId===g)&&(!e.sheetId||e.sheetId===_)).map(e=>e.range);if(k({...O,ranges:r}),r.length===0)return;let a={unitId:g,subUnitId:_,ruleId:y,ranges:r};L(i.UpdateSheetDataValidationRangeCommand.id,a)}),te=e=>{if((0,t.shallowEqual)(e,(0,a.getRuleSetting)(O)))return;k({...O,...e});let n={unitId:g,subUnitId:_,ruleId:y,setting:e};L(i.UpdateSheetDataValidationSettingCommand.id,n,void 0)},ne=async()=>{await C.executeCommand(i.RemoveSheetDataValidationCommand.id,{ruleId:y,unitId:g,subUnitId:_}),h.setActiveRule(null),q()},re={type:O.type,operator:O.operator,formula1:O.formula1,formula2:O.formula2,allowBlank:O.allowBlank},ie=e=>{let t=b.getValidatorItem(e);if(!t)return;let n=t.operators,r=w.getRuleById(g,_,y),o=e===(r==null?void 0:r.type)||e.includes(`list`)&&r!=null&&r.type.includes(`list`)?{...r,type:e}:{...O,type:e,operator:n[0],formula1:void 0,formula2:void 0};k(o),C.executeCommand(i.UpdateSheetDataValidationSettingCommand.id,{unitId:g,subUnitId:_,ruleId:O.uid,setting:(0,a.getRuleSetting)(o)})},ae=S.get(j.formulaInput),Y=(0,d.useMemo)(()=>F.map(e=>(0,f.serializeRange)(e.range)).join(`,`),[]),oe=(0,a.getRuleOptions)(O),se=e=>{(0,t.shallowEqual)(e,(0,a.getRuleOptions)(O))||(k({...O,...e}),L(i.UpdateSheetDataValidationOptionsCommand.id,{unitId:g,subUnitId:_,ruleId:y,options:e}))},X=W.length&&!O.operator;return(0,m.jsxs)(`div`,{"data-u-comp":`data-validation-detail`,className:`univer-py-2`,children:[(0,m.jsx)(u.FormLayout,{label:T.t(`dataValidation.panel.range`),error:!O.ranges.length||R?T.t(`dataValidation.panel.rangeError`):``,children:(0,m.jsx)(p.RangeSelector,{selectorRef:H,unitId:g,subUnitId:_,initialValue:Y,onChange:(e,t)=>{var n;!B&&(n=H.current)!=null&&n.verify()&&ee(t)},onFocusChange:(e,t)=>{var n;V(e),!e&&t&&(n=H.current)!=null&&n.verify()&&ee(t)},onVerify:e=>z(!e)})}),(0,m.jsx)(u.FormLayout,{label:T.t(`dataValidation.panel.type`),children:(0,m.jsx)(u.Select,{className:`univer-w-full`,value:O.type,options:P==null||(e=P.sort((e,t)=>e.order-t.order))==null?void 0:e.map(e=>({label:T.t(e.title),value:e.id})),onChange:ie})}),W!=null&&W.length?(0,m.jsx)(u.FormLayout,{label:T.t(`dataValidation.panel.operator`),children:(0,m.jsx)(u.Select,{className:`univer-w-full`,value:`${O.operator}`,options:[{value:``,label:T.t(`dataValidation.operators.legal`)},...W.map((e,t)=>({value:`${e}`,label:G[t]}))],onChange:e=>{te({...re,operator:e})}})}):null,ae&&!X?(0,m.jsx)(ae,{isTwoFormula:K,value:{formula1:O.formula1,formula2:O.formula2},onChange:e=>{te({...re,...e})},showError:M,validResult:j.validatorFormula(O,g,_),unitId:g,subUnitId:_,ruleId:y},c+O.type):null,(0,m.jsx)(u.FormLayout,{children:(0,m.jsx)(u.Checkbox,{checked:(n=O.allowBlank)==null?!0:n,onChange:()=>{var e;return te({...re,allowBlank:!((e=O.allowBlank)==null||e)})},children:T.t(`dataValidation.panel.allowBlank`)})}),(0,m.jsx)(we,{value:oe,onChange:se,extraComponent:j.optionsInput}),(0,m.jsxs)(`div`,{className:`univer-mt-5 univer-flex univer-flex-row univer-justify-end`,children:[(0,m.jsx)(u.Button,{className:`univer-ml-3`,onClick:ne,children:T.t(`dataValidation.panel.removeRule`)}),(0,m.jsx)(u.Button,{className:`univer-ml-3`,variant:`primary`,onClick:J,children:T.t(`dataValidation.panel.done`)})]})]})}let Oe=e=>{let{rule:n,onClick:r,unitId:s,subUnitId:c,disable:p}=e,h=(0,o.useDependency)(a.DataValidatorRegistryService),g=(0,o.useDependency)(t.ICommandService),_=(0,o.useDependency)(l.IMarkSelectionService),v=h.getValidatorItem(n.type),y=(0,d.useRef)(void 0),[b,x]=(0,d.useState)(!1),S=(0,o.useDependency)(t.ThemeService),C=(0,d.useMemo)(()=>{var e;let n=S.getColorFromTheme(`primary.600`),r=S.getColorFromTheme(`loop-color.2`),i=(e=S.getColorFromTheme(r))==null?n:e,a=new t.ColorKit(i).toRgb();return{fill:`rgba(${a.r}, ${a.g}, ${a.b}, 0.1)`,stroke:i}},[(0,o.useObservable)(S.currentTheme$)]),w=e=>{g.executeCommand(i.RemoveSheetDataValidationCommand.id,{ruleId:n.uid,unitId:s,subUnitId:c}),e.stopPropagation()};return(0,d.useEffect)(()=>()=>{if(y.current){var e;(e=y.current)==null||e.forEach(e=>{e&&_.removeShape(e)})}},[_]),(0,m.jsxs)(`div`,{className:(0,u.clsx)(`
|
|
2
5
|
univer-bg-secondary univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px]
|
|
3
6
|
univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md
|
|
4
7
|
univer-p-2 univer-pr-9
|
|
5
|
-
`,{"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:P,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=>qe.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(at,{})}):null]})};function In(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=>N.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(_n,{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 Cn=()=>{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(Sn,{},t.rule.uid):p.jsx(In,{workbook:r})},yn=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 wn(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 En(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(Je.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 Dn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Mn=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:Dn.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(it,{})]})})},Vt=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(Rt,{})}),p.jsx(Mn,{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(at,{onClick:()=>i(t.id)})})]})};function bn(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,P]=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:"",k=R.useMemo(()=>I.ruleChange$.pipe(oe.debounceTime(16)),[]),Y=E.useObservable(k),$=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),P(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(Je.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();P(z),Q(z)}}),de.length>0&&p.jsx("div",{className:"univer-mt-3",children:de.map(V=>p.jsx(Vt,{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(Vt,{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(bt,{className:"univer-mr-1"}),m.t("dataValidation.list.add")]})]})})]})}const Tn=[[_.CUSTOM_FORMULA_INPUT_NAME,En],[_.BASE_FORMULA_INPUT_NAME,yn],[_.LIST_FORMULA_INPUT_NAME,bn],[_.CHECKBOX_FORMULA_INPUT_NAME,wn]],Rn="LIST_RENDER_MODE_OPTION_INPUT";function xe(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")})]})})}xe.componentKey=Rn;const Vn="DATE_SHOW_TIME_OPTION";function Ye(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")})})}Ye.componentKey=Vn;var On=Object.getOwnPropertyDescriptor,An=(e,t,n,r)=>{for(var a=r>1?void 0:r?On(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 ot=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,P,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=(P=i==null?void 0:i[0])==null?void 0:P.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,k,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,P=this._calc(c,n),{a:m,d:y}=e.getTransform(),I=O.fixLineWidthByScale(P.left,m),D=O.fixLineWidthByScale(P.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=(k=n==null?void 0:n.cl)==null?void 0:k.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(N.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)}};ot=An([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))],ot);var Ln=Object.getOwnPropertyDescriptor,Pn=(e,t,n,r)=>{for(var a=r>1?void 0:r?Ln(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Un=(e,t)=>(n,r)=>t(n,r,e);U.BaseSheetDataValidatorView=class{constructor(t){L(this,"canvasRender",null);L(this,"dropdownType");L(this,"optionsInput");L(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME);this.injector=t}},U.BaseSheetDataValidatorView=Pn([Un(0,o.Inject(o.Injector))],U.BaseSheetDataValidatorView);class Fn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(ot));L(this,"formulaInput",_.CHECKBOX_FORMULA_INPUT_NAME)}}class kn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",_.CUSTOM_FORMULA_INPUT_NAME)}}const Nn="data-validation.formula-input";class jn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",Nn);L(this,"optionsInput",Ye.componentKey);L(this,"dropdownType",X.DataValidatorDropdownType.DATE)}}class Bn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}const Ot=4,Wn=0,st=4,At=4,lt=6,ze=6,ye=14;function $n(e,t){const n=O.FontCache.getTextSize(e,t),r=n.width+Ot*2,{ba:a,bd:i}=n,s=a+i;return{width:r,height:s+Wn*2,ba:a}}function dt(e,t,n,r){const a=ye+lt*2,i=n-a,s=r-ze*2,d=e.map(u=>({layout:$n(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:S}=u,{width:w,height:P}=S;!l||l.width+w+st>i?(l={width:w,height:P,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+st}),l.width=l.width+w+st)});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+At}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+ze*2,calcAutoWidth:v+a}}const Hn=8;class xn 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:Hn,fill:i||me}),t.translateWithPrecision(Ot,d.ba),t.font=r,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}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},Ke=(e,t)=>(n,r)=>t(n,r,e);const zn=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 ct=class{constructor(e,t,n,r){L(this,"zIndex");L(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(zn),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:P=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-P},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:k}=d||{},Y=T!=null?T:o.VerticalAlign.MIDDLE,$=(de=_.getCellValueOrigin(l))!=null?de:"",K=f.parseCellValue($),ae=f.getListWithColorMap(A),G=dt(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(lt,ze);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(k){case o.HorizontalAlign.RIGHT:ee=G.contentWidth-Q;break;case o.HorizontalAlign.CENTER:ee=(G.contentWidth-Q)/2;break}e.translate(ee,ne*(ce+At)),re.forEach(V=>{e.save(),e.translateWithPrecision(V.left,0),xn.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+lt+ye,height:G.contentHeight+ze*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 P=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 dt(I,D,P,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 P=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 dt(I,D,P,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(We.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)}};ct=Xn([Ke(0,o.ICommandService),Ke(1,o.IUniverInstanceService),Ke(2,o.Inject(O.IRenderManagerService)),Ke(3,o.Inject(_.SheetDataValidationModel))],ct);class Kn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(ct));L(this,"dropdownType",X.DataValidatorDropdownType.MULTIPLE_LIST)}}var Zn=Object.getOwnPropertyDescriptor,Gn=(e,t,n,r)=>{for(var a=r>1?void 0:r?Zn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Fe=(e,t)=>(n,r)=>t(n,r,e);const Oe=4,Ze=4,pe=14,ut=1,ve=6,Ae=3,ht=8,qn="#565656",Lt=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 Pt(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 pt=class{constructor(e,t,n,r,a){L(this,"_dropdownInfoMap",new Map);L(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(Lt),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:P=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+P,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:k,ht:Y,pd:$}=s||{};T=T!=null?T:o.WrapStrategy.WRAP,k=k!=null?k: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}=Pt(ee,f-Q-re,z,H,k,Y,!0);this._drawDownIcon(e,D,A,f,H,k,$),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+ut*2,V=Math.max(A-ve*2,1),{paddingTop:z}=Pt(V,f,ce,ee,k,Y);e.translateWithPrecision(ve,z),O.Rect.drawWith(e,{width:V,height:ee,fill:W||me,radius:ht}),e.save(),e.translateWithPrecision(Oe,ut),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=qn,e.fill(Lt),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,P=_.getCellValueOrigin(r),m=`${P!=null?P:""}`;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+ut*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,P=_.getCellValueOrigin(r),m=`${P!=null?P:""}`;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+ht/2+1;break;default:f=pe+ve*2+Oe*2+A+D+ht/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(We.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)}};pt=Gn([Fe(0,o.IUniverInstanceService),Fe(1,o.Inject(o.LocaleService)),Fe(2,o.ICommandService),Fe(3,o.Inject(O.IRenderManagerService)),Fe(4,o.Inject(_.SheetDataValidationModel))],pt);class Jn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(pt));L(this,"dropdownType",X.DataValidatorDropdownType.LIST);L(this,"optionsInput",xe.componentKey);L(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME)}}class Qn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}class er extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}var tr=Object.getOwnPropertyDescriptor,nr=(e,t,n,r)=>{for(var a=r>1?void 0:r?tr(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);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",Mt],[Be,Cn],[xe.componentKey,xe],[Ye.componentKey,Ye],...Tn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Bn,er,Qn,jn,Fn,Jn,Kn,kn].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=nr([vt(0,o.Inject(o.Injector)),vt(1,o.Inject(E.ComponentManager)),vt(2,o.Inject(X.DataValidatorRegistryService))],Le);var rr=Object.getOwnPropertyDescriptor,ar=(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},gt=(e,t)=>(n,r)=>t(n,r,e);U.UniverSheetsDataValidationMobileUIPlugin=(Pe=class extends o.Plugin{constructor(t=je,n,r,a){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=a;const{menu:i,...s}=o.merge({},je,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ne,s)}onStarting(){[[ue],[Se],[Ue],[Me],[Re],[Te],[be],[Le]].forEach(t=>{this._injector.add(t)}),[$e,We,_t,et,_e,St].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,[He])}onRendered(){this._injector.get(Le),this._injector.get(Re)}onSteady(){this._injector.get(Me)}},L(Pe,"pluginName","SHEET_DATA_VALIDATION_UI_PLUGIN"),L(Pe,"packageName",ke.name),L(Pe,"version",ke.version),L(Pe,"type",o.UniverInstanceType.UNIVER_SHEET),Pe),U.UniverSheetsDataValidationMobileUIPlugin=ar([gt(1,o.Inject(o.Injector)),gt(2,o.ICommandService),gt(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},ft=(e,t)=>(n,r)=>t(n,r,e),Ge=(e,t,n)=>sr(e,typeof t!="symbol"?t+"":t,n);U.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=je,n,r,a){super(),this._config=t,this._injector=n,this._commandService=r,this._configService=a;const{menu:i,...s}=o.merge({},je,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ne,s)}onStarting(){[[ue],[Se],[Ue],[Me],[Re],[Te],[be],[Ee],[Le]].forEach(t=>{this._injector.add(t)}),[$e,We,_t,et,_e,St].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(be),this._injector.get(Te),this._injector.get(Ee),this._injector.get(Ue),this._injector.get(O.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[He])}onRendered(){this._injector.get(Le),this._injector.get(Re)}onSteady(){this._injector.get(Me)}},Ge(U.UniverSheetsDataValidationUIPlugin,"pluginName","SHEET_DATA_VALIDATION_UI_PLUGIN"),Ge(U.UniverSheetsDataValidationUIPlugin,"packageName",ke.name),Ge(U.UniverSheetsDataValidationUIPlugin,"version",ke.version),Ge(U.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),U.UniverSheetsDataValidationUIPlugin=lr([o.DependentOn(_.UniverSheetsDataValidationPlugin),ft(1,o.Inject(o.Injector)),ft(2,o.ICommandService),ft(3,o.IConfigService)],U.UniverSheetsDataValidationUIPlugin),Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})}));
|
|
8
|
+
`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!p,"univer-opacity-50":p}),onClick:r,onMouseEnter:()=>{p||(x(!0),y.current=n.ranges.map(e=>_.addShape({range:e,style:C,primary:null})))},onMouseLeave:()=>{var e;x(!1),(e=y.current)==null||e.forEach(e=>{e&&_.removeShape(e)}),y.current=void 0},children:[(0,m.jsx)(`div`,{className:`
|
|
9
|
+
univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900
|
|
10
|
+
dark:!univer-text-white
|
|
11
|
+
`,children:v==null?void 0:v.generateRuleName(n)}),(0,m.jsx)(`div`,{className:`
|
|
12
|
+
univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px]
|
|
13
|
+
dark:!univer-text-gray-300
|
|
14
|
+
`,children:n.ranges.map(e=>(0,f.serializeRange)(e)).join(`,`)}),b?(0,m.jsx)(`div`,{className:`
|
|
15
|
+
univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-size-5 univer-items-center
|
|
16
|
+
univer-justify-center univer-rounded
|
|
17
|
+
hover:univer-bg-gray-200
|
|
18
|
+
dark:!univer-text-gray-300
|
|
19
|
+
dark:hover:!univer-bg-gray-700
|
|
20
|
+
`,onClick:w,children:(0,m.jsx)(he,{})}):null]})};function ke(e){let n=(0,o.useDependency)(i.SheetDataValidationModel),a=(0,o.useDependency)(t.IUniverInstanceService),s=(0,o.useDependency)(t.ICommandService),c=(0,o.useDependency)(t.Injector),l=(0,o.useDependency)(A),f=(0,o.useDependency)(t.LocaleService),[p,h]=(0,d.useState)([]),{workbook:g}=e,_=(0,o.useObservable)(g.activeSheet$,void 0,!0),v=g.getUnitId(),y=_==null?void 0:_.getSheetId();(0,d.useEffect)(()=>{h(n.getRules(v,y));let e=n.ruleChange$.subscribe(e=>{e.unitId===v&&e.subUnitId===y&&h(n.getRules(v,y))});return()=>{e.unsubscribe()}},[v,y,n]);let b=async()=>{let e=(0,i.createDefaultNewRule)(c),t={unitId:v,subUnitId:y,rule:e};await s.executeCommand(i.AddSheetDataValidationCommand.id,t),l.setActiveRule({unitId:v,subUnitId:y,rule:e})},x=()=>{s.executeCommand(i.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:y})},S=(e=>{let n=a.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),i=n.getActiveSheet(),o=n.getUnitId(),s=i.getSheetId();return e.map(e=>(0,r.checkRangesEditablePermission)(c,o,s,e.ranges)?{...e}:{...e,disable:!0})})(p),C=S==null?void 0:S.some(e=>e.disable);return(0,m.jsxs)(`div`,{className:`univer-pb-4`,children:[S==null?void 0:S.map(e=>{var t;return(0,m.jsx)(Oe,{unitId:v,subUnitId:y,onClick:()=>{e.disable||l.setActiveRule({unitId:v,subUnitId:y,rule:e})},rule:e,disable:(t=e.disable)==null?!1:t},e.uid)}),(0,m.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[p.length&&!C?(0,m.jsx)(u.Button,{onClick:x,children:f.t(`dataValidation.panel.removeAll`)}):null,(0,m.jsx)(u.Button,{variant:`primary`,onClick:b,children:f.t(`dataValidation.panel.add`)})]})]})}let Ae=()=>{let e=(0,o.useDependency)(A),n=(0,o.useObservable)(e.activeRule$,e.activeRule),r=(0,o.useDependency)(t.IUniverInstanceService),i=(0,o.useObservable)(()=>r.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),a=(0,o.useObservable)(()=>{var e;return(e=i==null?void 0:i.activeSheet$)==null?(0,s.of)(null):e},void 0,void 0,[]);return!i||!a?null:n&&(n.subUnitId===a.getSheetId()||n.subUnitId===e.getFocusFormulaEditorActiveRuleSubUnitId())?(0,m.jsx)(De,{},n.rule.uid):(0,m.jsx)(ke,{workbook:i})},je=e=>{let{isTwoFormula:n=!1,value:r,onChange:i,showError:a,validResult:s}=e,c=(0,o.useDependency)(t.LocaleService),l=a?s==null?void 0:s.formula1:``,d=a?s==null?void 0:s.formula2:``;return n?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(u.FormLayout,{error:l,children:(0,m.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`dataValidation.panel.formulaPlaceholder`),value:r==null?void 0:r.formula1,onChange:e=>{i==null||i({...r,formula1:e})}})}),(0,m.jsx)(`div`,{className:`-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400`,children:c.t(`dataValidation.panel.formulaAnd`)}),(0,m.jsx)(u.FormLayout,{error:d,children:(0,m.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`dataValidation.panel.formulaPlaceholder`),value:r==null?void 0:r.formula2,onChange:e=>{i==null||i({...r,formula2:e})}})})]}):(0,m.jsx)(u.FormLayout,{error:l,children:(0,m.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`dataValidation.panel.formulaPlaceholder`),value:r==null?void 0:r.formula1,onChange:e=>{i==null||i({formula1:e})}})})};function Me(e){let{value:n,onChange:r,showError:i,validResult:a}=e,s=(0,o.useDependency)(t.LocaleService),c=i?a==null?void 0:a.formula1:``,l=i?a==null?void 0:a.formula2:``,[f,p]=(0,d.useState)(!((n==null?void 0:n.formula1)===void 0&&(n==null?void 0:n.formula2)===void 0));return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(u.FormLayout,{children:(0,m.jsx)(u.Checkbox,{checked:f,onChange:e=>{e?p(!0):(p(!1),r==null||r({...n,formula1:void 0,formula2:void 0}))},children:s.t(`dataValidation.checkbox.tips`)})}),f?(0,m.jsx)(u.FormLayout,{label:s.t(`dataValidation.checkbox.checked`),error:c,children:(0,m.jsx)(u.Input,{className:`univer-w-full`,placeholder:s.t(`dataValidation.panel.valuePlaceholder`),value:n==null?void 0:n.formula1,onChange:e=>{r==null||r({...n,formula1:e||void 0})}})}):null,f?(0,m.jsx)(u.FormLayout,{label:s.t(`dataValidation.checkbox.unchecked`),error:l,children:(0,m.jsx)(u.Input,{className:`univer-w-full`,placeholder:s.t(`dataValidation.panel.valuePlaceholder`),value:n==null?void 0:n.formula2,onChange:e=>{r==null||r({...n,formula2:e||void 0})}})}):null]})}function Ne(e){var t;let{unitId:n,subUnitId:r,value:i,onChange:a,showError:s,validResult:c}=e,l=s?c==null?void 0:c.formula1:void 0,f=(0,d.useRef)(null),[h,g]=(0,d.useState)(!1);return(0,o.useSidebarClick)(e=>{var t;(t=f.current)!=null&&t.isClickOutSide(e)&&g(!1)}),(0,m.jsx)(u.FormLayout,{error:l,children:(0,m.jsx)(p.FormulaEditor,{ref:f,className:(0,u.clsx)(`
|
|
21
|
+
univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg
|
|
22
|
+
univer-bg-white univer-pt-2 univer-transition-colors
|
|
23
|
+
hover:univer-border-primary-600
|
|
24
|
+
dark:!univer-bg-gray-700 dark:!univer-text-white
|
|
25
|
+
[&>div:first-child]:univer-px-2.5
|
|
26
|
+
[&>div]:univer-h-5 [&>div]:univer-ring-transparent
|
|
27
|
+
`,u.borderClassName),initValue:(t=i==null?void 0:i.formula1)==null?`=`:t,unitId:n,subUnitId:r,isFocus:h,isSupportAcrossSheet:!0,onChange:e=>{let t=(e==null?``:e).trim();t!==(i==null?void 0:i.formula1)&&(a==null||a({...i,formula1:t}))},onFocus:()=>g(!0)})})}let Pe=[`#FFFFFF`,`#FEE7E7`,`#FEF0E6`,`#EFFBD0`,`#E4F4FE`,`#E8ECFD`,`#F1EAFA`,`#FDE8F3`,`#E5E5E5`,`#FDCECE`,`#FDC49B`,`#DEF6A2`,`#9FDAFF`,`#D0D9FB`,`#E3D5F6`,`#FBD0E8`,`#656565`,`#FE4B4B`,`#FF8C51`,`#8BBB11`,`#0B9EFB`,`#3A60F7`,`#9E6DE3`,`#F248A6`],Fe=e=>{let{value:t,onChange:n,disabled:r}=e,[i,a]=(0,d.useState)(!1);return(0,m.jsx)(u.Dropdown,{align:`start`,disabled:r,open:i,onOpenChange:a,overlay:(0,m.jsx)(`div`,{className:`
|
|
28
|
+
univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2
|
|
29
|
+
univer-p-1.5
|
|
30
|
+
`,children:Pe.map(e=>(0,m.jsx)(`div`,{className:(0,u.clsx)(`univer-box-border univer-size-4 univer-cursor-pointer univer-rounded`,u.borderClassName),style:{background:e},onClick:()=>{n(e),a(!1)}},e))}),children:(0,m.jsxs)(`div`,{className:(0,u.clsx)(`
|
|
31
|
+
univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center
|
|
32
|
+
univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5
|
|
33
|
+
univer-transition-colors univer-duration-200
|
|
34
|
+
hover:univer-border-primary-600
|
|
35
|
+
dark:!univer-bg-gray-700 dark:!univer-text-white
|
|
36
|
+
`,u.borderClassName),children:[(0,m.jsx)(`div`,{className:`univer-box-border univer-size-4 univer-rounded univer-text-base`,style:{background:t}}),(0,m.jsx)(ye,{})]})})},Ie=e=>{let{item:t,commonProps:n,className:r}=e,{onItemChange:i,onItemDelete:a}=n;return(0,m.jsxs)(`div`,{className:(0,u.clsx)(`univer-flex univer-items-center univer-gap-2`,r),children:[!t.isRef&&(0,m.jsx)(`div`,{className:(0,u.clsx)(`univer-cursor-move`,`draggableHandle`),children:(0,m.jsx)(Ce,{})}),(0,m.jsx)(Fe,{value:t.color,onChange:e=>{i(t.id,t.label,e)}}),(0,m.jsx)(u.Input,{disabled:t.isRef,value:t.label,onChange:e=>{i(t.id,e,t.color)}}),t.isRef?null:(0,m.jsx)(`div`,{className:`
|
|
37
|
+
univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base
|
|
38
|
+
hover:univer-bg-gray-200
|
|
39
|
+
`,children:(0,m.jsx)(he,{onClick:()=>a(t.id)})})]})};function Le(e){let{value:n,onChange:r=()=>{},unitId:c,subUnitId:l,validResult:f,showError:h,ruleId:g}=e,{formula1:_=``,formula2:v=``}=n||{},[y,b]=(0,d.useState)(()=>(0,t.isFormulaString)(_)?`1`:`0`),[x,S]=(0,d.useState)(y===`1`?_:`=`),[C,w]=(0,d.useState)(y===`1`?_:`=`),T=(0,o.useDependency)(t.LocaleService),E=(0,o.useDependency)(a.DataValidatorRegistryService),D=(0,o.useDependency)(a.DataValidationModel),O=(0,o.useDependency)(i.DataValidationFormulaController),k=(0,o.useDependency)(A),[j,M]=(0,d.useState)(()=>v.split(`,`)),N=E.getValidatorItem(t.DataValidationType.LIST),[P,F]=(0,d.useState)([]),[I,L]=(0,d.useState)(``),R=h?f==null?void 0:f.formula1:``,z=(0,o.useObservable)((0,d.useMemo)(()=>D.ruleChange$.pipe((0,s.debounceTime)(16)),[])),B=(0,o.useEvent)(r);(0,d.useEffect)(()=>{(async()=>{await new Promise(e=>{setTimeout(()=>e(!0),100)});let e=D.getRuleById(c,l,g);(0,t.isFormulaString)(e==null?void 0:e.formula1)&&N&&e&&F(await N.getListAsync(e,c,l))})()},[D,z,N,g,l,c]),(0,d.useEffect)(()=>{(0,t.isFormulaString)(_)&&_!==C&&(S(_),w(C))},[C,_]);let[V,H]=(0,d.useState)(()=>{let e=y===`1`?[]:(0,i.deserializeListOptions)(_),n=v.split(`,`);return e.map((e,r)=>({label:e,color:n[r]||`#ECECEC`,isRef:!1,id:(0,t.generateRandomId)(4)}))}),U=(e,t,n)=>{let r=V.find(t=>t.id===e);r&&(r.label=t,r.color=n,H([...V]))},W=e=>{let t=V.findIndex(t=>t.id===e);t!==-1&&(V.splice(t,1),H([...V]))},G=v.split(`,`),K=(0,d.useMemo)(()=>P.map((e,t)=>({label:e,color:G[t]||`#ECECEC`,id:`${t}`,isRef:!0})),[G,P]),q=(e,t,n)=>{let r=[...j];r[+e]=n,M(r),B({formula1:_,formula2:r.join(`,`)})},J=()=>{H([...V,{label:``,color:`#ECECEC`,isRef:!1,id:(0,t.generateRandomId)(4)}])};(0,d.useEffect)(()=>{if(y===`1`)return;let e=new Set,t=[];V.map(e=>({labelList:e.label.split(`,`),item:e})).forEach(({item:n,labelList:r})=>{r.forEach(r=>{e.has(r)||(e.add(r),t.push({label:r,color:n.color}))})}),B({formula1:(0,i.serializeListOptions)(t.map(e=>e.label)),formula2:t.map(e=>e.color===`#ECECEC`?``:e.color).join(`,`)})},[V,B,y,C,j]);let ee=(0,o.useEvent)(async e=>{if(!(0,t.isFormulaString)(e)){B==null||B({formula1:``,formula2:v});return}O.getFormulaRefCheck(e)?(B==null||B({formula1:(0,t.isFormulaString)(e)?e:``,formula2:v}),L(``)):(B==null||B({formula1:``,formula2:v}),S(`=`),L(T.t(`dataValidation.validFail.formulaError`)))}),te=(0,d.useRef)(null),[ne,re]=(0,d.useState)(!1);return(0,o.useSidebarClick)(e=>{var t;(t=te.current)!=null&&t.isClickOutSide(e)&&re(!1)}),(0,d.useEffect)(()=>{ne?k.setFocusFormulaEditorActiveRuleSubUnitId(l):k.setFocusFormulaEditorActiveRuleSubUnitId(null)},[ne,l,k]),(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(u.FormLayout,{label:T.t(`dataValidation.list.options`),children:(0,m.jsxs)(u.RadioGroup,{value:y,onChange:e=>{b(e),S(C),e===`1`&&B({formula1:C===`=`?``:C,formula2:j.join(`,`)})},children:[(0,m.jsx)(u.Radio,{value:`0`,children:T.t(`dataValidation.list.customOptions`)}),(0,m.jsx)(u.Radio,{value:`1`,children:T.t(`dataValidation.list.refOptions`)})]})}),y===`1`?(0,m.jsxs)(u.FormLayout,{error:R||I||void 0,children:[(0,m.jsx)(p.FormulaEditor,{ref:te,className:(0,u.clsx)(`
|
|
40
|
+
univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center
|
|
41
|
+
univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors
|
|
42
|
+
hover:univer-border-primary-600
|
|
43
|
+
dark:!univer-bg-gray-700 dark:!univer-text-white
|
|
44
|
+
[&>div:first-child]:univer-px-2.5
|
|
45
|
+
[&>div]:univer-h-5 [&>div]:univer-ring-transparent
|
|
46
|
+
`,u.borderClassName),initValue:x,unitId:c,subUnitId:l,isFocus:ne,isSupportAcrossSheet:!0,onFocus:()=>re(!0),onChange:(e=``)=>{let t=(e==null?``:e).trim();w(t),ee(t)}}),K.length>0&&(0,m.jsx)(`div`,{className:`univer-mt-3`,children:K.map(e=>(0,m.jsx)(Ie,{className:`univer-mb-3`,item:e,commonProps:{onItemChange:q}},e.id))})]}):(0,m.jsx)(u.FormLayout,{error:R,children:(0,m.jsxs)(`div`,{className:`-univer-mt-3`,children:[(0,m.jsx)(u.DraggableList,{list:V,onListChange:H,rowHeight:28,margin:[0,12],draggableHandle:`.draggableHandle`,itemRender:e=>(0,m.jsx)(Ie,{item:e,commonProps:{onItemChange:U,onItemDelete:W}},e.id),idKey:`id`}),(0,m.jsxs)(`a`,{className:`
|
|
47
|
+
univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row
|
|
48
|
+
univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm
|
|
49
|
+
hover:univer-bg-primary-50
|
|
50
|
+
dark:hover:!univer-bg-gray-800
|
|
51
|
+
`,onClick:J,children:[(0,m.jsx)(_e,{className:`univer-mr-1`}),T.t(`dataValidation.list.add`)]})]})})]})}let Re=[[i.CUSTOM_FORMULA_INPUT_NAME,Ne],[i.BASE_FORMULA_INPUT_NAME,je],[i.LIST_FORMULA_INPUT_NAME,Le],[i.CHECKBOX_FORMULA_INPUT_NAME,Me]];function ze(e){var n;let{value:r,onChange:i}=e,a=(0,o.useDependency)(t.LocaleService);return(0,m.jsx)(u.FormLayout,{label:a.t(`dataValidation.renderMode.label`),children:(0,m.jsxs)(u.RadioGroup,{value:`${(n=r.renderMode)==null?t.DataValidationRenderMode.CUSTOM:n}`,onChange:e=>i({...r,renderMode:+e}),children:[(0,m.jsx)(u.Radio,{value:`${t.DataValidationRenderMode.CUSTOM}`,children:a.t(`dataValidation.renderMode.chip`)}),(0,m.jsx)(u.Radio,{value:`${t.DataValidationRenderMode.ARROW}`,children:a.t(`dataValidation.renderMode.arrow`)}),(0,m.jsx)(u.Radio,{value:`${t.DataValidationRenderMode.TEXT}`,children:a.t(`dataValidation.renderMode.text`)})]})})}ze.componentKey=`LIST_RENDER_MODE_OPTION_INPUT`;function Be(e){var n;let{value:r,onChange:i}=e,a=(0,o.useDependency)(t.LocaleService);return(0,m.jsx)(u.FormLayout,{children:(0,m.jsx)(u.Checkbox,{checked:(n=r.bizInfo)==null?void 0:n.showTime,onChange:e=>{i({...r,bizInfo:{...r.bizInfo,showTime:e}})},children:a.t(`dataValidation.showTime.label`)})})}Be.componentKey=`DATE_SHOW_TIME_OPTION`;let Ve=class{_calc(e,n){var r,i,a;let{vt:o,ht:s}=n||{},c=e.endX-e.startX-12,l=e.endY-e.startY,u=((r=n==null?void 0:n.fs)==null?10:r)*1.6,d=0,f=0;switch(o){case t.VerticalAlign.TOP:f=0;break;case t.VerticalAlign.BOTTOM:f=0+(l-u);break;default:f=0+(l-u)/2;break}switch(s){case t.HorizontalAlign.LEFT:d=6;break;case t.HorizontalAlign.RIGHT:d=6+(c-u);break;default:d=6+(c-u)/2;break}return{left:e.startX+d,top:e.startY+f,width:((i=n==null?void 0:n.fs)==null?10:i)*1.6,height:((a=n==null?void 0:n.fs)==null?10:a)*1.6}}constructor(e,t,n,r,i,a){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=r,this._renderManagerService=i,this._dataValidationModel=a}calcCellAutoHeight(e){var t;let{style:n}=e;return((t=n==null?void 0:n.fs)==null?10:t)*1.6}calcCellAutoWidth(e){var t;let{style:n}=e;return((t=n==null?void 0:n.fs)==null?10:t)*1.6}async _parseFormula(e,n,r){var a,o,s;let{formula1:c=i.CHECKBOX_FORMULA_1,formula2:l=i.CHECKBOX_FORMULA_2}=e,u=await this._formulaService.getRuleFormulaResult(n,r,e.uid),d=(0,i.getFormulaResult)(u==null||(a=u[0])==null||(a=a.result)==null||(a=a[0])==null?void 0:a[0]),f=(0,i.getFormulaResult)(u==null||(o=u[1])==null||(o=o.result)==null||(o=o[0])==null?void 0:o[0]),p=(0,i.isLegalFormulaResult)(String(d))&&(0,i.isLegalFormulaResult)(String(f));return{formula1:(0,t.isFormulaString)(c)?(0,i.getFormulaResult)(u==null||(s=u[0])==null||(s=s.result)==null||(s=s[0])==null?void 0:s[0]):c,formula2:(0,t.isFormulaString)(l)?f:l,isFormulaValid:p}}drawWith(e,t){var r,a,o,s;let{style:c,primaryWithCoord:l,unitId:u,subUnitId:d,worksheet:f,row:p,col:m}=t,h=l.isMergedMainCell?l.mergeInfo:l,g=(0,i.getCellValueOrigin)(f.getCellRaw(p,m)),_=this._dataValidationModel.getRuleByLocation(u,d,p,m);if(!_)return;let v=this._dataValidationModel.getValidator(_.type);if(!v||!((r=v.skipDefaultFontRender)!=null&&r.call(v,_,g,{unitId:u,subUnitId:d,row:p,column:m})))return;let{formula1:y}=v.parseFormulaSync(_,u,d),b=this._calc(h,c),{a:x,d:S}=e.getTransform(),C=(0,n.fixLineWidthByScale)(b.left,x),w=(0,n.fixLineWidthByScale)(b.top,S),T=n.Transform.create().composeMatrix({left:C,top:w,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),E=h.endX-h.startX,D=h.endY-h.startY;e.save(),e.beginPath(),e.rect(h.startX,h.startY,E,D),e.clip();let O=T.getMatrix();e.transform(O[0],O[1],O[2],O[3],O[4],O[5]);let k=((a=c==null?void 0:c.fs)==null?10:a)*1.6,A=String(g)===String(y),j=this._themeService.getColorFromTheme(`primary.600`);n.CheckboxShape.drawWith(e,{checked:A,width:k,height:k,fill:(o=c==null||(s=c.cl)==null?void 0:s.rgb)==null?j:o}),e.restore()}isHit(e,t){let n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,r=this._calc(n,t.style),i=r.top,a=r.top+r.height,o=r.left,s=r.left+r.width,{x:c,y:l}=e;return c<=s&&c>=o&&l<=a&&l>=i}async onPointerDown(e,t){var n;if(t.button===2)return;let{primaryWithCoord:a,unitId:o,subUnitId:s,worksheet:c,row:l,col:u}=e,d=(0,i.getCellValueOrigin)(c.getCellRaw(l,u)),f=this._dataValidationModel.getRuleByLocation(o,s,l,u);if(!f)return;let p=this._dataValidationModel.getValidator(f.type);if(!p||!((n=p.skipDefaultFontRender)!=null&&n.call(p,f,d,{unitId:o,subUnitId:s,row:l,column:u})))return;let{formula1:m,formula2:h}=await this._parseFormula(f,o,s),g={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===(0,i.transformCheckboxValue)(String(m))?h:m,p:null}};this._commandService.executeCommand(r.SetRangeValuesCommand.id,g)}onPointerEnter(e,r){var i;(i=(0,n.getCurrentTypeOfRenderer)(t.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(i=i.mainComponent)==null||i.setCursor(n.CURSOR_TYPE.POINTER)}onPointerLeave(e,r){var i;(i=(0,n.getCurrentTypeOfRenderer)(t.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(i=i.mainComponent)==null||i.setCursor(n.CURSOR_TYPE.DEFAULT)}};Ve=k([O(0,t.ICommandService),O(1,t.IUniverInstanceService),O(2,(0,t.Inject)(i.DataValidationFormulaService)),O(3,(0,t.Inject)(t.ThemeService)),O(4,(0,t.Inject)(n.IRenderManagerService)),O(5,(0,t.Inject)(i.SheetDataValidationModel))],Ve);let Z=class{constructor(e){this.injector=e,D(this,`canvasRender`,null),D(this,`dropdownType`,void 0),D(this,`optionsInput`,void 0),D(this,`formulaInput`,i.LIST_FORMULA_INPUT_NAME)}};Z=k([O(0,(0,t.Inject)(t.Injector))],Z);var He=class extends Z{constructor(...e){super(...e),D(this,`id`,t.DataValidationType.CHECKBOX),D(this,`canvasRender`,this.injector.createInstance(Ve)),D(this,`formulaInput`,i.CHECKBOX_FORMULA_INPUT_NAME)}},Ue=class extends Z{constructor(...e){super(...e),D(this,`id`,t.DataValidationType.CUSTOM),D(this,`formulaInput`,i.CUSTOM_FORMULA_INPUT_NAME)}},We=class extends Z{constructor(...e){super(...e),D(this,`id`,t.DataValidationType.DATE),D(this,`formulaInput`,`data-validation.formula-input`),D(this,`optionsInput`,Be.componentKey),D(this,`dropdownType`,a.DataValidatorDropdownType.DATE)}},Ge=class extends Z{constructor(...e){super(...e),D(this,`id`,t.DataValidationType.DECIMAL),D(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}};function Ke(e,t){let r=n.FontCache.getTextSize(e,t),i=r.width+8,{ba:a,bd:o}=r;return{width:i,height:a+o+0,ba:a}}function qe(e,t,n,r){let i=n-26,a=r-12,o=e.map(e=>({layout:Ke(e,t),text:e})),s,c=[];o.forEach(e=>{let{layout:t}=e,{width:n,height:r}=t;!s||s.width+n+4>i?(s={width:n,height:r,items:[{...e,left:0}]},c.push(s)):(s.items.push({...e,left:s.width+4}),s.width=s.width+n+4)});let l=0,u=0;return c.forEach((e,t)=>{u=Math.max(u,e.width),t===c.length-1?l+=e.height:l+=e.height+4}),{lines:c,totalHeight:l,contentWidth:i,contentHeight:a,cellAutoHeight:l+12,calcAutoWidth:u+26}}var Je=class extends n.Shape{static drawWith(e,t){let{fontString:r,info:i,fill:a,color:o}=t,{layout:s,text:c}=i;e.save(),n.Rect.drawWith(e,{width:s.width,height:s.height,radius:8,fill:a||`#ECECEC`}),e.translateWithPrecision(4,s.ba),e.font=r,e.fillStyle=o,e.fillText(c,0,0),e.restore()}};let Ye=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`),Xe=class{constructor(e,t,n,r){this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=r,D(this,`zIndex`,void 0),D(this,`_dropdownInfoMap`,new Map)}_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,n,r,i,a){let o=r-14+4,s=4;switch(a){case t.VerticalAlign.MIDDLE:s=(i-14)/2+4;break;case t.VerticalAlign.BOTTOM:s=i-14+4;break;default:break}e.save(),e.translateWithPrecision(n.startX+o,n.startY+s),e.fillStyle=`#565656`,e.fill(Ye),e.restore()}drawWith(e,r,a,o){var s,c;let{primaryWithCoord:l,row:u,col:d,style:f,data:p,subUnitId:m}=r,h=l.isMergedMainCell?l.mergeInfo:l,{leftOffset:g=0,rightOffset:_=0,topOffset:v=0,downOffset:y=0}=(p==null?void 0:p.fontRenderExtension)||{},b=this._ensureMap(m),x=this._generateKey(u,d),S=l.isMergedMainCell?l.mergeInfo.startRow:u,C=l.isMergedMainCell?l.mergeInfo.startColumn:d,w=this._dataValidationModel.getRuleByLocation(r.unitId,r.subUnitId,S,C);if(!w)return;let T=this._dataValidationModel.getValidator(w.type);if(!T)return;let E={startX:h.startX+g,endX:h.endX-_,startY:h.startY+v,endY:h.endY-y},D=E.endX-E.startX,O=E.endY-E.startY,{cl:k}=f||{},A=(s=typeof k==`object`?k==null?void 0:k.rgb:k)==null?`#000`:s,j=(0,n.getFontStyleString)(f==null?void 0:f),{vt:M,ht:N}=f||{},P=M==null?t.VerticalAlign.MIDDLE:M,F=(c=(0,i.getCellValueOrigin)(p))==null?``:c,I=T.parseCellValue(F),L=T.getListWithColorMap(w),R=qe(I,j,D,O);this._drawDownIcon(e,E,D,O,P),e.save(),e.translateWithPrecision(E.startX,E.startY),e.beginPath(),e.rect(0,0,D-14,O),e.clip(),e.translateWithPrecision(6,6);let z=0;switch(P){case t.VerticalAlign.MIDDLE:z=(R.contentHeight-R.totalHeight)/2;break;case t.VerticalAlign.BOTTOM:z=R.contentHeight-R.totalHeight;break;default:break}e.translateWithPrecision(0,z),R.lines.forEach((n,r)=>{e.save();let{width:i,height:a,items:o}=n,s=0;switch(N){case t.HorizontalAlign.RIGHT:s=R.contentWidth-i;break;case t.HorizontalAlign.CENTER:s=(R.contentWidth-i)/2;break;default:break}e.translate(s,r*(a+4)),o.forEach(t=>{e.save(),e.translateWithPrecision(t.left,0),Je.drawWith(e,{...j,info:t,color:A,fill:L[t.text]}),e.restore()}),e.restore()}),e.restore(),b.set(x,{left:E.startX,top:E.startY,width:R.contentWidth+6+14,height:R.contentHeight+12})}calcCellAutoHeight(e){var t;let{primaryWithCoord:r,style:a,data:o,row:s,col:c}=e,{leftOffset:l=0,rightOffset:u=0,topOffset:d=0,downOffset:f=0}=(o==null?void 0:o.fontRenderExtension)||{},p=r.isMergedMainCell?r.mergeInfo:r,m={startX:p.startX+l,endX:p.endX-u,startY:p.startY+d,endY:p.endY-f},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,s,c);if(!h)return;let g=this._dataValidationModel.getValidator(h.type);if(!g)return;let _=m.endX-m.startX,v=m.endY-m.startY,y=(t=(0,i.getCellValueOrigin)(o))==null?``:t;return qe(g.parseCellValue(y),(0,n.getFontStyleString)(a==null?void 0:a),_,v).cellAutoHeight}calcCellAutoWidth(e){var t;let{primaryWithCoord:r,style:a,data:o,row:s,col:c}=e,{leftOffset:l=0,rightOffset:u=0,topOffset:d=0,downOffset:f=0}=(o==null?void 0:o.fontRenderExtension)||{},p=r.isMergedMainCell?r.mergeInfo:r,m={startX:p.startX+l,endX:p.endX-u,startY:p.startY+d,endY:p.endY-f},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,s,c);if(!h)return;let g=this._dataValidationModel.getValidator(h.type);if(!g)return;let _=m.endX-m.startX,v=m.endY-m.startY,y=(t=(0,i.getCellValueOrigin)(o))==null?``:t;return qe(g.parseCellValue(y),(0,n.getFontStyleString)(a==null?void 0:a),_,v).calcAutoWidth}isHit(e,t){let{primaryWithCoord:n}=t,{endX:r}=n.isMergedMainCell?n.mergeInfo:n,{x:i}=e;return i>=r-14&&i<=r}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(V.id,o)}onPointerEnter(e,r){var i;return(i=(0,n.getCurrentTypeOfRenderer)(t.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(i=i.mainComponent)==null?void 0:i.setCursor(n.CURSOR_TYPE.POINTER)}onPointerLeave(e,r){var i;return(i=(0,n.getCurrentTypeOfRenderer)(t.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(i=i.mainComponent)==null?void 0:i.setCursor(n.CURSOR_TYPE.DEFAULT)}};Xe=k([O(0,t.ICommandService),O(1,t.IUniverInstanceService),O(2,(0,t.Inject)(n.IRenderManagerService)),O(3,(0,t.Inject)(i.SheetDataValidationModel))],Xe);var Ze=class extends Z{constructor(...e){super(...e),D(this,`id`,t.DataValidationType.LIST_MULTIPLE),D(this,`canvasRender`,this.injector.createInstance(Xe)),D(this,`dropdownType`,a.DataValidatorDropdownType.MULTIPLE_LIST)}};let Qe=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 $e(e,n,r,i,a,o,s=!0){let c=0,l=s?3:0;switch(a){case t.VerticalAlign.BOTTOM:c=n-i-l;break;case t.VerticalAlign.MIDDLE:c=(n-i)/2;break;default:c=l;break}c=Math.max(3,c);let u=0;switch(o){case t.HorizontalAlign.CENTER:u=(e-r)/2;break;case t.HorizontalAlign.RIGHT:u=e-r;break;default:break}return u=Math.max(6,u),{paddingLeft:u,paddingTop:c}}let et=class{constructor(e,t,n,r,i){this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=r,this._dataValidationModel=i,D(this,`_dropdownInfoMap`,new Map),D(this,`zIndex`,void 0)}_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,n,r,i,a,o,s){let{t:c=t.DEFAULT_STYLES.pd.t,b:l=t.DEFAULT_STYLES.pd.b}=s,u=r-14,d;switch(o){case t.VerticalAlign.MIDDLE:d=(i-4)/2;break;case t.VerticalAlign.BOTTOM:d=i-l-a-3+(a/2-4/2);break;default:d=c+3+(a/2-4/2);break}e.save(),e.translateWithPrecision(n.startX+u,n.startY+d),e.fillStyle=`#565656`,e.fill(Qe),e.restore()}drawWith(e,r,a){var o,s,c,l;let{primaryWithCoord:u,row:d,col:f,style:p,data:m,subUnitId:h}=r,g=u.isMergedMainCell?u.mergeInfo:u,_=u.isMergedMainCell?u.mergeInfo.startRow:d,v=u.isMergedMainCell?u.mergeInfo.startColumn:f,y=this._dataValidationModel.getRuleByLocation(r.unitId,r.subUnitId,_,v);if(!y)return;let b=this._dataValidationModel.getValidator(y.type);if(!b)return;let{leftOffset:x=0,rightOffset:S=0,topOffset:C=0,downOffset:w=0}=(m==null?void 0:m.fontRenderExtension)||{};if(!y||!b||!b||b.id.indexOf(t.DataValidationType.LIST)!==0||!b.skipDefaultFontRender(y))return;let T={startX:g.startX+x,endX:g.endX-S,startY:g.startY+C,endY:g.endY-w},E=T.endX-T.startX,D=T.endY-T.startY,O=this._ensureMap(h),k=this._generateKey(d,f),A=b.getListWithColorMap(y),j=(0,i.getCellValueOrigin)(m),M=`${j==null?``:j}`,N=A[M],{tb:P,vt:F,ht:I,pd:L}=p||{};P=(o=P)==null?t.WrapStrategy.WRAP:o,F=(s=F)==null?t.VerticalAlign.BOTTOM:s,I=(c=I)==null?t.DEFAULT_STYLES.ht:c,L=(l=L)==null?t.DEFAULT_STYLES.pd:l;let R=(0,n.getFontStyleString)(p).fontCache;if(y.renderMode===t.DataValidationRenderMode.ARROW){var z,B,V;let{l:r=t.DEFAULT_STYLES.pd.l,t:i=t.DEFAULT_STYLES.pd.t,r:o=t.DEFAULT_STYLES.pd.r,b:s=t.DEFAULT_STYLES.pd.b}=L,c=E-r-o-14-4,l=new n.DocSimpleSkeleton(M,R,P===t.WrapStrategy.WRAP,c,1/0);l.calculate();let u=l.getTotalWidth(),d=l.getTotalHeight(),{paddingTop:f,paddingLeft:m}=$e(c,D-i-s,u,d,F,I,!0);this._drawDownIcon(e,T,E,D,d,F,L),e.save(),e.translateWithPrecision(T.startX+r,T.startY+i),e.beginPath(),e.rect(0,0,E-r-o,D-i-s),e.clip(),e.translateWithPrecision(0,f),e.save(),e.translateWithPrecision(m,0),e.beginPath(),e.rect(0,0,c,d),e.clip(),n.Text.drawWith(e,{text:M,fontStyle:R,width:c,height:d,color:p==null||(z=p.cl)==null?void 0:z.rgb,strokeLine:!!(!(p==null||(B=p.st)==null)&&B.s),underline:!!(!(p==null||(V=p.ul)==null)&&V.s),warp:P===t.WrapStrategy.WRAP,hAlign:t.HorizontalAlign.LEFT},l),e.restore(),e.restore(),O.set(k,{left:T.endX-14+a.rowHeaderWidth,top:T.startY+i+a.columnHeaderHeight,width:14,height:D-i-s})}else{var H,U,W;e.save(),e.translateWithPrecision(T.startX,T.startY),e.beginPath(),e.rect(0,0,E,D),e.clip();let r=E-12-4-14-4,i=new n.DocSimpleSkeleton(M,R,P===t.WrapStrategy.WRAP,r,1/0);i.calculate();let o=i.getTotalWidth(),s=i.getTotalHeight(),c=s+2,l=Math.max(E-12,1),{paddingTop:u}=$e(l,D,o,c,F,I);e.translateWithPrecision(6,u),n.Rect.drawWith(e,{width:l,height:c,fill:N||`#ECECEC`,radius:8}),e.save(),e.translateWithPrecision(4,1),e.beginPath(),e.rect(0,0,r,s),e.clip(),n.Text.drawWith(e,{text:M,fontStyle:R,width:r,height:s,color:p==null||(H=p.cl)==null?void 0:H.rgb,strokeLine:!!(!(p==null||(U=p.st)==null)&&U.s),underline:!!(!(p==null||(W=p.ul)==null)&&W.s),warp:P===t.WrapStrategy.WRAP,hAlign:t.HorizontalAlign.LEFT},i),e.restore(),e.translateWithPrecision(r+4+4,(s-4)/2),e.fillStyle=`#565656`,e.fill(Qe),e.restore(),O.set(k,{left:T.startX+6+a.rowHeaderWidth,top:T.startY+u+a.columnHeaderHeight,width:l,height:c})}}calcCellAutoHeight(e){var r;let{primaryWithCoord:a,style:o,data:s,row:c,col:l}=e,u=a.isMergedMainCell?a.mergeInfo:a,{leftOffset:d=0,rightOffset:f=0,topOffset:p=0,downOffset:m=0}=(s==null?void 0:s.fontRenderExtension)||{},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,c,l);if(!h||h.renderMode===t.DataValidationRenderMode.TEXT)return;let g={startX:u.startX+d,endX:u.endX-f,startY:u.startY+p,endY:u.endY-m},_=g.endX-g.startX,v=(0,i.getCellValueOrigin)(s),y=`${v==null?``:v}`,{tb:b,pd:x}=o||{},{t:S=t.DEFAULT_STYLES.pd.t,b:C=t.DEFAULT_STYLES.pd.b}=x==null?{}:x;if(b=(r=b)==null?t.WrapStrategy.WRAP:r,h.renderMode===t.DataValidationRenderMode.ARROW){let{l:e=t.DEFAULT_STYLES.pd.l,r=t.DEFAULT_STYLES.pd.r}=x==null?{}:x,i=_-e-r-14-4,a=new n.DocSimpleSkeleton(y,(0,n.getFontStyleString)(o).fontCache,b===t.WrapStrategy.WRAP,i,1/0);return a.calculate(),a.getTotalHeight()+S+C+6}else{let e=Math.max(_-12-4-14-4,10),r=new n.DocSimpleSkeleton(y,(0,n.getFontStyleString)(o).fontCache,b===t.WrapStrategy.WRAP,e,1/0);return r.calculate(),r.getTotalHeight()+6+2}}calcCellAutoWidth(e){var r;let{primaryWithCoord:a,style:o,data:s,row:c,col:l}=e,u=a.isMergedMainCell?a.mergeInfo:a,{leftOffset:d=0,rightOffset:f=0,topOffset:p=0,downOffset:m=0}=(s==null?void 0:s.fontRenderExtension)||{},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,c,l);if(!h||h.renderMode===t.DataValidationRenderMode.TEXT)return;let g={startX:u.startX+d,endX:u.endX-f,startY:u.startY+p,endY:u.endY-m},_=g.endX-g.startX,v=(0,i.getCellValueOrigin)(s),y=`${v==null?``:v}`,{tb:b,pd:x}=o||{},{l:S=t.DEFAULT_STYLES.pd.l,r:C=t.DEFAULT_STYLES.pd.r}=x==null?{}:x;b=(r=b)==null?t.WrapStrategy.WRAP:r;let w=26;switch(h.renderMode){case t.DataValidationRenderMode.ARROW:w=18+C+S;break;case t.DataValidationRenderMode.CUSTOM:w=34+C+S+8/2+1;break;default:w=34+C+S+8/2+1}let T=_-w,E=new n.DocSimpleSkeleton(y,(0,n.getFontStyleString)(o).fontCache,b===t.WrapStrategy.WRAP,T,1/0);return E.calculate(),E.getTotalWidth()+w}isHit(e,n){let{subUnitId:r,row:i,col:a}=n,o=this._ensureMap(r).get(this._generateKey(i,a)),s=this._dataValidationModel.getRuleByLocation(n.unitId,n.subUnitId,i,a);if(!s||!o||s.renderMode===t.DataValidationRenderMode.TEXT)return!1;let{top:c,left:l,width:u,height:d}=o,{x:f,y:p}=e;return f>=l&&f<=l+u&&p>=c&&p<=c+d}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(V.id,o)}onPointerEnter(e,r){var i;(i=(0,n.getCurrentTypeOfRenderer)(t.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(i=i.mainComponent)==null||i.setCursor(n.CURSOR_TYPE.POINTER)}onPointerLeave(e,r){var i;(i=(0,n.getCurrentTypeOfRenderer)(t.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(i=i.mainComponent)==null||i.setCursor(n.CURSOR_TYPE.DEFAULT)}};et=k([O(0,t.IUniverInstanceService),O(1,(0,t.Inject)(t.LocaleService)),O(2,t.ICommandService),O(3,(0,t.Inject)(n.IRenderManagerService)),O(4,(0,t.Inject)(i.SheetDataValidationModel))],et);var tt=class extends Z{constructor(...e){super(...e),D(this,`id`,t.DataValidationType.LIST),D(this,`canvasRender`,this.injector.createInstance(et)),D(this,`dropdownType`,a.DataValidatorDropdownType.LIST),D(this,`optionsInput`,ze.componentKey),D(this,`formulaInput`,i.LIST_FORMULA_INPUT_NAME)}},nt=class extends Z{constructor(...e){super(...e),D(this,`id`,t.DataValidationType.TEXT_LENGTH),D(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}},rt=class extends Z{constructor(...e){super(...e),D(this,`id`,t.DataValidationType.WHOLE),D(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}};let it=class extends t.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[`DataValidationIcon`,pe],[L,Ae],[ze.componentKey,ze],[Be.componentKey,Be],...Re].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Ge,rt,nt,We,He,tt,Ze,Ue].forEach(e=>{let 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)})}};it=k([O(0,(0,t.Inject)(t.Injector)),O(1,(0,t.Inject)(o.ComponentManager)),O(2,(0,t.Inject)(a.DataValidatorRegistryService))],it);let Q=class extends t.Plugin{constructor(e=M,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},M,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(j,o)}onStarting(){[[A],[I],[G],[K],[Y],[J],[q],[it]].forEach(e=>{this._injector.add(e)}),[U,V,H,z,R,B].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(q),this._injector.get(J),this._injector.get(n.IRenderManagerService).registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,[se])}onRendered(){this._injector.get(it),this._injector.get(Y)}onSteady(){this._injector.get(K)}};D(Q,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),D(Q,`packageName`,S),D(Q,`version`,C),D(Q,`type`,t.UniverInstanceType.UNIVER_SHEET),Q=k([O(1,(0,t.Inject)(t.Injector)),O(2,t.ICommandService),O(3,t.IConfigService)],Q);let $=class extends t.Plugin{constructor(e=M,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},M,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(j,o)}onStarting(){[[A],[I],[G],[K],[Y],[J],[q],[N],[it]].forEach(e=>{this._injector.add(e)}),[U,V,H,z,R,B].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(q),this._injector.get(J),this._injector.get(N),this._injector.get(G),this._injector.get(n.IRenderManagerService).registerRenderModule(t.UniverInstanceType.UNIVER_SHEET,[se])}onRendered(){this._injector.get(it),this._injector.get(Y)}onSteady(){this._injector.get(K)}};D($,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),D($,`packageName`,S),D($,`version`,C),D($,`type`,t.UniverInstanceType.UNIVER_SHEET),$=k([(0,t.DependentOn)(i.UniverSheetsDataValidationPlugin),O(1,(0,t.Inject)(t.Injector)),O(2,t.ICommandService),O(3,t.IConfigService)],$),Object.defineProperty(e,`BaseSheetDataValidatorView`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,`UniverSheetsDataValidationMobileUIPlugin`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,`UniverSheetsDataValidationUIPlugin`,{enumerable:!0,get:function(){return $}})});
|
package/lib/umd/locale/ca-ES.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.UniverSheetsDataValidationUiCaES=t())})(this,function(){return{dataValidation:{title:`Validació de dades`,validFail:{value:`Si us plau, introdueix un valor`,common:`Si us plau, introdueix un valor o una fórmula`,number:`Si us plau, introdueix un número o una fórmula`,formula:`Si us plau, introdueix una fórmula`,integer:`Si us plau, introdueix un enter o una fórmula`,date:`Si us plau, introdueix una data o una fórmula`,list:`Si us plau, introdueix opcions`,listInvalid:`La font de la llista ha de ser una llista delimitada o una referència a una sola fila o columna`,checkboxEqual:`Introdueix valors diferents per als continguts de cel·la marcats i desmarcats.`,formulaError:`L’interval de referència conté dades invisibles, ajusta l’interval`,listIntersects:`L’interval seleccionat no pot creuar-se amb l’àmbit de les regles`,primitive:`No es permeten fórmules per a valors personalitzats marcats i desmarcats.`},panel:{title:`Gestió de la validació de dades`,addTitle:`Crea una nova validació de dades`,removeAll:`Elimina-ho tot`,add:`Afegeix regla`,range:`Intervals`,type:`Tipus`,options:`Opcions avançades`,operator:`Operador`,removeRule:`Elimina`,done:`Fet`,formulaPlaceholder:`Si us plau, introdueix valor o fórmula`,valuePlaceholder:`Si us plau, introdueix valor`,formulaAnd:`i`,invalid:`Invàlid`,showWarning:`Mostra advertència`,rejectInput:`Rebutja l’entrada`,messageInfo:`Missatge d’ajuda`,showInfo:`Mostra text d’ajuda per a la cel·la seleccionada`,rangeError:`Els intervals no són vàlids`,allowBlank:`Permet valors en blanc`},operators:{between:`entre`,greaterThan:`més gran que`,greaterThanOrEqual:`més gran o igual que`,lessThan:`menys que`,lessThanOrEqual:`menys o igual que`,equal:`igual`,notEqual:`no igual`,notBetween:`no entre`,legal:`és tipus legal`},ruleName:{between:`Està entre {FORMULA1} i {FORMULA2}`,greaterThan:`És més gran que {FORMULA1}`,greaterThanOrEqual:`És més gran o igual que {FORMULA1}`,lessThan:`És menys que {FORMULA1}`,lessThanOrEqual:`És menys o igual que {FORMULA1}`,equal:`És igual a {FORMULA1}`,notEqual:`No és igual a {FORMULA1}`,notBetween:`No està entre {FORMULA1} i {FORMULA2}`,legal:`És un {TYPE} legal`},errorMsg:{between:`El valor ha d’estar entre {FORMULA1} i {FORMULA2}`,greaterThan:`El valor ha de ser més gran que {FORMULA1}`,greaterThanOrEqual:`El valor ha de ser més gran o igual que {FORMULA1}`,lessThan:`El valor ha de ser menys que {FORMULA1}`,lessThanOrEqual:`El valor ha de ser menys o igual que {FORMULA1}`,equal:`El valor ha de ser igual a {FORMULA1}`,notEqual:`El valor no ha de ser igual a {FORMULA1}`,notBetween:`El valor no ha d’estar entre {FORMULA1} i {FORMULA2}`,legal:`El valor ha de ser un {TYPE} legal`},any:{title:`Qualsevol valor`,error:`El contingut d’aquesta cel·la incompleix la regla de validació`},date:{title:`Data`,operators:{between:`entre`,greaterThan:`després de`,greaterThanOrEqual:`en o després de`,lessThan:`abans de`,lessThanOrEqual:`en o abans de`,equal:`igual`,notEqual:`no igual`,notBetween:`no entre`,legal:`és una data legal`},ruleName:{between:`està entre {FORMULA1} i {FORMULA2}`,greaterThan:`és després de {FORMULA1}`,greaterThanOrEqual:`és en o després de {FORMULA1}`,lessThan:`és abans de {FORMULA1}`,lessThanOrEqual:`és en o abans de {FORMULA1}`,equal:`és {FORMULA1}`,notEqual:`no és {FORMULA1}`,notBetween:`no està entre {FORMULA1}`,legal:`és una data legal`},errorMsg:{between:`El valor ha de ser una data legal i estar entre {FORMULA1} i {FORMULA2}`,greaterThan:`El valor ha de ser una data legal i després de {FORMULA1}`,greaterThanOrEqual:`El valor ha de ser una data legal i en o després de {FORMULA1}`,lessThan:`El valor ha de ser una data legal i abans de {FORMULA1}`,lessThanOrEqual:`El valor ha de ser una data legal i en o abans de {FORMULA1}`,equal:`El valor ha de ser una data legal i {FORMULA1}`,notEqual:`El valor ha de ser una data legal i no {FORMULA1}`,notBetween:`El valor ha de ser una data legal i no estar entre {FORMULA1}`,legal:`El valor ha de ser una data legal`}},list:{title:`Desplegable`,name:`El valor conté un del rang`,error:`L’entrada ha d’estar dins del rang especificat`,emptyError:`Si us plau, introdueix un valor`,add:`Afegeix`,dropdown:`Selecciona`,options:`Opcions`,customOptions:`Personalitzat`,refOptions:`D’un interval`,formulaError:`La font de la llista ha de ser una llista delimitada de dades o una referència a una sola fila o columna.`,edit:`Edita`},listMultiple:{title:`Desplegable-múltiple`,dropdown:`Selecció múltiple`},textLength:{title:`Longitud del text`,errorMsg:{between:`La longitud del text ha d’estar entre {FORMULA1} i {FORMULA2}`,greaterThan:`La longitud del text ha de ser més gran que {FORMULA1}`,greaterThanOrEqual:`La longitud del text ha de ser més gran o igual que {FORMULA1}`,lessThan:`La longitud del text ha de ser menys que {FORMULA1}`,lessThanOrEqual:`La longitud del text ha de ser menys o igual que {FORMULA1}`,equal:`La longitud del text ha de ser {FORMULA1}`,notEqual:`La longitud del text no ha de ser {FORMULA1}`,notBetween:`La longitud del text no ha d’estar entre {FORMULA1}`}},decimal:{title:`Número`},whole:{title:`Enter`},checkbox:{title:`Casella de selecció`,error:`El contingut d’aquesta cel·la incompleix la seva regla de validació`,tips:`Utilitza valors personalitzats dins de les cel·les`,checked:`Valor seleccionat`,unchecked:`Valor no seleccionat`},custom:{title:`Fórmula personalitzada`,error:`El contingut d’aquesta cel·la incompleix la seva regla de validació`,validFail:`Si us plau, introdueix una fórmula vàlida`,ruleName:`La fórmula personalitzada és {FORMULA1}`},alert:{title:`Error`,ok:`OK`},error:{title:`Invàlid:`},renderMode:{arrow:`Fletxa`,chip:`Xip`,text:`Text pla`,label:`Estil de visualització`},showTime:{label:`Mostra el selector d’hora`}}}});
|
package/lib/umd/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.UniverSheetsDataValidationUiEnUS=t())})(this,function(){return{dataValidation:{title:`Data validation`,validFail:{value:`Please input a value`,common:`Please input value or formula`,number:`Please input number or formula`,formula:`Please input formula`,integer:`Please input integer or formula`,date:`Please input date or formula`,list:`Please input options`,listInvalid:`The list source must be a delimited list or a reference to a single row or column`,checkboxEqual:`Enter different values for ticked and unticked cell contents.`,formulaError:`The reference range contains invisible data, please readjust the range`,listIntersects:`The selected range cannot intersect with the scope of the rules`,primitive:`Formulas are not permitted for custom ticked and unticked values.`},panel:{title:`Data validation management`,addTitle:`Create new data validation`,removeAll:`Remove All`,add:`Add Rule`,range:`Ranges`,type:`Type`,options:`Advance options`,operator:`Operator`,removeRule:`Remove`,done:`Done`,formulaPlaceholder:`Please input value or formula`,valuePlaceholder:`Please input value`,formulaAnd:`and`,invalid:`Invalid`,showWarning:`Show warning`,rejectInput:`Reject input`,messageInfo:`Helper message`,showInfo:`Show help text for a selected cell`,rangeError:`Ranges are not legal`,allowBlank:`Allow blank values`},operators:{between:`between`,greaterThan:`greater than`,greaterThanOrEqual:`greater than or equal`,lessThan:`less than`,lessThanOrEqual:`less than or equal`,equal:`equal`,notEqual:`not equal`,notBetween:`not between`,legal:`is legal type`},ruleName:{between:`Is between {FORMULA1} and {FORMULA2}`,greaterThan:`Is greater than {FORMULA1}`,greaterThanOrEqual:`Is greater than or equal to {FORMULA1}`,lessThan:`Is less than {FORMULA1}`,lessThanOrEqual:`Is less than or equal to {FORMULA1}`,equal:`Is equal to {FORMULA1}`,notEqual:`Is not equal to {FORMULA1}`,notBetween:`Is not between {FORMULA1} and {FORMULA2}`,legal:`Is a legal {TYPE}`},errorMsg:{between:`Value must be between {FORMULA1} and {FORMULA2}`,greaterThan:`Value must be greater than {FORMULA1}`,greaterThanOrEqual:`Value must be greater than or equal to {FORMULA1}`,lessThan:`Value must be less than {FORMULA1}`,lessThanOrEqual:`Value must be less than or equal to {FORMULA1}`,equal:`Value must be equal to {FORMULA1}`,notEqual:`Value must be not equal to {FORMULA1}`,notBetween:`Value must be not between {FORMULA1} and {FORMULA2}`,legal:`Value must be a legal {TYPE}`},any:{title:`Any value`,error:`The content of this cell violates the validation rule`},date:{title:`Date`,operators:{between:`between`,greaterThan:`after`,greaterThanOrEqual:`on or after`,lessThan:`before`,lessThanOrEqual:`on or before`,equal:`equal`,notEqual:`not equal`,notBetween:`not between`,legal:`is a legal date`},ruleName:{between:`is between {FORMULA1} and {FORMULA2}`,greaterThan:`is after {FORMULA1}`,greaterThanOrEqual:`is on or after {FORMULA1}`,lessThan:`is before {FORMULA1}`,lessThanOrEqual:`is on or before {FORMULA1}`,equal:`is {FORMULA1}`,notEqual:`is not {FORMULA1}`,notBetween:`is not between {FORMULA1}`,legal:`is a legal date`},errorMsg:{between:`Value must be a legal date and between {FORMULA1} and {FORMULA2}`,greaterThan:`Value must be a legal date and after {FORMULA1}`,greaterThanOrEqual:`Value must be a legal date and on or after {FORMULA1}`,lessThan:`Value must be a legal date and before {FORMULA1}`,lessThanOrEqual:`Value must be a legal date and on or before {FORMULA1}`,equal:`Value must be a legal date and {FORMULA1}`,notEqual:`Value must be a legal date and not {FORMULA1}`,notBetween:`Value must be a legal date and not between {FORMULA1}`,legal:`Value must be a legal date`}},list:{title:`Dropdown`,name:`Value contains one from range`,error:`Input must fall within specified range`,emptyError:`Please enter a value`,add:`Add`,dropdown:`Select`,options:`Options`,customOptions:`Custom`,refOptions:`From a range`,formulaError:`The list source must be a delimited list of data, or a reference to a single row or column.`,edit:`Edit`},listMultiple:{title:`Dropdown-Multiple`,dropdown:`Multiple select`},textLength:{title:`Text length`,errorMsg:{between:`Text length must be between {FORMULA1} and {FORMULA2}`,greaterThan:`Text length must be after {FORMULA1}`,greaterThanOrEqual:`Text length must be on or after {FORMULA1}`,lessThan:`Text length must be before {FORMULA1}`,lessThanOrEqual:`Text length must be on or before {FORMULA1}`,equal:`Text length must be {FORMULA1}`,notEqual:`Text length must be not {FORMULA1}`,notBetween:`Text length must be not between {FORMULA1}`}},decimal:{title:`Number`},whole:{title:`Integer`},checkbox:{title:`Checkbox`,error:`This cell's contents violate its validation rule`,tips:`Use custom values within cells`,checked:`Selected value`,unchecked:`Unselected value`},custom:{title:`Custom formula`,error:`This cell's contents violate its validation rule`,validFail:`Please input a valid formula`,ruleName:`Custom formula is {FORMULA1}`},alert:{title:`Error`,ok:`OK`},error:{title:`Invalid:`},renderMode:{arrow:`Arrow`,chip:`Chip`,text:`Plain text`,label:`Display style`},showTime:{label:`Show TimePicker`}}}});
|