@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/cjs/index.js
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
|
-
"use strict";var xt=Object.defineProperty;var jt=(e,t,n)=>t in e?xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var A=(e,t,n)=>jt(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),P=require("@univerjs/engine-render"),j=require("@univerjs/sheets"),_=require("@univerjs/sheets-data-validation"),Y=require("@univerjs/data-validation"),D=require("@univerjs/ui"),ie=require("rxjs"),Ft=require("@univerjs/sheets-numfmt"),H=require("@univerjs/sheets-ui"),V=require("@univerjs/design"),T=require("react"),g=require("react/jsx-runtime"),st=require("@univerjs/engine-formula"),ht=require("@univerjs/sheets-formula-ui"),kt="@univerjs/sheets-data-validation-ui",Nt="0.17.0",ke={name:kt,version:Nt};var Bt=Object.getOwnPropertyDescriptor,Wt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Bt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ft=(e,t)=>(n,a)=>t(n,a,e);let he=class extends o.Disposable{constructor(t,n){super();A(this,"_open$",new ie.BehaviorSubject(!1));A(this,"open$",this._open$.pipe(ie.distinctUntilChanged()));A(this,"_activeRule");A(this,"_activeRule$",new ie.BehaviorSubject(void 0));A(this,"activeRule$",this._activeRule$.asObservable());A(this,"_closeDisposable",null);A(this,"_focusFormulaEditorActiveRuleSubUnitId",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(a=>!a)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===We&&(a.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}};he=Wt([ft(0,o.IUniverInstanceService),ft(1,D.ISidebarService)],he);const Ne="sheets-data-validation-ui.config",Be={},Se="#ECECEC";var $t=Object.getOwnPropertyDescriptor,Ht=(e,t,n,a)=>{for(var r=a>1?void 0:a?$t(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ye=(e,t)=>(n,a)=>t(n,a,e);let Me=class extends o.Disposable{constructor(e,t,n,a,r,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=a,this._localeService=r,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(j.VALIDATE_CELL,{handler:async(e,t,n)=>{const a=await e,{row:r,col:i,unitId:s,subUnitId:c}=t,l=this._dataValidationModel.getRuleIdByLocation(s,c,r,i),d=l?this._dataValidationModel.getRuleById(s,c,l):void 0;if(a===!1)return n(Promise.resolve(!1));if(!d||d.errorStyle!==o.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(d.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,c,r,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(d,{row:r,col:i,unitId:s,subUnitId:c})},footer:{title:T.createElement(V.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:T.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Me=Ht([ye(0,o.Inject(j.SheetInterceptorService)),ye(1,o.Inject(_.SheetDataValidationModel)),ye(2,o.Inject(Y.DataValidatorRegistryService)),ye(3,D.IDialogService),ye(4,o.Inject(o.LocaleService)),ye(5,o.Inject(_.SheetsDataValidationValidatorService))],Me);var Yt=Object.getOwnPropertyDescriptor,Xt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Yt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},de=(e,t)=>(n,a)=>t(n,a,e);const Ge=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 zt(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 _e=class extends o.Disposable{constructor(t,n,a,r,i,s,c,l,d,h,p){super();A(this,"_activeDropdown");A(this,"_activeDropdown$",new ie.Subject);A(this,"_currentPopup",null);A(this,"activeDropdown$",this._activeDropdown$.asObservable());A(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=a,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=c,this._commandService=l,this._editorBridgeService=d,this._injector=h,this._configService=p,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,n,a,r){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 c=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),a,r);if(!c)return;const l=this._dataValidatorRegistryService.getValidatorItem(c.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var L,f,y,I,w,O;const{location:n}=t,{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._sheetDataValidationModel.getRuleByLocation(i,s,a,r);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(h!=null&&h.dropdownType))return;let p;const u=async(m,v)=>{var $,B,z;if(!m)return!0;const C=m,U=l.getCell(a,r),F=C.format(v==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),k=($=o.numfmt.parseDate(F))==null?void 0:$.v,N=v==="time"?k%1:k,M=c.getStyles().getStyleByCell(U),x=(z=(B=M==null?void 0:M.n)==null?void 0:B.pattern)!=null?z:"";return d.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:N,unitId:i,subUnitId:s,row:a,column:r,worksheet:l,workbook:c,interceptValue:F.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},d)?(await this._commandService.executeCommand(j.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:N,t:2,p:null,f:null,si:null,s:{n:{pattern:zt(v,x)}}}}),await this._commandService.executeCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:D.KeyCode.ESC}),!0):(this._injector.has(Me)&&this._injector.get(Me).showReject(h.getRuleFinalError(d,{row:a,col:r,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const m=_.getCellValueOrigin(l.getCellRaw(a,r)),v=Ge(m),C=!!((L=d.bizInfo)!=null&&L.showTime);S={location:n,type:"datepicker",props:{showTime:C,onChange:U=>u(U,C?"datetime":"date"),defaultValue:v,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const m=_.getCellValueOrigin(l.getCellRaw(a,r)),v=Ge(m);S={location:n,type:"datepicker",props:{onChange:C=>u(C,"time"),defaultValue:v,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const m=_.getCellValueOrigin(l.getCellRaw(a,r)),v=Ge(m);S={location:n,type:"datepicker",props:{onChange:C=>u(C,"datetime"),defaultValue:v,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const m=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,v=async M=>{const x=_.serializeListOptions(M),$={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:x,p:null,f:null,si:null}};return this._commandService.executeCommand(j.SetRangeValuesCommand.id,$),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:D.KeyCode.ESC}),!m},C=(d==null?void 0:d.renderMode)===o.DataValidationRenderMode.CUSTOM||(d==null?void 0:d.renderMode)===void 0,U=h.getListWithColor(d,i,s),F=_.getDataValidationCellValue(l.getCellRaw(a,r)),k=()=>{this._commandService.executeCommand(Ie.id,{ruleId:d.uid}),p==null||p.dispose()},N=U.map(M=>({label:M.label,value:M.label,color:C||M.color?M.color||Se:"transparent"}));S={location:n,type:"list",props:{onChange:M=>v(M),options:N,onEdit:k,defaultValue:F,multiple:m,showEdit:(y=(f=this._configService.getConfig(Ne))==null?void 0:f.showEditOnDropdown)!=null?y:!0,showSearch:(w=(I=this._configService.getConfig(Ne))==null?void 0:I.showSearchOnDropdown)!=null?w:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{S={type:"cascader",props:{onChange:v=>{const C={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:v.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(j.SetRangeValuesCommand.id,C),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:D.KeyCode.ESC}),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(a,r)).split("/"),options:JSON.parse((O=d.formula1)!=null?O:"[]")},location:n};break}case Y.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:v=>{const C={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(j.SetRangeValuesCommand.id,C),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(H.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:D.KeyCode.ESC}),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(a,r))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(p=this._cellDropdownManagerService.showDropdown({...S,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const R=new o.DisposableCollection;R.add(p),R.add({dispose:()=>{var m,v;(v=(m=this._activeDropdown)==null?void 0:m.onHide)==null||v.call(m)}}),this._currentPopup=R}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,a,r,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const c=s.getSheetBySheetId(n);if(!c)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),c.getSheetId(),a,r);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!d||!d.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:c,row:a,col:r,unitId:t,subUnitId:n},onHide:i})}};_e=Xt([de(0,o.IUniverInstanceService),de(1,o.Inject(Y.DataValidatorRegistryService)),de(2,D.IZenZoneService),de(3,o.Inject(_.SheetDataValidationModel)),de(4,o.Inject(j.SheetsSelectionsService)),de(5,o.Inject(H.ISheetCellDropdownManagerService)),de(6,o.Inject(_.SheetDataValidationModel)),de(7,o.ICommandService),de(8,H.IEditorBridgeService),de(9,o.Inject(o.Injector)),de(10,o.IConfigService)],_e);const We="DataValidationPanel",Ie={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:a}=t,r=e.get(he),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),c=e.get(D.ISidebarService),l=j.getSheetCommandTarget(s);if(!l)return!1;const{unitId:d,subUnitId:h}=l,p=n?i.getRuleById(d,h,n):void 0;r.open(),r.setActiveRule(p&&{unitId:d,subUnitId:h,rule:p});const u=c.open({id:We,header:{title:a?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:We},width:312,onClose:()=>r.close()});return r.setCloseDisposable(u),!0}},gt={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(he).close(),!0}},Rt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),n=e.get(he);return n.open(),n.isOpen?t.executeCommand(gt.id):t.executeCommand(Ie.id),!0}},ze={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(_e),{unitId:a,subUnitId:r,row:i,column:s}=t,c=n.activeDropdown,l=c==null?void 0:c.location;return l&&l.unitId===a&&l.subUnitId===r&&l.row===i&&l.col===s||n.showDataValidationDropdown(a,r,i,s),!0}},Dt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(_e).hideDropdown(),!0):!1}},Ke={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),n=j.getSheetCommandTarget(t);if(!n)return!1;const{workbook:a,worksheet:r}=n,i=_.createDefaultNewRule(e),s=e.get(o.ICommandService),c=a.getUnitId(),l=r.getSheetId(),d={rule:i,unitId:c,subUnitId:l};return s.syncExecuteCommand(_.AddSheetDataValidationCommand.id,d)?(s.syncExecuteCommand(Ie.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Kt=Object.getOwnPropertyDescriptor,Zt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Re=(e,t)=>(n,a)=>t(n,a,e);const me="SHEET_DATA_VALIDATION_ALERT";let Ue=class extends o.Disposable{constructor(e,t,n,a,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=a,this._zenZoneService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ie.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),a=n.getSheetBySheetId(e.location.subUnitId);if(!a)return;const r=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!r){this._cellAlertManagerService.removeAlert(me);return}if(this._dataValidationModel.validator(r,{...e.location,workbook:n,worksheet:a})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(me),c=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(c&&c.row===e.location.row&&c.col===e.location.col&&c.subUnitId===e.location.subUnitId&&c.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(me);return}const l=this._dataValidationModel.getValidator(r.type);if(!l){this._cellAlertManagerService.removeAlert(me);return}this._cellAlertManagerService.showAlert({type:H.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(r,e.location),location:e.location,width:200,height:74,key:me});return}}this._cellAlertManagerService.removeAlert(me)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(me)}))}};Ue=Zt([Re(0,o.Inject(H.HoverManagerService)),Re(1,o.Inject(H.CellAlertManagerService)),Re(2,o.IUniverInstanceService),Re(3,o.Inject(o.LocaleService)),Re(4,D.IZenZoneService),Re(5,o.Inject(_.SheetDataValidationModel))],Ue);var Gt=Object.getOwnPropertyDescriptor,qt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Gt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},qe=(e,t)=>(n,a)=>t(n,a,e);let be=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=(a,r)=>{const{source:i,target:s,unitId:c,subUnitId:l}=a,d=this._sheetDataValidationModel.getRuleObjectMatrix(c,l).clone(),h=H.virtualizeDiscreteRanges([i,s]),[p,u]=h.ranges,{mapFunc:S}=h,R={row:p.startRow,col:p.startColumn},L=j.AutoFillTools.getAutoFillRepeatRange(p,u),f=new o.ObjectMatrix,y=new Set;L.forEach(v=>{const C=v.repeatStartCell,U=v.relativeRange,F={startRow:R.row,startColumn:R.col,endColumn:R.col,endRow:R.row},k={startRow:C.row,startColumn:C.col,endColumn:C.col,endRow:C.row};o.Range.foreach(U,(N,M)=>{const x=o.Rectangle.getPositionRange({startRow:N,startColumn:M,endColumn:M,endRow:N},F),{row:$,col:B}=S(x.startRow,x.startColumn),z=this._sheetDataValidationModel.getRuleIdByLocation(c,l,$,B)||"",ae=o.Rectangle.getPositionRange({startRow:N,startColumn:M,endColumn:M,endRow:N},k),{row:Z,col:oe}=S(ae.startRow,ae.startColumn);f.setValue(Z,oe,z),y.add(z)})});const I=Array.from(y).map(v=>({id:v,ranges:o.queryObjectMatrix(f,C=>C===v)}));d.addRangeRules(I);const w=d.diff(this._sheetDataValidationModel.getRules(c,l)),{redoMutations:O,undoMutations:m}=_.getDataValidationDiffMutations(c,l,w,this._injector,"patched",r===j.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT);return{undos:m,redos:O}},n={id:_.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:a=>{const{source:r,unitId:i,subUnitId:s}=a;for(const c of r.rows)for(const l of r.cols){const d=this._sheetDataValidationModel.getRuleByLocation(i,s,c,l);if(d&&d.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(j.AUTO_FILL_APPLY_TYPE.SERIES,!0);return}}},onFillData:(a,r,i)=>i===j.AUTO_FILL_APPLY_TYPE.COPY||i===j.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||i===j.AUTO_FILL_APPLY_TYPE.SERIES?t(a,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};be=qt([qe(0,j.IAutoFillService),qe(1,o.Inject(_.SheetDataValidationModel)),qe(2,o.Inject(o.Injector))],be);var Jt=Object.getOwnPropertyDescriptor,Qt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Jt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Je=(e,t)=>(n,a)=>t(n,a,e);let Te=class extends o.Disposable{constructor(t,n,a){super();A(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=a,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:_.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,a)=>this._collect(t,n,a),onPasteCells:(t,n,a,r)=>{const{copyType:i=H.COPY_TYPE.COPY,pasteType:s}=r,{range:c}=t||{},{range:l,unitId:d,subUnitId:h}=n;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:c,unitId:d,subUnitId:h})}})}_collect(t,n,a){const r=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:r};const i=this._injector.invoke(l=>j.rangeToDiscreteRange(a,l,t,n));if(!i)return;const{rows:s,cols:c}=i;s.forEach((l,d)=>{c.forEach((h,p)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);r.setValue(d,p,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===H.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([H.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,H.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,H.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,H.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=this._copyInfo;if(n.unitId!==r||i!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:p}=H.virtualizeDiscreteRanges([n.copyRange,t]),u=H.getRepeatRange(d,h,!0),S=new Map;u.forEach(({startRange:y})=>{var I;(I=this._copyInfo)==null||I.matrix.forValue((w,O,m)=>{const v=o.Rectangle.getPositionRange({startRow:w,endRow:w,startColumn:O,endColumn:O},y),C=`${i}-${m}`,U=this._sheetDataValidationModel.getRuleById(r,i,m);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,C)&&U&&S.set(C,{...U,uid:C});const{row:F,col:k}=p(v.startRow,v.startColumn);l.add(C),c.setValue(F,k,C)})});const R=Array.from(l).map(y=>({id:y,ranges:o.queryObjectMatrix(c,I=>I===y)}));s.addRangeRules(R);const{redoMutations:L,undoMutations:f}=_.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),S.values()),this._injector,"patched",!1);return{redos:L,undos:f}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:p}=H.virtualizeDiscreteRanges([n.copyRange,t]);H.getRepeatRange(d,h,!0).forEach(({startRange:f})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((I,w,O)=>{const m=o.Rectangle.getPositionRange({startRow:I,endRow:I,startColumn:w,endColumn:w},f),{row:v,col:C}=p(m.startRow,m.startColumn);c.setValue(v,C,O),l.add(O)})});const S=Array.from(l).map(f=>({id:f,ranges:o.queryObjectMatrix(c,y=>y===f)}));s.addRangeRules(S);const{redoMutations:R,undoMutations:L}=_.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:R,undos:L}}}};Te=Qt([Je(0,H.ISheetClipboardService),Je(1,o.Inject(_.SheetDataValidationModel)),Je(2,o.Inject(o.Injector))],Te);var en=Object.getOwnPropertyDescriptor,tn=(e,t,n,a)=>{for(var r=a>1?void 0:a?en(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Qe=(e,t)=>(n,a)=>t(n,a,e);let Oe=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:a}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[j.WorkbookEditablePermission],rangeTypes:[j.RangeProtectionPermissionEditPoint],worksheetTypes:[j.WorksheetEditPermission,j.WorksheetSetCellStylePermission]},a,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}if(e.id===_.UpdateSheetDataValidationRangeCommand.id){const{unitId:t,subUnitId:n,ranges:a}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[j.WorkbookEditablePermission],rangeTypes:[j.RangeProtectionPermissionEditPoint],worksheetTypes:[j.WorksheetEditPermission,j.WorksheetSetCellStylePermission]},a,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Oe=tn([Qe(0,o.Inject(o.LocaleService)),Qe(1,o.ICommandService),Qe(2,o.Inject(j.SheetPermissionCheckController))],Oe);const wt="sheet.menu.data-validation";function nn(e){return{id:wt,type:D.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:D.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(e,{workbookTypes:[j.WorkbookEditablePermission],worksheetTypes:[j.WorksheetSetCellStylePermission,j.WorksheetEditPermission],rangeTypes:[j.RangeProtectionPermissionEditPoint]})}}function an(e){return{id:Ie.id,title:"dataValidation.panel.title",type:D.MenuItemType.BUTTON}}function rn(e){return{id:Ke.id,title:"dataValidation.panel.add",type:D.MenuItemType.BUTTON}}const on={[D.RibbonDataGroup.RULES]:{[wt]:{order:0,menuItemFactory:nn,[Ie.id]:{order:0,menuItemFactory:an},[Ke.id]:{order:1,menuItemFactory:rn}}}};var sn=Object.getOwnPropertyDescriptor,Vt=(e,t,n,a)=>{for(var r=a>1?void 0:a?sn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},q=(e,t)=>(n,a)=>t(n,a,e);const Et={tr:{size:6,color:"#fe4b4b"}};let Ae=class extends o.RxDisposable{constructor(e,t,n,a,r,i,s,c,l,d,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=a,this._autoHeightController=r,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=c,this._sheetInterceptorService=l,this._dataValidationCacheService=d,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(on)}_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:a,sheetId:r,row:i,column:s}=t,c=this._univerInstanceService.getUniverSheetInstance(a);if(!c)return;const l=this._sheetDataValidationModel.getRuleByLocation(a,r,i,s);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(d!=null&&d.dropdownType))return;const h=c.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,u=p==null?void 0:p.location;if(u&&u.unitId===a&&u.subUnitId===r&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:a,subUnitId:r,row:i,col:s,workbook:c,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(j.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:j.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var y,I,w,O,m;const{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,a,r);if(!d)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);if(!h)return n(e);const p=(y=this._dataValidationCacheService.getValue(i,s,a,r))!=null?y:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=t.rawData;let R;const L={get value(){var v;return R!==void 0||(R=(v=_.getCellValueOrigin(S))!=null?v:null),R}},f={get value(){var v;return`${(v=L.value)!=null?v:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Et: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:((w=e==null?void 0:e.fontRenderExtension)==null?void 0:w.isSkip)||((O=u==null?void 0:u.skipDefaultFontRender)==null?void 0:O.call(u,h,L.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,f.value,{get style(){const v=c.getStyles();return(typeof(e==null?void 0:e.s)=="string"?v.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,r)},e.interceptorAutoHeight=()=>{var F,k,N,M,x,$;const v=(k=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:k.skeleton;if(!v)return;const C=v.worksheet.getMergedCell(a,r),U={data:e,style:v.getStyles().getStyleByCell(e),primaryWithCoord:v.getCellWithCoordByIndex((N=C==null?void 0:C.startRow)!=null?N:a,(M=C==null?void 0:C.startColumn)!=null?M:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return($=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:$.call(x,U)},e.interceptorAutoWidth=()=>{var F,k,N,M,x,$;const v=(k=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:k.skeleton;if(!v)return;const C=v.worksheet.getMergedCell(a,r),U={data:e,style:v.getStyles().getStyleByCell(e),primaryWithCoord:v.getCellWithCoordByIndex((N=C==null?void 0:C.startRow)!=null?N:a,(M=C==null?void 0:C.startColumn)!=null?M:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return($=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:$.call(x,U)},e.coverable=((m=e==null?void 0:e.coverable)!=null?m:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var a;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};Ae=Vt([q(0,o.ICommandService),q(1,D.IMenuManagerService),q(2,P.IRenderManagerService),q(3,o.IUniverInstanceService),q(4,o.Inject(H.AutoHeightController)),q(5,o.Inject(_e)),q(6,o.Inject(_.SheetDataValidationModel)),q(7,o.Inject(Y.DataValidatorRegistryService)),q(8,o.Inject(j.SheetInterceptorService)),q(9,o.Inject(_.DataValidationCacheService)),q(10,o.Optional(H.IEditorBridgeService))],Ae);let St=class extends o.RxDisposable{constructor(e,t,n,a,r,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=a,this._sheetInterceptorService=r,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(j.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:j.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var f,y,I,w,O;const{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,a,r);if(!d)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);if(!h)return n(e);const p=(f=this._dataValidationCacheService.getValue(i,s,a,r))!=null?f:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=l.getCellRaw(a,r),R=_.getCellValueOrigin(S),L=`${R!=null?R:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Et: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)||((w=u==null?void 0:u.skipDefaultFontRender)==null?void 0:w.call(u,h,R,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,L,{get style(){const m=c.getStyles();return(typeof(e==null?void 0:e.s)=="string"?m.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,r)},e.interceptorAutoHeight=()=>{var U,F,k,N,M,x;const m=(F=(U=this._renderManagerService.getRenderById(i))==null?void 0:U.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:F.skeleton;if(!m)return;const v=m.worksheet.getMergedCell(a,r),C={data:e,style:m.getStyles().getStyleByCell(e),primaryWithCoord:m.getCellWithCoordByIndex((k=v==null?void 0:v.startRow)!=null?k:a,(N=v==null?void 0:v.startColumn)!=null?N:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(x=(M=u==null?void 0:u.canvasRender)==null?void 0:M.calcCellAutoHeight)==null?void 0:x.call(M,C)},e.interceptorAutoWidth=()=>{var U,F,k,N,M,x;const m=(F=(U=this._renderManagerService.getRenderById(i))==null?void 0:U.with(H.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:F.skeleton;if(!m)return;const v=m.worksheet.getMergedCell(a,r),C={data:e,style:m.getStyles().getStyleByCell(e),primaryWithCoord:m.getCellWithCoordByIndex((k=v==null?void 0:v.startRow)!=null?k:a,(N=v==null?void 0:v.startColumn)!=null?N:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(x=(M=u==null?void 0:u.canvasRender)==null?void 0:M.calcCellAutoWidth)==null?void 0:x.call(M,C)},e.coverable=((O=e==null?void 0:e.coverable)!=null?O:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var a;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};St=Vt([q(0,o.ICommandService),q(1,P.IRenderManagerService),q(2,o.Inject(H.AutoHeightController)),q(3,o.Inject(Y.DataValidatorRegistryService)),q(4,o.Inject(j.SheetInterceptorService)),q(5,o.Inject(_.SheetDataValidationModel)),q(6,o.Inject(_.DataValidationCacheService))],St);var ln=Object.getOwnPropertyDescriptor,cn=(e,t,n,a)=>{for(var r=a>1?void 0:a?ln(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},_t=(e,t)=>(n,a)=>t(n,a,e);let $e=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 a;if(!t.length)return;const n=new Set;t.forEach(r=>{n.add(r.subUnitId)}),n.forEach(r=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(r))==null||i.skeleton.makeDirty(!0)}),(a=this._context.mainComponent)==null||a.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};$e=cn([_t(1,o.Inject(_.SheetDataValidationModel)),_t(2,o.Inject(H.SheetSkeletonManagerService))],$e);function Ce({ref:e,...t}){const{icon:n,id:a,className:r,extend:i,...s}=t,c=`univerjs-icon univerjs-icon-${a} ${r||""}`.trim(),l=T.useRef(`_${hn()}`);return Mt(n,`${a}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:c,...s},i)}function Mt(e,t,n,a,r){return T.createElement(e.tag,{key:t,...dn(e,n,r),...a},(un(e,n).children||[]).map((i,s)=>Mt(i,`${t}-${e.tag}-${s}`,n,void 0,r)))}function dn(e,t,n){const a={...e.attrs};n!=null&&n.colorChannel1&&a.fill==="colorChannel1"&&(a.fill=n.colorChannel1),e.tag==="mask"&&a.id&&(a.id=a.id+t.idSuffix),Object.entries(a).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(a[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:r}=t;return!r||r.length===0||(e.tag==="use"&&a["xlink:href"]&&(a["xlink:href"]=a["xlink:href"]+t.idSuffix),Object.entries(a).forEach(([i,s])=>{typeof s=="string"&&(a[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),a}function un(e,t){var a;const{defIds:n}=t;return!n||n.length===0?e:e.tag==="defs"&&((a=e.children)!=null&&a.length)?{...e,children:e.children.map(r=>typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?{...r,attrs:{...r.attrs,id:r.attrs.id+t.idSuffix}}:r)}:e}function hn(){return Math.random().toString(36).substring(2,8)}Ce.displayName="UniverIcon";const gn={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"}}]},bt=T.forwardRef(function(t,n){return T.createElement(Ce,Object.assign({},t,{id:"data-validation-icon",ref:n,icon:gn}))});bt.displayName="DataValidationIcon";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:"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"}}]},pt=T.forwardRef(function(t,n){return T.createElement(Ce,Object.assign({},t,{id:"delete-icon",ref:n,icon:pn}))});pt.displayName="DeleteIcon";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:"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"}}]},Tt=T.forwardRef(function(t,n){return T.createElement(Ce,Object.assign({},t,{id:"increase-icon",ref:n,icon:vn}))});Tt.displayName="IncreaseIcon";const mn={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"}}]},vt=T.forwardRef(function(t,n){return T.createElement(Ce,Object.assign({},t,{id:"more-down-icon",ref:n,icon:mn}))});vt.displayName="MoreDownIcon";const fn={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"}}]},Ot=T.forwardRef(function(t,n){return T.createElement(Ce,Object.assign({},t,{id:"more-up-icon",ref:n,icon:fn}))});Ot.displayName="MoreUpIcon";const Sn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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"}}]},At=T.forwardRef(function(t,n){return T.createElement(Ce,Object.assign({},t,{id:"sequence-icon",ref:n,icon:Sn}))});At.displayName="SequenceIcon";function _n(e){var d;const t=D.useDependency(o.LocaleService),n=D.useDependency(D.ComponentManager),{value:a,onChange:r,extraComponent:i}=e,[s,c]=T.useState(!1),l=i?n.get(i):null;return g.jsxs(g.Fragment,{children:[g.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:()=>c(!s),children:[t.t("dataValidation.panel.options"),s?g.jsx(Ot,{className:"univer-ml-1"}):g.jsx(vt,{className:"univer-ml-1"})]}),s&&g.jsxs(g.Fragment,{children:[l?g.jsx(l,{value:a,onChange:r}):null,g.jsx(V.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:g.jsxs(V.RadioGroup,{value:`${(d=a.errorStyle)!=null?d:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...a,errorStyle:+h}),children:[g.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),g.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),g.jsx(V.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:g.jsx(V.Checkbox,{checked:a.showErrorMessage,onChange:()=>r({...a,showErrorMessage:!a.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),a.showErrorMessage?g.jsx(V.FormLayout,{children:g.jsx(V.Input,{value:a.error,onChange:h=>r({...a,error:h})})}):null]})]})}const In=e=>o.debounce(async(t,n,a,r)=>{const i=await e.executeCommand(t,n,a);r==null||r(i)},1e3);function Cn(e,t,n){var a,r,i,s;return t?((r=(a=e.getUnit(t))==null?void 0:a.getSheetBySheetName(n))==null?void 0:r.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function yn(){var W,ee;const[e,t]=T.useState(0),n=D.useDependency(he),a=D.useObservable(n.activeRule$,n.activeRule),{unitId:r,subUnitId:i,rule:s}=a||{},c=s.uid,l=D.useDependency(Y.DataValidatorRegistryService),d=D.useDependency(o.IUniverInstanceService),h=D.useDependency(D.ComponentManager),p=D.useDependency(o.ICommandService),u=D.useDependency(Y.DataValidationModel),S=D.useDependency(o.LocaleService),R=D.useObservable(()=>d.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),L=D.useObservable(()=>{var E;return(E=R==null?void 0:R.activeSheet$)!=null?E:ie.of(null)},void 0,void 0,[]),[f,y]=T.useState(s),I=l.getValidatorItem(f.type),[w,O]=T.useState(!1),m=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[v,C]=T.useState(()=>f.ranges.map(E=>({unitId:"",sheetId:"",range:E}))),U=T.useMemo(()=>In(p),[p]),[F,k]=T.useState(!1),[N,M]=T.useState(!1),x=T.useRef(null),$=D.useDependency(j.SheetsSelectionsService);if(T.useEffect(()=>()=>{const E=$.getCurrentLastSelection();E&&$.setSelections([E])},[$]),T.useEffect(()=>{p.onCommandExecuted(E=>{(E.id===o.UndoCommand.id||E.id===o.RedoCommand.id)&&setTimeout(()=>{const K=u.getRuleById(r,i,c);t(G=>G+1),K&&(y(K),C(K.ranges.map(G=>({unitId:"",sheetId:"",range:G}))))},20)})},[p,u,c,i,r]),!I)return null;const B=I.operators,z=I.operatorNames,ae=f.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(f.operator):!1,Z=()=>{(L==null?void 0:L.getSheetId())!==i&&p.syncExecuteCommand(j.SetWorksheetActiveOperation.id,{unitId:r,subUnitId:i})},oe=()=>{var E,K,G;(K=(E=x.current)==null?void 0:E.editor)!=null&&K.isFocus()&&se((G=x.current)==null?void 0:G.getValue()),!(!f.ranges.length||F)&&(I.validatorFormula(f,r,i).success?n.setActiveRule(null):O(!0),Z())},se=D.useEvent(E=>{const K=E.split(",").filter(Boolean).map(st.deserializeRangeWithSheet).map(re=>{const mt=re.sheetName;if(mt){const Ut=Cn(d,re.unitId,mt);return{...re,sheetId:Ut}}return{...re,sheetId:""}});if(o.isUnitRangesEqual(K,v))return;C(K);const G=K.filter(re=>(!re.unitId||re.unitId===r)&&(!re.sheetId||re.sheetId===i)).map(re=>re.range);if(y({...f,ranges:G}),G.length===0)return;const ge={unitId:r,subUnitId:i,ruleId:c,ranges:G};U(_.UpdateSheetDataValidationRangeCommand.id,ge)}),le=E=>{if(o.shallowEqual(E,Y.getRuleSetting(f)))return;y({...f,...E});const K={unitId:r,subUnitId:i,ruleId:c,setting:E};U(_.UpdateSheetDataValidationSettingCommand.id,K,void 0)},ve=async()=>{await p.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:c,unitId:r,subUnitId:i}),n.setActiveRule(null),Z()},te={type:f.type,operator:f.operator,formula1:f.formula1,formula2:f.formula2,allowBlank:f.allowBlank},J=E=>{const K=l.getValidatorItem(E);if(!K)return;const G=K.operators,ge=u.getRuleById(r,i,c),re=E===(ge==null?void 0:ge.type)||E.includes("list")&&(ge!=null&&ge.type.includes("list"))?{...ge,type:E}:{...f,type:E,operator:G[0],formula1:void 0,formula2:void 0};y(re),p.executeCommand(_.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:f.uid,setting:Y.getRuleSetting(re)})},ce=h.get(I.formulaInput),ne=T.useMemo(()=>v.map(E=>st.serializeRange(E.range)).join(","),[]),Q=Y.getRuleOptions(f),b=E=>{o.shallowEqual(E,Y.getRuleOptions(f))||(y({...f,...E}),U(_.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:c,options:E}))},X=B.length&&!f.operator;return g.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.range"),error:!f.ranges.length||F?S.t("dataValidation.panel.rangeError"):"",children:g.jsx(ht.RangeSelector,{selectorRef:x,unitId:r,subUnitId:i,initialValue:ne,onChange:(E,K)=>{var G;!N&&((G=x.current)!=null&&G.verify())&&se(K)},onFocusChange:(E,K)=>{var G;M(E),!E&&K&&((G=x.current)!=null&&G.verify())&&se(K)},onVerify:E=>k(!E)})}),g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.type"),children:g.jsx(V.Select,{className:"univer-w-full",value:f.type,options:(W=m==null?void 0:m.sort((E,K)=>E.order-K.order))==null?void 0:W.map(E=>({label:S.t(E.title),value:E.id})),onChange:J})}),B!=null&&B.length?g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.operator"),children:g.jsx(V.Select,{className:"univer-w-full",value:`${f.operator}`,options:[{value:"",label:S.t("dataValidation.operators.legal")},...B.map((E,K)=>({value:`${E}`,label:z[K]}))],onChange:E=>{le({...te,operator:E})}})}):null,ce&&!X?g.jsx(ce,{isTwoFormula:ae,value:{formula1:f.formula1,formula2:f.formula2},onChange:E=>{le({...te,...E})},showError:w,validResult:I.validatorFormula(f,r,i),unitId:r,subUnitId:i,ruleId:c},e+f.type):null,g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:(ee=f.allowBlank)!=null?ee:!0,onChange:()=>{var E;return le({...te,allowBlank:!((E=f.allowBlank)==null||E)})},children:S.t("dataValidation.panel.allowBlank")})}),g.jsx(_n,{value:Q,onChange:b,extraComponent:I.optionsInput}),g.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[g.jsx(V.Button,{className:"univer-ml-3",onClick:ve,children:S.t("dataValidation.panel.removeRule")}),g.jsx(V.Button,{className:"univer-ml-3",variant:"primary",onClick:oe,children:S.t("dataValidation.panel.done")})]})]})}const Rn=e=>{const{rule:t,onClick:n,unitId:a,subUnitId:r,disable:i}=e,s=D.useDependency(Y.DataValidatorRegistryService),c=D.useDependency(o.ICommandService),l=D.useDependency(H.IMarkSelectionService),d=s.getValidatorItem(t.type),h=T.useRef(void 0),[p,u]=T.useState(!1),S=D.useDependency(o.ThemeService),R=D.useObservable(S.currentTheme$),L=T.useMemo(()=>{var m;const y=S.getColorFromTheme("primary.600"),I=S.getColorFromTheme("loop-color.2"),w=(m=S.getColorFromTheme(I))!=null?m:y,O=new o.ColorKit(w).toRgb();return{fill:`rgba(${O.r}, ${O.g}, ${O.b}, 0.1)`,stroke:w}},[R]),f=y=>{c.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:a,subUnitId:r}),y.stopPropagation()};return T.useEffect(()=>()=>{var y;h.current&&((y=h.current)==null||y.forEach(I=>{I&&l.removeShape(I)}))},[l]),g.jsxs("div",{className:V.clsx(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@univerjs/core`),l=require(`@univerjs/engine-render`),u=require(`@univerjs/sheets`),d=require(`@univerjs/sheets-data-validation`),f=require(`@univerjs/data-validation`),p=require(`@univerjs/ui`),m=require(`rxjs`),h=require(`@univerjs/sheets-numfmt`),g=require(`@univerjs/sheets-ui`),_=require(`@univerjs/design`),v=require(`react`);v=s(v);let y=require(`@univerjs/icons`),b=require(`@univerjs/engine-formula`),x=require(`@univerjs/sheets-formula-ui`),S=require(`react/jsx-runtime`);var C=`@univerjs/sheets-data-validation-ui`,w=`0.18.0`;function T(e){"@babel/helpers - typeof";return T=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},T(e)}function E(e,t){if(T(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(T(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function D(e){var t=E(e,`string`);return T(t)==`symbol`?t:t+``}function O(e,t,n){return(t=D(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k(e,t){return function(n,r){t(n,r,e)}}function A(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 j=class extends c.Disposable{get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}constructor(e,t){super(),this._univerInstanceService=e,this._sidebarService=t,O(this,`_open$`,new m.BehaviorSubject(!1)),O(this,`open$`,this._open$.pipe((0,m.distinctUntilChanged)())),O(this,`_activeRule`,void 0),O(this,`_activeRule$`,new m.BehaviorSubject(void 0)),O(this,`activeRule$`,this._activeRule$.asObservable()),O(this,`_closeDisposable`,null),O(this,`_focusFormulaEditorActiveRuleSubUnitId`,null),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET).pipe((0,m.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,c.toDisposable)(()=>{e.dispose(),this._closeDisposable=null})}setActiveRule(e){this._activeRule=e,this._activeRule$.next(e)}setFocusFormulaEditorActiveRuleSubUnitId(e){this._focusFormulaEditorActiveRuleSubUnitId=e}getFocusFormulaEditorActiveRuleSubUnitId(){return this._focusFormulaEditorActiveRuleSubUnitId}};j=A([k(0,c.IUniverInstanceService),k(1,p.ISidebarService)],j);const M=`sheets-data-validation-ui.config`;Symbol(M);const N={};let P=class extends c.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(u.VALIDATE_CELL,{handler:async(e,t,n)=>{let r=await e,{row:i,col:a,unitId:o,subUnitId:s}=t,l=this._dataValidationModel.getRuleIdByLocation(o,s,i,a),u=l?this._dataValidationModel.getRuleById(o,s,l):void 0;if(r===!1)return n(Promise.resolve(!1));if(!u||u.errorStyle!==c.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));let d=this._dataValidatorRegistryService.getValidatorItem(u.type);return!d||await this._sheetsDataValidationValidatorService.validatorCell(o,s,i,a)===c.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:d.getRuleFinalError(u,{row:i,col:a,unitId:o,subUnitId:s})},footer:{title:(0,v.createElement)(_.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:(0,v.createElement)(_.Button,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`dataValidation.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}})}};P=A([k(0,(0,c.Inject)(u.SheetInterceptorService)),k(1,(0,c.Inject)(d.SheetDataValidationModel)),k(2,(0,c.Inject)(f.DataValidatorRegistryService)),k(3,p.IDialogService),k(4,(0,c.Inject)(c.LocaleService)),k(5,(0,c.Inject)(d.SheetsDataValidationValidatorService))],P);const F=e=>{if(e==null||typeof e==`boolean`)return;if(e===``)return(0,c.dayjs)();if(typeof e==`number`||!Number.isNaN(+e))return(0,c.dayjs)(c.numfmt.format(`yyyy-MM-dd HH:mm:ss`,Number(e)));let t=(0,c.dayjs)(e);if(t.isValid())return t};function I(e,t){if(e===(0,h.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 L=class extends c.Disposable{get activeDropdown(){return this._activeDropdown}constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this._univerInstanceService=e,this._dataValidatorRegistryService=t,this._zenZoneService=n,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=a,this._sheetDataValidationModel=o,this._commandService=s,this._editorBridgeService=c,this._injector=l,this._configService=u,O(this,`_activeDropdown`,void 0),O(this,`_activeDropdown$`,new m.Subject),O(this,`_currentPopup`,null),O(this,`activeDropdown$`,this._activeDropdown$.asObservable()),O(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,t,n,r){let i=e?this._univerInstanceService.getUnit(e,c.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!i)return;let a=t?i.getSheetBySheetId(t):i.getActiveSheet();if(!a)return;let o=this._dataValidationModel.getRuleByLocation(i.getUnitId(),a.getSheetId(),n,r);if(!o)return;let s=this._dataValidatorRegistryService.getValidatorItem(o.type);return s==null?void 0:s.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:t}=e,{row:n,col:r,unitId:i,subUnitId:a,workbook:o,worksheet:s}=t;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=e,this._activeDropdown$.next(this._activeDropdown);let m=this._sheetDataValidationModel.getRuleByLocation(i,a,n,r);if(!m)return;let h=this._dataValidatorRegistryService.getValidatorItem(m.type);if(!(h!=null&&h.dropdownType))return;let _,v=async(e,t)=>{var d,f,_;if(!e)return!0;let v=e,y=s.getCell(n,r),b=v.format(t===`date`?`YYYY-MM-DD 00:00:00`:`YYYY-MM-DD HH:mm:ss`),x=(d=c.numfmt.parseDate(b))==null?void 0:d.v,S=t===`time`?x%1:x,C=o.getStyles().getStyleByCell(y),w=(f=C==null||(_=C.n)==null?void 0:_.pattern)==null?``:f;return m.errorStyle!==c.DataValidationErrorStyle.STOP||await h.validator({value:S,unitId:i,subUnitId:a,row:n,column:r,worksheet:s,workbook:o,interceptValue:b.replace(`Z`,``).replace(`T`,` `),t:c.CellValueType.NUMBER},m)?(await this._commandService.executeCommand(u.SetRangeValuesCommand.id,{unitId:i,subUnitId:a,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:S,t:2,p:null,f:null,si:null,s:{n:{pattern:I(t,w)}}}}),await this._commandService.executeCommand(g.SetCellEditVisibleOperation.id,{visible:!1,eventType:l.DeviceInputEventType.Keyboard,unitId:i,keycode:p.KeyCode.ESC}),!0):(this._injector.has(P)&&this._injector.get(P).showReject(h.getRuleFinalError(m,{row:n,col:r,unitId:i,subUnitId:a})),!1)},y;switch(h.dropdownType){case f.DataValidatorDropdownType.DATE:{var b;let e=F((0,d.getCellValueOrigin)(s.getCellRaw(n,r))),i=!!((b=m.bizInfo)!=null&&b.showTime);y={location:t,type:`datepicker`,props:{showTime:i,onChange:e=>v(e,i?`datetime`:`date`),defaultValue:e,patternType:`date`}};break}case f.DataValidatorDropdownType.TIME:y={location:t,type:`datepicker`,props:{onChange:e=>v(e,`time`),defaultValue:F((0,d.getCellValueOrigin)(s.getCellRaw(n,r))),patternType:`time`}};break;case f.DataValidatorDropdownType.DATETIME:y={location:t,type:`datepicker`,props:{onChange:e=>v(e,`datetime`),defaultValue:F((0,d.getCellValueOrigin)(s.getCellRaw(n,r))),patternType:`datetime`}};break;case f.DataValidatorDropdownType.LIST:case f.DataValidatorDropdownType.MULTIPLE_LIST:{var x,S,C,w;let e=h.dropdownType===f.DataValidatorDropdownType.MULTIPLE_LIST,o=async t=>{let o=(0,d.serializeListOptions)(t),s={unitId:i,subUnitId:a,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:o,p:null,f:null,si:null}};return this._commandService.executeCommand(u.SetRangeValuesCommand.id,s),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(g.SetCellEditVisibleOperation.id,{visible:!1,eventType:l.DeviceInputEventType.Keyboard,unitId:i,keycode:p.KeyCode.ESC}),!e},v=(m==null?void 0:m.renderMode)===c.DataValidationRenderMode.CUSTOM||(m==null?void 0:m.renderMode)===void 0,b=h.getListWithColor(m,i,a),T=(0,d.getDataValidationCellValue)(s.getCellRaw(n,r));y={location:t,type:`list`,props:{onChange:e=>o(e),options:b.map(e=>({label:e.label,value:e.label,color:v||e.color?e.color||`#ECECEC`:`transparent`})),onEdit:()=>{this._commandService.executeCommand(z.id,{ruleId:m.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 f.DataValidatorDropdownType.CASCADE:var T;y={type:`cascader`,props:{onChange:e=>{let t={unitId:i,subUnitId:a,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:e.join(`/`),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(u.SetRangeValuesCommand.id,t),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(g.SetCellEditVisibleOperation.id,{visible:!1,eventType:l.DeviceInputEventType.Keyboard,unitId:i,keycode:p.KeyCode.ESC}),!0},defaultValue:(0,d.getDataValidationCellValue)(s.getCellRaw(n,r)).split(`/`),options:JSON.parse((T=m.formula1)==null?`[]`:T)},location:t};break;case f.DataValidatorDropdownType.COLOR:y={type:`color`,props:{onChange:e=>{let t={unitId:i,subUnitId:a,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:e,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(u.SetRangeValuesCommand.id,t),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(g.SetCellEditVisibleOperation.id,{visible:!1,eventType:l.DeviceInputEventType.Keyboard,unitId:i,keycode:p.KeyCode.ESC}),!0},defaultValue:(0,d.getDataValidationCellValue)(s.getCellRaw(n,r))},location:t};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 c.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,t,n,r,i){let a=this._univerInstanceService.getUnit(e,c.UniverInstanceType.UNIVER_SHEET);if(!a)return;let o=a.getSheetBySheetId(t);if(!o)return;let s=this._dataValidationModel.getRuleByLocation(a.getUnitId(),o.getSheetId(),n,r);if(!s)return;let l=this._dataValidatorRegistryService.getValidatorItem(s.type);if(!l||!l.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:a,worksheet:o,row:n,col:r,unitId:e,subUnitId:t},onHide:i})}};L=A([k(0,c.IUniverInstanceService),k(1,(0,c.Inject)(f.DataValidatorRegistryService)),k(2,p.IZenZoneService),k(3,(0,c.Inject)(d.SheetDataValidationModel)),k(4,(0,c.Inject)(u.SheetsSelectionsService)),k(5,(0,c.Inject)(g.ISheetCellDropdownManagerService)),k(6,(0,c.Inject)(d.SheetDataValidationModel)),k(7,c.ICommandService),k(8,g.IEditorBridgeService),k(9,(0,c.Inject)(c.Injector)),k(10,c.IConfigService)],L);const R=`DataValidationPanel`,z={id:`data-validation.operation.open-validation-panel`,type:c.CommandType.OPERATION,handler(e,t){if(!t)return!1;let{ruleId:n,isAdd:r}=t,i=e.get(j),a=e.get(f.DataValidationModel),o=e.get(c.IUniverInstanceService),s=e.get(p.ISidebarService),l=(0,u.getSheetCommandTarget)(o);if(!l)return!1;let{unitId:d,subUnitId:m}=l,h=n?a.getRuleById(d,m,n):void 0;i.open(),i.setActiveRule(h&&{unitId:d,subUnitId:m,rule:h});let g=s.open({id:R,header:{title:r?`dataValidation.panel.addTitle`:`dataValidation.panel.title`},children:{label:R},width:312,onClose:()=>i.close()});return i.setCloseDisposable(g),!0}},B={id:`data-validation.operation.close-validation-panel`,type:c.CommandType.OPERATION,handler(e){return e.get(j).close(),!0}},V={id:`data-validation.operation.toggle-validation-panel`,type:c.CommandType.OPERATION,handler(e){let t=e.get(c.ICommandService),n=e.get(j);return n.open(),n.isOpen?t.executeCommand(B.id):t.executeCommand(z.id),!0}},H={type:c.CommandType.OPERATION,id:`sheet.operation.show-data-validation-dropdown`,handler(e,t){if(!t)return!1;let n=e.get(L),{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}},U={type:c.CommandType.OPERATION,id:`sheet.operation.hide-data-validation-dropdown`,handler(e,t){return t?(e.get(L).hideDropdown(),!0):!1}},W={type:c.CommandType.COMMAND,id:`data-validation.command.addRuleAndOpen`,handler(e){let t=(0,u.getSheetCommandTarget)(e.get(c.IUniverInstanceService));if(!t)return!1;let{workbook:n,worksheet:r}=t,i=(0,d.createDefaultNewRule)(e),a=e.get(c.ICommandService),o={rule:i,unitId:n.getUnitId(),subUnitId:r.getSheetId()};return a.syncExecuteCommand(d.AddSheetDataValidationCommand.id,o)?(a.syncExecuteCommand(z.id,{ruleId:i.uid,isAdd:!0}),!0):!1}},G=`SHEET_DATA_VALIDATION_ALERT`;let K=class extends c.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,m.debounceTime)(100)).subscribe(e=>{if(e){let n=this._univerInstanceService.getUnit(e.location.unitId,c.UniverInstanceType.UNIVER_SHEET),r=n.getSheetBySheetId(e.location.subUnitId);if(!r)return;let i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i){this._cellAlertManagerService.removeAlert(G);return}if(this._dataValidationModel.validator(i,{...e.location,workbook:n,worksheet:r})===c.DataValidationStatus.INVALID){var t;let n=this._cellAlertManagerService.currentAlert.get(G),r=n==null||(t=n.alert)==null?void 0:t.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(G);return}let a=this._dataValidationModel.getValidator(i.type);if(!a){this._cellAlertManagerService.removeAlert(G);return}this._cellAlertManagerService.showAlert({type:g.CellAlertType.ERROR,title:this._localeService.t(`dataValidation.error.title`),message:a==null?void 0:a.getRuleFinalError(i,e.location),location:e.location,width:200,height:74,key:G});return}}this._cellAlertManagerService.removeAlert(G)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(G)}))}};K=A([k(0,(0,c.Inject)(g.HoverManagerService)),k(1,(0,c.Inject)(g.CellAlertManagerService)),k(2,c.IUniverInstanceService),k(3,(0,c.Inject)(c.LocaleService)),k(4,p.IZenZoneService),k(5,(0,c.Inject)(d.SheetDataValidationModel))],K);let q=class extends c.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),t=(e,t)=>{let{source:n,target:r,unitId:i,subUnitId:a}=e,o=this._sheetDataValidationModel.getRuleObjectMatrix(i,a).clone(),s=(0,g.virtualizeDiscreteRanges)([n,r]),[l,f]=s.ranges,{mapFunc:p}=s,m={row:l.startRow,col:l.startColumn},h=u.AutoFillTools.getAutoFillRepeatRange(l,f),_=new c.ObjectMatrix,v=new Set;h.forEach(e=>{let t=e.repeatStartCell,n=e.relativeRange,r={startRow:m.row,startColumn:m.col,endColumn:m.col,endRow:m.row},o={startRow:t.row,startColumn:t.col,endColumn:t.col,endRow:t.row};c.Range.foreach(n,(e,t)=>{let n=c.Rectangle.getPositionRange({startRow:e,startColumn:t,endColumn:t,endRow:e},r),{row:s,col:l}=p(n.startRow,n.startColumn),u=this._sheetDataValidationModel.getRuleIdByLocation(i,a,s,l)||``,d=c.Rectangle.getPositionRange({startRow:e,startColumn:t,endColumn:t,endRow:e},o),{row:f,col:m}=p(d.startRow,d.startColumn);_.setValue(f,m,u),v.add(u)})});let y=Array.from(v).map(e=>({id:e,ranges:(0,c.queryObjectMatrix)(_,t=>t===e)}));o.addRangeRules(y);let{redoMutations:b,undoMutations:x}=(0,d.getDataValidationDiffMutations)(i,a,o.diff(this._sheetDataValidationModel.getRules(i,a)),this._injector,`patched`,t===u.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT);return{undos:x,redos:b}},n={id:d.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:e=>{let{source:t,unitId:n,subUnitId:r}=e;for(let e of t.rows)for(let i of t.cols){let t=this._sheetDataValidationModel.getRuleByLocation(n,r,e,i);if(t&&t.type===c.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(u.AUTO_FILL_APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,r,i)=>i===u.AUTO_FILL_APPLY_TYPE.COPY||i===u.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||i===u.AUTO_FILL_APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};q=A([k(0,u.IAutoFillService),k(1,(0,c.Inject)(d.SheetDataValidationModel)),k(2,(0,c.Inject)(c.Injector))],q);let J=class extends c.Disposable{constructor(e,t,n){super(),this._sheetClipboardService=e,this._sheetDataValidationModel=t,this._injector=n,O(this,`_copyInfo`,void 0),this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:d.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,r)=>{let{copyType:i=g.COPY_TYPE.COPY,pasteType:a}=r,{range:o}=e||{},{range:s,unitId:c,subUnitId:l}=t;return this._generateMutations(s,{copyType:i,pasteType:a,copyRange:o,unitId:c,subUnitId:l})}})}_collect(e,t,n){let r=new c.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:t,matrix:r};let i=this._injector.invoke(r=>(0,u.rangeToDiscreteRange)(n,r,e,t));if(!i)return;let{rows:a,cols:o}=i;a.forEach((n,i)=>{o.forEach((a,o)=>{let s=this._sheetDataValidationModel.getRuleIdByLocation(e,t,n,a);r.setValue(i,o,s==null?``:s)})})}_generateMutations(e,t){if(!this._copyInfo)return{redos:[],undos:[]};if(t.copyType===g.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!t.copyRange||[g.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,g.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,g.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,g.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(t.pasteType))return{redos:[],undos:[]};let{unitId:n,subUnitId:r}=this._copyInfo;if(t.unitId!==n||r!==t.subUnitId){let i=this._sheetDataValidationModel.getRuleObjectMatrix(t.unitId,t.subUnitId).clone(),a=new c.ObjectMatrix,o=new Set,{ranges:[s,l],mapFunc:u}=(0,g.virtualizeDiscreteRanges)([t.copyRange,e]),f=(0,g.getRepeatRange)(s,l,!0),p=new Map;f.forEach(({startRange:e})=>{var i;(i=this._copyInfo)==null||i.matrix.forValue((i,s,l)=>{let d=c.Rectangle.getPositionRange({startRow:i,endRow:i,startColumn:s,endColumn:s},e),f=`${r}-${l}`,m=this._sheetDataValidationModel.getRuleById(n,r,l);!this._sheetDataValidationModel.getRuleById(t.unitId,t.subUnitId,f)&&m&&p.set(f,{...m,uid:f});let{row:h,col:g}=u(d.startRow,d.startColumn);o.add(f),a.setValue(h,g,f)})});let m=Array.from(o).map(e=>({id:e,ranges:(0,c.queryObjectMatrix)(a,t=>t===e)}));i.addRangeRules(m);let{redoMutations:h,undoMutations:_}=(0,d.getDataValidationDiffMutations)(t.unitId,t.subUnitId,i.diffWithAddition(this._sheetDataValidationModel.getRules(t.unitId,t.subUnitId),p.values()),this._injector,`patched`,!1);return{redos:h,undos:_}}else{let i=this._sheetDataValidationModel.getRuleObjectMatrix(n,r).clone(),a=new c.ObjectMatrix,o=new Set,{ranges:[s,l],mapFunc:u}=(0,g.virtualizeDiscreteRanges)([t.copyRange,e]);(0,g.getRepeatRange)(s,l,!0).forEach(({startRange:e})=>{var t;(t=this._copyInfo)==null||t.matrix.forValue((t,n,r)=>{let i=c.Rectangle.getPositionRange({startRow:t,endRow:t,startColumn:n,endColumn:n},e),{row:s,col:l}=u(i.startRow,i.startColumn);a.setValue(s,l,r),o.add(r)})});let f=Array.from(o).map(e=>({id:e,ranges:(0,c.queryObjectMatrix)(a,t=>t===e)}));i.addRangeRules(f);let{redoMutations:p,undoMutations:m}=(0,d.getDataValidationDiffMutations)(n,r,i.diff(this._sheetDataValidationModel.getRules(n,r)),this._injector,`patched`,!1);return{redos:p,undos:m}}}};J=A([k(0,g.ISheetClipboardService),k(1,(0,c.Inject)(d.SheetDataValidationModel)),k(2,(0,c.Inject)(c.Injector))],J);let Y=class extends c.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===d.AddSheetDataValidationCommand.id){let{unitId:t,subUnitId:n,rule:{ranges:r}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[u.WorkbookEditablePermission],rangeTypes:[u.RangeProtectionPermissionEditPoint],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellStylePermission]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.setStyleErr`))}if(e.id===d.UpdateSheetDataValidationRangeCommand.id){let{unitId:t,subUnitId:n,ranges:r}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[u.WorkbookEditablePermission],rangeTypes:[u.RangeProtectionPermissionEditPoint],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellStylePermission]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.setStyleErr`))}}))}};Y=A([k(0,(0,c.Inject)(c.LocaleService)),k(1,c.ICommandService),k(2,(0,c.Inject)(u.SheetPermissionCheckController))],Y);const ee=`sheet.menu.data-validation`;function te(e){return{id:ee,type:p.MenuItemType.SUBITEMS,icon:`DataValidationIcon`,tooltip:`dataValidation.title`,hidden$:(0,p.getMenuHiddenObservable)(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:(0,g.getCurrentRangeDisable$)(e,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSetCellStylePermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function X(e){return{id:z.id,title:`dataValidation.panel.title`,type:p.MenuItemType.BUTTON}}function ne(e){return{id:W.id,title:`dataValidation.panel.add`,type:p.MenuItemType.BUTTON}}const re={[p.RibbonDataGroup.RULES]:{[ee]:{order:0,menuItemFactory:te,[z.id]:{order:0,menuItemFactory:X},[W.id]:{order:1,menuItemFactory:ne}}}},ie={tr:{size:6,color:`#fe4b4b`}};let Z=class extends c.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(re)}_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(u.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,priority:u.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var r,i,a,o,s;let{row:l,col:u,unitId:f,subUnitId:p,workbook:m,worksheet:h}=t,_=this._sheetDataValidationModel.getRuleIdByLocation(f,p,l,u);if(!_)return n(e);let v=this._sheetDataValidationModel.getRuleById(f,p,_);if(!v)return n(e);let y=(r=this._dataValidationCacheService.getValue(f,p,l,u))==null?c.DataValidationStatus.VALID:r,b=this._dataValidatorRegistryService.getValidatorItem(v.type),x=t.rawData,S,C={get value(){var e;return S===void 0&&(S=(e=(0,d.getCellValueOrigin)(x))==null?null:e),S}},w={get value(){var e;return`${(e=C.value)==null?``:e}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...y===c.DataValidationStatus.INVALID?ie:null},e.customRender=[...(i=e==null?void 0:e.customRender)==null?[]:i,...b!=null&&b.canvasRender?[b.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(a=e.fontRenderExtension)==null?void 0:a.isSkip)||(b==null||(o=b.skipDefaultFontRender)==null?void 0:o.call(b,v,C.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...b==null?void 0:b.getExtraStyle(v,w.value,{get style(){let t=m.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},l,u)},e.interceptorAutoHeight=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(f))==null||(t=t.with(g.SheetSkeletonManagerService).getSkeletonParam(p))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(l,u),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?l:n,(r=s==null?void 0:s.startColumn)==null?u:r),unitId:f,subUnitId:p,row:l,col:u,workbook:m,worksheet:h};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(f))==null||(t=t.with(g.SheetSkeletonManagerService).getSkeletonParam(p))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(l,u),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?l:n,(r=s==null?void 0:s.startColumn)==null?u:r),unitId:f,subUnitId:p,row:l,col:u,workbook:m,worksheet:h};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoWidth)==null?void 0:a.call(i,c)},e.coverable=((s=e==null?void 0:e.coverable)==null?!0:s)&&!(v.type===c.DataValidationType.LIST||v.type===c.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,m.filter)(e=>e.source===`command`),(0,m.bufferTime)(100)).subscribe(e=>{if(e.length===0)return;let t=[];e.forEach(e=>{if(e.rule.type===c.DataValidationType.LIST_MULTIPLE||e.rule.type===c.DataValidationType.LIST){var n;(n=e.rule)!=null&&n.ranges&&t.push(...e.rule.ranges)}}),t.length&&(0,c.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};Z=A([k(0,c.ICommandService),k(1,p.IMenuManagerService),k(2,l.IRenderManagerService),k(3,c.IUniverInstanceService),k(4,(0,c.Inject)(g.AutoHeightController)),k(5,(0,c.Inject)(L)),k(6,(0,c.Inject)(d.SheetDataValidationModel)),k(7,(0,c.Inject)(f.DataValidatorRegistryService)),k(8,(0,c.Inject)(u.SheetInterceptorService)),k(9,(0,c.Inject)(d.DataValidationCacheService)),k(10,(0,c.Optional)(g.IEditorBridgeService))],Z);let ae=class extends c.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(u.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,priority:u.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var r,i,a,o,s;let{row:l,col:u,unitId:f,subUnitId:p,workbook:m,worksheet:h}=t,_=this._sheetDataValidationModel.getRuleIdByLocation(f,p,l,u);if(!_)return n(e);let v=this._sheetDataValidationModel.getRuleById(f,p,_);if(!v)return n(e);let y=(r=this._dataValidationCacheService.getValue(f,p,l,u))==null?c.DataValidationStatus.VALID:r,b=this._dataValidatorRegistryService.getValidatorItem(v.type),x=(0,d.getCellValueOrigin)(h.getCellRaw(l,u)),S=`${x==null?``:x}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...y===c.DataValidationStatus.INVALID?ie:null},e.customRender=[...(i=e==null?void 0:e.customRender)==null?[]:i,...b!=null&&b.canvasRender?[b.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(a=e.fontRenderExtension)==null?void 0:a.isSkip)||(b==null||(o=b.skipDefaultFontRender)==null?void 0:o.call(b,v,x,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...b==null?void 0:b.getExtraStyle(v,S,{get style(){let t=m.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},l,u)},e.interceptorAutoHeight=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(f))==null||(t=t.with(g.SheetSkeletonManagerService).getSkeletonParam(p))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(l,u),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?l:n,(r=s==null?void 0:s.startColumn)==null?u:r),unitId:f,subUnitId:p,row:l,col:u,workbook:m,worksheet:h};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(f))==null||(t=t.with(g.SheetSkeletonManagerService).getSkeletonParam(p))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(l,u),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?l:n,(r=s==null?void 0:s.startColumn)==null?u:r),unitId:f,subUnitId:p,row:l,col:u,workbook:m,worksheet:h};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoWidth)==null?void 0:a.call(i,c)},e.coverable=((s=e==null?void 0:e.coverable)==null?!0:s)&&!(v.type===c.DataValidationType.LIST||v.type===c.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,m.filter)(e=>e.source===`command`),(0,m.bufferTime)(16)).subscribe(e=>{let t=[];e.forEach(e=>{if(e.rule.type===c.DataValidationType.LIST_MULTIPLE||e.rule.type===c.DataValidationType.LIST){var n;(n=e.rule)!=null&&n.ranges&&t.push(...e.rule.ranges)}}),t.length&&(0,c.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};ae=A([k(0,c.ICommandService),k(1,l.IRenderManagerService),k(2,(0,c.Inject)(g.AutoHeightController)),k(3,(0,c.Inject)(f.DataValidatorRegistryService)),k(4,(0,c.Inject)(u.SheetInterceptorService)),k(5,(0,c.Inject)(d.SheetDataValidationModel)),k(6,(0,c.Inject)(d.DataValidationCacheService))],ae);let oe=class extends c.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,c.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()}))}};oe=A([k(1,(0,c.Inject)(d.SheetDataValidationModel)),k(2,(0,c.Inject)(g.SheetSkeletonManagerService))],oe);function se(e){var t;let n=(0,p.useDependency)(c.LocaleService),r=(0,p.useDependency)(p.ComponentManager),{value:i,onChange:a,extraComponent:o}=e,[s,l]=(0,v.useState)(!1),u=o?r.get(o):null;return(0,S.jsxs)(S.Fragment,{children:[(0,S.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:()=>l(!s),children:[n.t(`dataValidation.panel.options`),s?(0,S.jsx)(y.MoreUpIcon,{className:`univer-ml-1`}):(0,S.jsx)(y.MoreDownIcon,{className:`univer-ml-1`})]}),s&&(0,S.jsxs)(S.Fragment,{children:[u?(0,S.jsx)(u,{value:i,onChange:a}):null,(0,S.jsx)(_.FormLayout,{label:n.t(`dataValidation.panel.invalid`),children:(0,S.jsxs)(_.RadioGroup,{value:`${(t=i.errorStyle)==null?c.DataValidationErrorStyle.WARNING:t}`,onChange:e=>a({...i,errorStyle:+e}),children:[(0,S.jsx)(_.Radio,{value:`${c.DataValidationErrorStyle.WARNING}`,children:n.t(`dataValidation.panel.showWarning`)}),(0,S.jsx)(_.Radio,{value:`${c.DataValidationErrorStyle.STOP}`,children:n.t(`dataValidation.panel.rejectInput`)})]})}),(0,S.jsx)(_.FormLayout,{label:n.t(`dataValidation.panel.messageInfo`),children:(0,S.jsx)(_.Checkbox,{checked:i.showErrorMessage,onChange:()=>a({...i,showErrorMessage:!i.showErrorMessage}),children:n.t(`dataValidation.panel.showInfo`)})}),i.showErrorMessage?(0,S.jsx)(_.FormLayout,{children:(0,S.jsx)(_.Input,{value:i.error,onChange:e=>a({...i,error:e})})}):null]})]})}const ce=e=>(0,c.debounce)(async(t,n,r,i)=>{let a=await e.executeCommand(t,n,r);i==null||i(a)},1e3);function le(e,t,n){var r;if(t){var i;return((i=e.getUnit(t))==null||(i=i.getSheetBySheetName(n))==null?void 0:i.getSheetId())||``}return((r=e.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET))==null||(r=r.getSheetBySheetName(n))==null?void 0:r.getSheetId())||``}function ue(){var e,t;let[n,r]=(0,v.useState)(0),i=(0,p.useDependency)(j),{unitId:a,subUnitId:o,rule:s}=(0,p.useObservable)(i.activeRule$,i.activeRule)||{},l=s.uid,h=(0,p.useDependency)(f.DataValidatorRegistryService),g=(0,p.useDependency)(c.IUniverInstanceService),y=(0,p.useDependency)(p.ComponentManager),C=(0,p.useDependency)(c.ICommandService),w=(0,p.useDependency)(f.DataValidationModel),T=(0,p.useDependency)(c.LocaleService),E=(0,p.useObservable)(()=>g.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),D=(0,p.useObservable)(()=>{var e;return(e=E==null?void 0:E.activeSheet$)==null?(0,m.of)(null):e},void 0,void 0,[]),[O,k]=(0,v.useState)(s),A=h.getValidatorItem(O.type),[M,N]=(0,v.useState)(!1),P=h.getValidatorsByScope(f.DataValidatorRegistryScope.SHEET),[F,I]=(0,v.useState)(()=>O.ranges.map(e=>({unitId:``,sheetId:``,range:e}))),L=(0,v.useMemo)(()=>ce(C),[C]),[R,z]=(0,v.useState)(!1),[B,V]=(0,v.useState)(!1),H=(0,v.useRef)(null),U=(0,p.useDependency)(u.SheetsSelectionsService);if((0,v.useEffect)(()=>()=>{let e=U.getCurrentLastSelection();e&&U.setSelections([e])},[U]),(0,v.useEffect)(()=>{C.onCommandExecuted(e=>{(e.id===c.UndoCommand.id||e.id===c.RedoCommand.id)&&setTimeout(()=>{let e=w.getRuleById(a,o,l);r(e=>e+1),e&&(k(e),I(e.ranges.map(e=>({unitId:``,sheetId:``,range:e}))))},20)})},[C,w,l,o,a]),!A)return null;let W=A.operators,G=A.operatorNames,K=O.operator?f.TWO_FORMULA_OPERATOR_COUNT.includes(O.operator):!1,q=()=>{(D==null?void 0:D.getSheetId())!==o&&C.syncExecuteCommand(u.SetWorksheetActiveOperation.id,{unitId:a,subUnitId:o})},J=()=>{var e;if(!((e=H.current)==null||(e=e.editor)==null)&&e.isFocus()){var t;Y((t=H.current)==null?void 0:t.getValue())}!O.ranges.length||R||(A.validatorFormula(O,a,o).success?i.setActiveRule(null):N(!0),q())},Y=(0,p.useEvent)(e=>{let t=e.split(`,`).filter(Boolean).map(b.deserializeRangeWithSheet).map(e=>{let t=e.sheetName;if(t){let n=le(g,e.unitId,t);return{...e,sheetId:n}}return{...e,sheetId:``}});if((0,c.isUnitRangesEqual)(t,F))return;I(t);let n=t.filter(e=>(!e.unitId||e.unitId===a)&&(!e.sheetId||e.sheetId===o)).map(e=>e.range);if(k({...O,ranges:n}),n.length===0)return;let r={unitId:a,subUnitId:o,ruleId:l,ranges:n};L(d.UpdateSheetDataValidationRangeCommand.id,r)}),ee=e=>{if((0,c.shallowEqual)(e,(0,f.getRuleSetting)(O)))return;k({...O,...e});let t={unitId:a,subUnitId:o,ruleId:l,setting:e};L(d.UpdateSheetDataValidationSettingCommand.id,t,void 0)},te=async()=>{await C.executeCommand(d.RemoveSheetDataValidationCommand.id,{ruleId:l,unitId:a,subUnitId:o}),i.setActiveRule(null),q()},X={type:O.type,operator:O.operator,formula1:O.formula1,formula2:O.formula2,allowBlank:O.allowBlank},ne=e=>{let t=h.getValidatorItem(e);if(!t)return;let n=t.operators,r=w.getRuleById(a,o,l),i=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(i),C.executeCommand(d.UpdateSheetDataValidationSettingCommand.id,{unitId:a,subUnitId:o,ruleId:O.uid,setting:(0,f.getRuleSetting)(i)})},re=y.get(A.formulaInput),ie=(0,v.useMemo)(()=>F.map(e=>(0,b.serializeRange)(e.range)).join(`,`),[]),Z=(0,f.getRuleOptions)(O),ae=e=>{(0,c.shallowEqual)(e,(0,f.getRuleOptions)(O))||(k({...O,...e}),L(d.UpdateSheetDataValidationOptionsCommand.id,{unitId:a,subUnitId:o,ruleId:l,options:e}))},oe=W.length&&!O.operator;return(0,S.jsxs)(`div`,{"data-u-comp":`data-validation-detail`,className:`univer-py-2`,children:[(0,S.jsx)(_.FormLayout,{label:T.t(`dataValidation.panel.range`),error:!O.ranges.length||R?T.t(`dataValidation.panel.rangeError`):``,children:(0,S.jsx)(x.RangeSelector,{selectorRef:H,unitId:a,subUnitId:o,initialValue:ie,onChange:(e,t)=>{var n;!B&&(n=H.current)!=null&&n.verify()&&Y(t)},onFocusChange:(e,t)=>{var n;V(e),!e&&t&&(n=H.current)!=null&&n.verify()&&Y(t)},onVerify:e=>z(!e)})}),(0,S.jsx)(_.FormLayout,{label:T.t(`dataValidation.panel.type`),children:(0,S.jsx)(_.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:ne})}),W!=null&&W.length?(0,S.jsx)(_.FormLayout,{label:T.t(`dataValidation.panel.operator`),children:(0,S.jsx)(_.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=>{ee({...X,operator:e})}})}):null,re&&!oe?(0,S.jsx)(re,{isTwoFormula:K,value:{formula1:O.formula1,formula2:O.formula2},onChange:e=>{ee({...X,...e})},showError:M,validResult:A.validatorFormula(O,a,o),unitId:a,subUnitId:o,ruleId:l},n+O.type):null,(0,S.jsx)(_.FormLayout,{children:(0,S.jsx)(_.Checkbox,{checked:(t=O.allowBlank)==null?!0:t,onChange:()=>{var e;return ee({...X,allowBlank:!((e=O.allowBlank)==null||e)})},children:T.t(`dataValidation.panel.allowBlank`)})}),(0,S.jsx)(se,{value:Z,onChange:ae,extraComponent:A.optionsInput}),(0,S.jsxs)(`div`,{className:`univer-mt-5 univer-flex univer-flex-row univer-justify-end`,children:[(0,S.jsx)(_.Button,{className:`univer-ml-3`,onClick:te,children:T.t(`dataValidation.panel.removeRule`)}),(0,S.jsx)(_.Button,{className:`univer-ml-3`,variant:`primary`,onClick:J,children:T.t(`dataValidation.panel.done`)})]})]})}const de=e=>{let{rule:t,onClick:n,unitId:r,subUnitId:i,disable:a}=e,o=(0,p.useDependency)(f.DataValidatorRegistryService),s=(0,p.useDependency)(c.ICommandService),l=(0,p.useDependency)(g.IMarkSelectionService),u=o.getValidatorItem(t.type),m=(0,v.useRef)(void 0),[h,x]=(0,v.useState)(!1),C=(0,p.useDependency)(c.ThemeService),w=(0,v.useMemo)(()=>{var e;let t=C.getColorFromTheme(`primary.600`),n=C.getColorFromTheme(`loop-color.2`),r=(e=C.getColorFromTheme(n))==null?t:e,i=new c.ColorKit(r).toRgb();return{fill:`rgba(${i.r}, ${i.g}, ${i.b}, 0.1)`,stroke:r}},[(0,p.useObservable)(C.currentTheme$)]),T=e=>{s.executeCommand(d.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:r,subUnitId:i}),e.stopPropagation()};return(0,v.useEffect)(()=>()=>{if(m.current){var e;(e=m.current)==null||e.forEach(e=>{e&&l.removeShape(e)})}},[l]),(0,S.jsxs)(`div`,{className:(0,_.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:L,primary:null})))},onMouseLeave:()=>{var y;u(!1),(y=h.current)==null||y.forEach(I=>{I&&l.removeShape(I)}),h.current=void 0},children:[g.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:d==null?void 0:d.generateRuleName(t)}),g.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(y=>st.serializeRange(y)).join(",")}),p?g.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:f,children:g.jsx(pt,{})}):null]})};function Dn(e){const t=D.useDependency(_.SheetDataValidationModel),n=D.useDependency(o.IUniverInstanceService),a=D.useDependency(o.ICommandService),r=D.useDependency(o.Injector),i=D.useDependency(he),s=D.useDependency(o.LocaleService),[c,l]=T.useState([]),{workbook:d}=e,h=D.useObservable(d.activeSheet$,void 0,!0),p=d.getUnitId(),u=h==null?void 0:h.getSheetId();T.useEffect(()=>{l(t.getRules(p,u));const I=t.ruleChange$.subscribe(w=>{w.unitId===p&&w.subUnitId===u&&l(t.getRules(p,u))});return()=>{I.unsubscribe()}},[p,u,t]);const S=async()=>{const I=_.createDefaultNewRule(r),w={unitId:p,subUnitId:u,rule:I};await a.executeCommand(_.AddSheetDataValidationCommand.id,w),i.setActiveRule({unitId:p,subUnitId:u,rule:I})},R=()=>{a.executeCommand(_.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:u})},f=(I=>{const w=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),O=w.getActiveSheet(),m=w.getUnitId(),v=O.getSheetId();return I.map(U=>j.checkRangesEditablePermission(r,m,v,U.ranges)?{...U}:{...U,disable:!0})})(c),y=f==null?void 0:f.some(I=>I.disable);return g.jsxs("div",{className:"univer-pb-4",children:[f==null?void 0:f.map(I=>{var w;return g.jsx(Rn,{unitId:p,subUnitId:u,onClick:()=>{I.disable||i.setActiveRule({unitId:p,subUnitId:u,rule:I})},rule:I,disable:(w=I.disable)!=null?w:!1},I.uid)}),g.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[c.length&&!y?g.jsx(V.Button,{onClick:R,children:s.t("dataValidation.panel.removeAll")}):null,g.jsx(V.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const wn=()=>{const e=D.useDependency(he),t=D.useObservable(e.activeRule$,e.activeRule),n=D.useDependency(o.IUniverInstanceService),a=D.useObservable(()=>n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),r=D.useObservable(()=>{var i;return(i=a==null?void 0:a.activeSheet$)!=null?i:ie.of(null)},void 0,void 0,[]);return!a||!r?null:t&&(t.subUnitId===r.getSheetId()||t.subUnitId===e.getFocusFormulaEditorActiveRuleSubUnitId())?g.jsx(yn,{},t.rule.uid):g.jsx(Dn,{workbook:a})},Vn=e=>{const{isTwoFormula:t=!1,value:n,onChange:a,showError:r,validResult:i}=e,s=D.useDependency(o.LocaleService),c=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{error:c,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:d=>{a==null||a({...n,formula1:d})}})}),g.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),g.jsx(V.FormLayout,{error:l,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:d=>{a==null||a({...n,formula2:d})}})})]}):g.jsx(V.FormLayout,{error:c,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:d=>{a==null||a({formula1:d})}})})};function En(e){const{value:t,onChange:n,showError:a,validResult:r}=e,i=D.useDependency(o.LocaleService),s=a?r==null?void 0:r.formula1:"",c=a?r==null?void 0:r.formula2:"",[l,d]=T.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:l,onChange:h=>{h?d(!0):(d(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:g.jsx(V.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?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:c,children:g.jsx(V.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 Mn(e){var p;const{unitId:t,subUnitId:n,value:a,onChange:r,showError:i,validResult:s}=e,c=i?s==null?void 0:s.formula1:void 0,l=T.useRef(null),[d,h]=T.useState(!1);return D.useSidebarClick(u=>{var R;(R=l.current)!=null&&R.isClickOutSide(u)&&h(!1)}),g.jsx(V.FormLayout,{error:c,children:g.jsx(ht.FormulaEditor,{ref:l,className:V.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",V.borderClassName),initValue:(p=a==null?void 0:a.formula1)!=null?p:"=",unitId:t,subUnitId:n,isFocus:d,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(a==null?void 0:a.formula1)&&(r==null||r({...a,formula1:S}))},onFocus:()=>h(!0)})})}const bn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Tn=e=>{const{value:t,onChange:n,disabled:a}=e,[r,i]=T.useState(!1);return g.jsx(V.Dropdown,{align:"start",disabled:a,open:r,onOpenChange:i,overlay:g.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:bn.map(s=>g.jsx("div",{className:V.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",V.borderClassName),style:{background:s},onClick:()=>{n(s),i(!1)}},s))}),children:g.jsxs("div",{className:V.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",V.borderClassName),children:[g.jsx("div",{className:"univer-box-border univer-size-4 univer-rounded univer-text-base",style:{background:t}}),g.jsx(vt,{})]})})},It=e=>{const{item:t,commonProps:n,className:a}=e,{onItemChange:r,onItemDelete:i}=n;return g.jsxs("div",{className:V.clsx("univer-flex univer-items-center univer-gap-2",a),children:[!t.isRef&&g.jsx("div",{className:V.clsx("univer-cursor-move","draggableHandle"),children:g.jsx(At,{})}),g.jsx(Tn,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),g.jsx(V.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:g.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:g.jsx(pt,{onClick:()=>i(t.id)})})]})};function On(e){const{value:t,onChange:n=()=>{},unitId:a,subUnitId:r,validResult:i,showError:s,ruleId:c}=e,{formula1:l="",formula2:d=""}=t||{},[h,p]=T.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=T.useState(h==="1"?l:"="),[R,L]=T.useState(h==="1"?l:"="),f=D.useDependency(o.LocaleService),y=D.useDependency(Y.DataValidatorRegistryService),I=D.useDependency(Y.DataValidationModel),w=D.useDependency(_.DataValidationFormulaController),O=D.useDependency(he),[m,v]=T.useState(()=>d.split(",")),C=y.getValidatorItem(o.DataValidationType.LIST),[U,F]=T.useState([]),[k,N]=T.useState(""),M=s?i==null?void 0:i.formula1:"",x=T.useMemo(()=>I.ruleChange$.pipe(ie.debounceTime(16)),[]),$=D.useObservable(x),B=D.useEvent(n);T.useEffect(()=>{(async()=>{await new Promise(W=>{setTimeout(()=>W(!0),100)});const b=I.getRuleById(a,r,c),X=b==null?void 0:b.formula1;if(o.isFormulaString(X)&&C&&b){const W=await C.getListAsync(b,a,r);F(W)}})()},[I,$,C,c,r,a]),T.useEffect(()=>{o.isFormulaString(l)&&l!==R&&(S(l),L(R))},[R,l]);const[z,ae]=T.useState(()=>{const b=h!=="1"?_.deserializeListOptions(l):[],X=d.split(",");return b.map((W,ee)=>({label:W,color:X[ee]||Se,isRef:!1,id:o.generateRandomId(4)}))}),Z=(b,X,W)=>{const ee=z.find(E=>E.id===b);ee&&(ee.label=X,ee.color=W,ae([...z]))},oe=b=>{const X=z.findIndex(W=>W.id===b);X!==-1&&(z.splice(X,1),ae([...z]))},se=d.split(","),le=T.useMemo(()=>U.map((b,X)=>({label:b,color:se[X]||Se,id:`${X}`,isRef:!0})),[se,U]),ve=(b,X,W)=>{const ee=[...m];ee[+b]=W,v(ee),B({formula1:l,formula2:ee.join(",")})},te=()=>{ae([...z,{label:"",color:Se,isRef:!1,id:o.generateRandomId(4)}])};T.useEffect(()=>{if(h==="1")return;const b=new Set,X=[];z.map(W=>({labelList:W.label.split(","),item:W})).forEach(({item:W,labelList:ee})=>{ee.forEach(E=>{b.has(E)||(b.add(E),X.push({label:E,color:W.color}))})}),B({formula1:_.serializeListOptions(X.map(W=>W.label)),formula2:X.map(W=>W.color===Se?"":W.color).join(",")})},[z,B,h,R,m]);const J=D.useEvent(async b=>{if(!o.isFormulaString(b)){B==null||B({formula1:"",formula2:d});return}w.getFormulaRefCheck(b)?(B==null||B({formula1:o.isFormulaString(b)?b:"",formula2:d}),N("")):(B==null||B({formula1:"",formula2:d}),S("="),N(f.t("dataValidation.validFail.formulaError")))}),ce=T.useRef(null),[ne,Q]=T.useState(!1);return D.useSidebarClick(b=>{var W;(W=ce.current)!=null&&W.isClickOutSide(b)&&Q(!1)}),T.useEffect(()=>{ne?O.setFocusFormulaEditorActiveRuleSubUnitId(r):O.setFocusFormulaEditorActiveRuleSubUnitId(null)},[ne,r,O]),g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{label:f.t("dataValidation.list.options"),children:g.jsxs(V.RadioGroup,{value:h,onChange:b=>{p(b),S(R),b==="1"&&B({formula1:R==="="?"":R,formula2:m.join(",")})},children:[g.jsx(V.Radio,{value:"0",children:f.t("dataValidation.list.customOptions")}),g.jsx(V.Radio,{value:"1",children:f.t("dataValidation.list.refOptions")})]})}),h==="1"?g.jsxs(V.FormLayout,{error:M||k||void 0,children:[g.jsx(ht.FormulaEditor,{ref:ce,className:V.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",V.borderClassName),initValue:u,unitId:a,subUnitId:r,isFocus:ne,isSupportAcrossSheet:!0,onFocus:()=>Q(!0),onChange:(b="")=>{const X=(b!=null?b:"").trim();L(X),J(X)}}),le.length>0&&g.jsx("div",{className:"univer-mt-3",children:le.map(b=>g.jsx(It,{className:"univer-mb-3",item:b,commonProps:{onItemChange:ve}},b.id))})]}):g.jsx(V.FormLayout,{error:M,children:g.jsxs("div",{className:"-univer-mt-3",children:[g.jsx(V.DraggableList,{list:z,onListChange:ae,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:b=>g.jsx(It,{item:b,commonProps:{onItemChange:Z,onItemDelete:oe}},b.id),idKey:"id"}),g.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:te,children:[g.jsx(Tt,{className:"univer-mr-1"}),f.t("dataValidation.list.add")]})]})})]})}const An=[[_.CUSTOM_FORMULA_INPUT_NAME,Mn],[_.BASE_FORMULA_INPUT_NAME,Vn],[_.LIST_FORMULA_INPUT_NAME,On],[_.CHECKBOX_FORMULA_INPUT_NAME,En]],Ln="LIST_RENDER_MODE_OPTION_INPUT";function He(e){var r;const{value:t,onChange:n}=e,a=D.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{label:a.t("dataValidation.renderMode.label"),children:g.jsxs(V.RadioGroup,{value:`${(r=t.renderMode)!=null?r:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>n({...t,renderMode:+i}),children:[g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:a.t("dataValidation.renderMode.chip")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:a.t("dataValidation.renderMode.arrow")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:a.t("dataValidation.renderMode.text")})]})})}He.componentKey=Ln;const Pn="DATE_SHOW_TIME_OPTION";function Ye(e){var r;const{value:t,onChange:n}=e,a=D.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:(r=t.bizInfo)==null?void 0:r.showTime,onChange:i=>{n({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:a.t("dataValidation.showTime.label")})})}Ye.componentKey=Pn;var Un=Object.getOwnPropertyDescriptor,xn=(e,t,n,a)=>{for(var r=a>1?void 0:a?Un(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},De=(e,t)=>(n,a)=>t(n,a,e);const xe=6;let lt=class{constructor(e,t,n,a,r,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=a,this._renderManagerService=r,this._dataValidationModel=i}_calc(e,t){var d,h,p;const{vt:n,ht:a}=t||{},r=e.endX-e.startX-xe*2,i=e.endY-e.startY,s=((d=t==null?void 0:t.fs)!=null?d:10)*1.6;let c=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(a){case o.HorizontalAlign.LEFT:c=xe;break;case o.HorizontalAlign.RIGHT:c=xe+(r-s);break;default:c=xe+(r-s)/2;break}return{left:e.startX+c,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((p=t==null?void 0:t.fs)!=null?p: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 d,h,p,u,S,R,L,f,y;const{formula1:a=_.CHECKBOX_FORMULA_1,formula2:r=_.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=_.getFormulaResult((p=(h=(d=i==null?void 0:i[0])==null?void 0:d.result)==null?void 0:h[0])==null?void 0:p[0]),c=_.getFormulaResult((R=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:R[0]),l=_.isLegalFormulaResult(String(s))&&_.isLegalFormulaResult(String(c));return{formula1:o.isFormulaString(a)?_.getFormulaResult((y=(f=(L=i==null?void 0:i[0])==null?void 0:L.result)==null?void 0:f[0])==null?void 0:y[0]):a,formula2:o.isFormulaString(r)?c:r,isFormulaValid:l}}drawWith(e,t){var N,M,x,$;const{style:n,primaryWithCoord:a,unitId:r,subUnitId:i,worksheet:s,row:c,col:l}=t,d=a.isMergedMainCell?a.mergeInfo:a,h=_.getCellValueOrigin(s.getCellRaw(c,l)),p=this._dataValidationModel.getRuleByLocation(r,i,c,l);if(!p)return;const u=this._dataValidationModel.getValidator(p.type);if(!u||!((N=u.skipDefaultFontRender)!=null&&N.call(u,p,h,{unitId:r,subUnitId:i,row:c,column:l})))return;const S=u.parseFormulaSync(p,r,i),{formula1:R}=S,L=this._calc(d,n),{a:f,d:y}=e.getTransform(),I=P.fixLineWidthByScale(L.left,f),w=P.fixLineWidthByScale(L.top,y),O=P.Transform.create().composeMatrix({left:I,top:w,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),m=d.endX-d.startX,v=d.endY-d.startY;e.save(),e.beginPath(),e.rect(d.startX,d.startY,m,v),e.clip();const C=O.getMatrix();e.transform(C[0],C[1],C[2],C[3],C[4],C[5]);const U=((M=n==null?void 0:n.fs)!=null?M:10)*1.6,F=String(h)===String(R),k=this._themeService.getColorFromTheme("primary.600");P.CheckboxShape.drawWith(e,{checked:F,width:U,height:U,fill:($=(x=n==null?void 0:n.cl)==null?void 0:x.rgb)!=null?$:k}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,a=this._calc(n,t.style),r=a.top,i=a.top+a.height,s=a.left,c=a.left+a.width,{x:l,y:d}=e;return l<=c&&l>=s&&d<=i&&d>=r}async onPointerDown(e,t){var R;if(t.button===2)return;const{primaryWithCoord:n,unitId:a,subUnitId:r,worksheet:i,row:s,col:c}=e,l=_.getCellValueOrigin(i.getCellRaw(s,c)),d=this._dataValidationModel.getRuleByLocation(a,r,s,c);if(!d)return;const h=this._dataValidationModel.getValidator(d.type);if(!h||!((R=h.skipDefaultFontRender)!=null&&R.call(h,d,l,{unitId:a,subUnitId:r,row:s,column:c})))return;const{formula1:p,formula2:u}=await this._parseFormula(d,a,r),S={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===_.transformCheckboxValue(String(p))?u:p,p:null}};this._commandService.executeCommand(j.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};lt=xn([De(0,o.ICommandService),De(1,o.IUniverInstanceService),De(2,o.Inject(_.DataValidationFormulaService)),De(3,o.Inject(o.ThemeService)),De(4,o.Inject(P.IRenderManagerService)),De(5,o.Inject(_.SheetDataValidationModel))],lt);var jn=Object.getOwnPropertyDescriptor,Fn=(e,t,n,a)=>{for(var r=a>1?void 0:a?jn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},kn=(e,t)=>(n,a)=>t(n,a,e);exports.BaseSheetDataValidatorView=class{constructor(t){A(this,"canvasRender",null);A(this,"dropdownType");A(this,"optionsInput");A(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=Fn([kn(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);class Nn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.CHECKBOX);A(this,"canvasRender",this.injector.createInstance(lt));A(this,"formulaInput",_.CHECKBOX_FORMULA_INPUT_NAME)}}class Bn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.CUSTOM);A(this,"formulaInput",_.CUSTOM_FORMULA_INPUT_NAME)}}const Wn="data-validation.formula-input";class $n extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.DATE);A(this,"formulaInput",Wn);A(this,"optionsInput",Ye.componentKey);A(this,"dropdownType",Y.DataValidatorDropdownType.DATE)}}class Hn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.DECIMAL);A(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}const Lt=4,Yn=0,et=4,Pt=4,ct=6,Xe=6,fe=14;function Xn(e,t){const n=P.FontCache.getTextSize(e,t),a=n.width+Lt*2,{ba:r,bd:i}=n,s=r+i;return{width:a,height:s+Yn*2,ba:r}}function tt(e,t,n,a){const r=fe+ct*2,i=n-r,s=a-Xe*2,c=e.map(u=>({layout:Xn(u,t),text:u}));let l;const d=[];c.forEach(u=>{const{layout:S}=u,{width:R,height:L}=S;!l||l.width+R+et>i?(l={width:R,height:L,items:[{...u,left:0}]},d.push(l)):(l.items.push({...u,left:l.width+et}),l.width=l.width+R+et)});let h=0,p=0;return d.forEach((u,S)=>{p=Math.max(p,u.width),S===d.length-1?h+=u.height:h+=u.height+Pt}),{lines:d,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+Xe*2,calcAutoWidth:p+r}}const zn=8;class Kn extends P.Shape{static drawWith(t,n){const{fontString:a,info:r,fill:i,color:s}=n,{layout:c,text:l}=r;t.save(),P.Rect.drawWith(t,{width:c.width,height:c.height,radius:zn,fill:i||Se}),t.translateWithPrecision(Lt,c.ba),t.font=a,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Zn=Object.getOwnPropertyDescriptor,Gn=(e,t,n,a)=>{for(var r=a>1?void 0:a?Zn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},je=(e,t)=>(n,a)=>t(n,a,e);const qn=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 dt=class{constructor(e,t,n,a){A(this,"zIndex");A(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,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,a,r){const i=n-fe+4;let s=4;switch(r){case o.VerticalAlign.MIDDLE:s=(a-fe)/2+4;break;case o.VerticalAlign.BOTTOM:s=a-fe+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(qn),e.restore()}drawWith(e,t,n,a){var se,le;const{primaryWithCoord:r,row:i,col:s,style:c,data:l,subUnitId:d}=t,h=r.isMergedMainCell?r.mergeInfo:r,p=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:R=0,downOffset:L=0}=p||{},f=this._ensureMap(d),y=this._generateKey(i,s),I=r.isMergedMainCell?r.mergeInfo.startRow:i,w=r.isMergedMainCell?r.mergeInfo.startColumn:s,O=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,I,w);if(!O)return;const m=this._dataValidationModel.getValidator(O.type);if(!m)return;const v={startX:h.startX+u,endX:h.endX-S,startY:h.startY+R,endY:h.endY-L},C=v.endX-v.startX,U=v.endY-v.startY,{cl:F}=c||{},k=(se=typeof F=="object"?F==null?void 0:F.rgb:F)!=null?se:"#000",N=P.getFontStyleString(c!=null?c:void 0),{vt:M,ht:x}=c||{},$=M!=null?M:o.VerticalAlign.MIDDLE,B=(le=_.getCellValueOrigin(l))!=null?le:"",z=m.parseCellValue(B),ae=m.getListWithColorMap(O),Z=tt(z,N,C,U);this._drawDownIcon(e,v,C,U,$),e.save(),e.translateWithPrecision(v.startX,v.startY),e.beginPath(),e.rect(0,0,C-fe,U),e.clip(),e.translateWithPrecision(ct,Xe);let oe=0;switch($){case o.VerticalAlign.MIDDLE:oe=(Z.contentHeight-Z.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:oe=Z.contentHeight-Z.totalHeight;break}e.translateWithPrecision(0,oe),Z.lines.forEach((ve,te)=>{e.save();const{width:J,height:ce,items:ne}=ve;let Q=0;switch(x){case o.HorizontalAlign.RIGHT:Q=Z.contentWidth-J;break;case o.HorizontalAlign.CENTER:Q=(Z.contentWidth-J)/2;break}e.translate(Q,te*(ce+Pt)),ne.forEach(b=>{e.save(),e.translateWithPrecision(b.left,0),Kn.drawWith(e,{...N,info:b,color:k,fill:ae[b.text]}),e.restore()}),e.restore()}),e.restore(),f.set(y,{left:v.startX,top:v.startY,width:Z.contentWidth+ct+fe,height:Z.contentHeight+Xe*2})}calcCellAutoHeight(e){var m;const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+c,endX:p.endX-l,startY:p.startY+d,endY:p.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const R=this._dataValidationModel.getValidator(S.type);if(!R)return;const L=u.endX-u.startX,f=u.endY-u.startY,y=(m=_.getCellValueOrigin(a))!=null?m:"",I=R.parseCellValue(y),w=P.getFontStyleString(n!=null?n:void 0);return tt(I,w,L,f).cellAutoHeight}calcCellAutoWidth(e){var m;const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+c,endX:p.endX-l,startY:p.startY+d,endY:p.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const R=this._dataValidationModel.getValidator(S.type);if(!R)return;const L=u.endX-u.startX,f=u.endY-u.startY,y=(m=_.getCellValueOrigin(a))!=null?m:"",I=R.parseCellValue(y),w=P.getFontStyleString(n!=null?n:void 0);return tt(I,w,L,f).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,a=n.isMergedMainCell?n.mergeInfo:n,{endX:r}=a,{x:i}=e;return i>=r-fe&&i<=r}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:r,col:i}=e,s={unitId:n,subUnitId:a,row:r,column:i};this._commandService.executeCommand(ze.id,s)}onPointerEnter(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.DEFAULT)}};dt=Gn([je(0,o.ICommandService),je(1,o.IUniverInstanceService),je(2,o.Inject(P.IRenderManagerService)),je(3,o.Inject(_.SheetDataValidationModel))],dt);class Jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.LIST_MULTIPLE);A(this,"canvasRender",this.injector.createInstance(dt));A(this,"dropdownType",Y.DataValidatorDropdownType.MULTIPLE_LIST)}}var Qn=Object.getOwnPropertyDescriptor,ea=(e,t,n,a)=>{for(var r=a>1?void 0:a?Qn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Pe=(e,t)=>(n,a)=>t(n,a,e);const we=4,Fe=4,ue=14,nt=1,pe=6,Ee=3,at=8,ta="#565656",Ct=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 yt(e,t,n,a,r,i,s=!0){let c=0;const l=s?Ee:0;switch(r){case o.VerticalAlign.BOTTOM:c=t-a-l;break;case o.VerticalAlign.MIDDLE:c=(t-a)/2;break;default:c=l;break}c=Math.max(Ee,c);let d=0;switch(i){case o.HorizontalAlign.CENTER:d=(e-n)/2;break;case o.HorizontalAlign.RIGHT:d=e-n;break}return d=Math.max(pe,d),{paddingLeft:d,paddingTop:c}}let ut=class{constructor(e,t,n,a,r){A(this,"_dropdownInfoMap",new Map);A(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=a,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,a,r,i,s){const{t:c=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,d=n-ue;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(a-Fe)/2;break;case o.VerticalAlign.BOTTOM:h=a-l-r-Ee+(r/2-Fe/2);break;default:h=c+Ee+(r/2-Fe/2);break}e.save(),e.translateWithPrecision(t.startX+d,t.startY+h),e.fillStyle="#565656",e.fill(Ct),e.restore()}drawWith(e,t,n){var ae,Z,oe,se,le,ve;const{primaryWithCoord:a,row:r,col:i,style:s,data:c,subUnitId:l}=t,d=a.isMergedMainCell?a.mergeInfo:a,h=a.isMergedMainCell?a.mergeInfo.startRow:r,p=a.isMergedMainCell?a.mergeInfo.startColumn:i,u=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,h,p);if(!u)return;const S=this._dataValidationModel.getValidator(u.type);if(!S)return;const R=c==null?void 0:c.fontRenderExtension,{leftOffset:L=0,rightOffset:f=0,topOffset:y=0,downOffset:I=0}=R||{};if(!u||!S||!S||S.id.indexOf(o.DataValidationType.LIST)!==0||!S.skipDefaultFontRender(u))return;const w={startX:d.startX+L,endX:d.endX-f,startY:d.startY+y,endY:d.endY-I},O=w.endX-w.startX,m=w.endY-w.startY,v=this._ensureMap(l),C=this._generateKey(r,i),U=S.getListWithColorMap(u),F=_.getCellValueOrigin(c),k=`${F!=null?F:""}`,N=U[k];let{tb:M,vt:x,ht:$,pd:B}=s||{};M=M!=null?M:o.WrapStrategy.WRAP,x=x!=null?x:o.VerticalAlign.BOTTOM,$=$!=null?$:o.DEFAULT_STYLES.ht,B=B!=null?B:o.DEFAULT_STYLES.pd;const z=P.getFontStyleString(s).fontCache;if(u.renderMode===o.DataValidationRenderMode.ARROW){const{l:te=o.DEFAULT_STYLES.pd.l,t:J=o.DEFAULT_STYLES.pd.t,r:ce=o.DEFAULT_STYLES.pd.r,b:ne=o.DEFAULT_STYLES.pd.b}=B,Q=O-te-ce-ue-4,b=new P.DocSimpleSkeleton(k,z,M===o.WrapStrategy.WRAP,Q,1/0);b.calculate();const X=b.getTotalWidth(),W=b.getTotalHeight(),{paddingTop:ee,paddingLeft:E}=yt(Q,m-J-ne,X,W,x,$,!0);this._drawDownIcon(e,w,O,m,W,x,B),e.save(),e.translateWithPrecision(w.startX+te,w.startY+J),e.beginPath(),e.rect(0,0,O-te-ce,m-J-ne),e.clip(),e.translateWithPrecision(0,ee),e.save(),e.translateWithPrecision(E,0),e.beginPath(),e.rect(0,0,Q,W),e.clip(),P.Text.drawWith(e,{text:k,fontStyle:z,width:Q,height:W,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((Z=s==null?void 0:s.st)!=null&&Z.s),underline:!!((oe=s==null?void 0:s.ul)!=null&&oe.s),warp:M===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},b),e.restore(),e.restore(),v.set(C,{left:w.endX-ue+n.rowHeaderWidth,top:w.startY+J+n.columnHeaderHeight,width:ue,height:m-J-ne})}else{e.save(),e.translateWithPrecision(w.startX,w.startY),e.beginPath(),e.rect(0,0,O,m),e.clip();const te=O-pe*2-we-ue-4,J=new P.DocSimpleSkeleton(k,z,M===o.WrapStrategy.WRAP,te,1/0);J.calculate();const ce=J.getTotalWidth(),ne=J.getTotalHeight(),Q=ne+nt*2,b=Math.max(O-pe*2,1),{paddingTop:X}=yt(b,m,ce,Q,x,$);e.translateWithPrecision(pe,X),P.Rect.drawWith(e,{width:b,height:Q,fill:N||Se,radius:at}),e.save(),e.translateWithPrecision(we,nt),e.beginPath(),e.rect(0,0,te,ne),e.clip(),P.Text.drawWith(e,{text:k,fontStyle:z,width:te,height:ne,color:(se=s==null?void 0:s.cl)==null?void 0:se.rgb,strokeLine:!!((le=s==null?void 0:s.st)!=null&&le.s),underline:!!((ve=s==null?void 0:s.ul)!=null&&ve.s),warp:M===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},J),e.restore(),e.translateWithPrecision(te+we+4,(ne-Fe)/2),e.fillStyle=ta,e.fill(Ct),e.restore(),v.set(C,{left:w.startX+pe+n.rowHeaderWidth,top:w.startY+X+n.columnHeaderHeight,width:b,height:Q})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:p=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-p},R=S.endX-S.startX,L=_.getCellValueOrigin(a),f=`${L!=null?L:""}`;let{tb:y,pd:I}=n||{};const{t:w=o.DEFAULT_STYLES.pd.t,b:O=o.DEFAULT_STYLES.pd.b}=I!=null?I:{};if(y=y!=null?y:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:m=o.DEFAULT_STYLES.pd.l,r:v=o.DEFAULT_STYLES.pd.r}=I!=null?I:{},C=R-m-v-ue-4,U=new P.DocSimpleSkeleton(f,P.getFontStyleString(n).fontCache,y===o.WrapStrategy.WRAP,C,1/0);return U.calculate(),U.getTotalHeight()+w+O+Ee*2}else{const m=Math.max(R-pe*2-we-ue-4,10),v=new P.DocSimpleSkeleton(f,P.getFontStyleString(n).fontCache,y===o.WrapStrategy.WRAP,m,1/0);return v.calculate(),v.getTotalHeight()+Ee*2+nt*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:p=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-p},R=S.endX-S.startX,L=_.getCellValueOrigin(a),f=`${L!=null?L:""}`;let{tb:y,pd:I}=n||{};const{l:w=o.DEFAULT_STYLES.pd.l,r:O=o.DEFAULT_STYLES.pd.r}=I!=null?I:{};y=y!=null?y:o.WrapStrategy.WRAP;let m=pe*2+ue;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:m=ue+4+O+w;break;case o.DataValidationRenderMode.CUSTOM:m=ue+pe*2+we*2+O+w+at/2+1;break;default:m=ue+pe*2+we*2+O+w+at/2+1}const v=R-m,C=new P.DocSimpleSkeleton(f,P.getFontStyleString(n).fontCache,y===o.WrapStrategy.WRAP,v,1/0);return C.calculate(),C.getTotalWidth()+m}isHit(e,t){const{subUnitId:n,row:a,col:r}=t,s=this._ensureMap(n).get(this._generateKey(a,r)),c=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,r);if(!c||!s||c.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:d,width:h,height:p}=s,{x:u,y:S}=e;return u>=d&&u<=d+h&&S>=l&&S<=l+p}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:r,col:i}=e,s={unitId:n,subUnitId:a,row:r,column:i};this._commandService.executeCommand(ze.id,s)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};ut=ea([Pe(0,o.IUniverInstanceService),Pe(1,o.Inject(o.LocaleService)),Pe(2,o.ICommandService),Pe(3,o.Inject(P.IRenderManagerService)),Pe(4,o.Inject(_.SheetDataValidationModel))],ut);class na extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.LIST);A(this,"canvasRender",this.injector.createInstance(ut));A(this,"dropdownType",Y.DataValidatorDropdownType.LIST);A(this,"optionsInput",He.componentKey);A(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME)}}class aa extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.TEXT_LENGTH);A(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}class ra extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.WHOLE);A(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}var ia=Object.getOwnPropertyDescriptor,oa=(e,t,n,a)=>{for(var r=a>1?void 0:a?ia(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},rt=(e,t)=>(n,a)=>t(n,a,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",bt],[We,wn],[He.componentKey,He],[Ye.componentKey,Ye],...An].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Hn,ra,aa,$n,Nn,na,Jn,Bn].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=oa([rt(0,o.Inject(o.Injector)),rt(1,o.Inject(D.ComponentManager)),rt(2,o.Inject(Y.DataValidatorRegistryService))],Le);var sa=Object.getOwnPropertyDescriptor,la=(e,t,n,a)=>{for(var r=a>1?void 0:a?sa(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},it=(e,t)=>(n,a)=>t(n,a,e),Ve;exports.UniverSheetsDataValidationMobileUIPlugin=(Ve=class extends o.Plugin{constructor(t=Be,n,a,r){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=r;const{menu:i,...s}=o.merge({},Be,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ne,s)}onStarting(){[[he],[_e],[Ue],[be],[Ae],[Oe],[Te],[Le]].forEach(t=>{this._injector.add(t)}),[Ke,ze,Dt,gt,Ie,Rt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Te),this._injector.get(Oe),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[$e])}onRendered(){this._injector.get(Le),this._injector.get(Ae)}onSteady(){this._injector.get(be)}},A(Ve,"pluginName","SHEET_DATA_VALIDATION_UI_PLUGIN"),A(Ve,"packageName",ke.name),A(Ve,"version",ke.version),A(Ve,"type",o.UniverInstanceType.UNIVER_SHEET),Ve);exports.UniverSheetsDataValidationMobileUIPlugin=la([it(1,o.Inject(o.Injector)),it(2,o.ICommandService),it(3,o.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);var ca=Object.defineProperty,da=Object.getOwnPropertyDescriptor,ua=(e,t,n)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ha=(e,t,n,a)=>{for(var r=a>1?void 0:a?da(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ot=(e,t)=>(n,a)=>t(n,a,e),Ze=(e,t,n)=>ua(e,typeof t!="symbol"?t+"":t,n);exports.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Be,n,a,r){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=r;const{menu:i,...s}=o.merge({},Be,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ne,s)}onStarting(){[[he],[_e],[Ue],[be],[Ae],[Oe],[Te],[Me],[Le]].forEach(t=>{this._injector.add(t)}),[Ke,ze,Dt,gt,Ie,Rt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Te),this._injector.get(Oe),this._injector.get(Me),this._injector.get(Ue),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[$e])}onRendered(){this._injector.get(Le),this._injector.get(Ae)}onSteady(){this._injector.get(be)}};Ze(exports.UniverSheetsDataValidationUIPlugin,"pluginName","SHEET_DATA_VALIDATION_UI_PLUGIN");Ze(exports.UniverSheetsDataValidationUIPlugin,"packageName",ke.name);Ze(exports.UniverSheetsDataValidationUIPlugin,"version",ke.version);Ze(exports.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDataValidationUIPlugin=ha([o.DependentOn(_.UniverSheetsDataValidationPlugin),ot(1,o.Inject(o.Injector)),ot(2,o.ICommandService),ot(3,o.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);
|
|
8
|
+
`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!a,"univer-opacity-50":a}),onClick:n,onMouseEnter:()=>{a||(x(!0),m.current=t.ranges.map(e=>l.addShape({range:e,style:w,primary:null})))},onMouseLeave:()=>{var e;x(!1),(e=m.current)==null||e.forEach(e=>{e&&l.removeShape(e)}),m.current=void 0},children:[(0,S.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:u==null?void 0:u.generateRuleName(t)}),(0,S.jsx)(`div`,{className:`
|
|
12
|
+
univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px]
|
|
13
|
+
dark:!univer-text-gray-300
|
|
14
|
+
`,children:t.ranges.map(e=>(0,b.serializeRange)(e)).join(`,`)}),h?(0,S.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:T,children:(0,S.jsx)(y.DeleteIcon,{})}):null]})};function fe(e){let t=(0,p.useDependency)(d.SheetDataValidationModel),n=(0,p.useDependency)(c.IUniverInstanceService),r=(0,p.useDependency)(c.ICommandService),i=(0,p.useDependency)(c.Injector),a=(0,p.useDependency)(j),o=(0,p.useDependency)(c.LocaleService),[s,l]=(0,v.useState)([]),{workbook:f}=e,m=(0,p.useObservable)(f.activeSheet$,void 0,!0),h=f.getUnitId(),g=m==null?void 0:m.getSheetId();(0,v.useEffect)(()=>{l(t.getRules(h,g));let e=t.ruleChange$.subscribe(e=>{e.unitId===h&&e.subUnitId===g&&l(t.getRules(h,g))});return()=>{e.unsubscribe()}},[h,g,t]);let y=async()=>{let e=(0,d.createDefaultNewRule)(i),t={unitId:h,subUnitId:g,rule:e};await r.executeCommand(d.AddSheetDataValidationCommand.id,t),a.setActiveRule({unitId:h,subUnitId:g,rule:e})},b=()=>{r.executeCommand(d.RemoveSheetAllDataValidationCommand.id,{unitId:h,subUnitId:g})},x=(e=>{let t=n.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),r=t.getActiveSheet(),a=t.getUnitId(),o=r.getSheetId();return e.map(e=>(0,u.checkRangesEditablePermission)(i,a,o,e.ranges)?{...e}:{...e,disable:!0})})(s),C=x==null?void 0:x.some(e=>e.disable);return(0,S.jsxs)(`div`,{className:`univer-pb-4`,children:[x==null?void 0:x.map(e=>{var t;return(0,S.jsx)(de,{unitId:h,subUnitId:g,onClick:()=>{e.disable||a.setActiveRule({unitId:h,subUnitId:g,rule:e})},rule:e,disable:(t=e.disable)==null?!1:t},e.uid)}),(0,S.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[s.length&&!C?(0,S.jsx)(_.Button,{onClick:b,children:o.t(`dataValidation.panel.removeAll`)}):null,(0,S.jsx)(_.Button,{variant:`primary`,onClick:y,children:o.t(`dataValidation.panel.add`)})]})]})}const pe=()=>{let e=(0,p.useDependency)(j),t=(0,p.useObservable)(e.activeRule$,e.activeRule),n=(0,p.useDependency)(c.IUniverInstanceService),r=(0,p.useObservable)(()=>n.getCurrentTypeOfUnit$(c.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),i=(0,p.useObservable)(()=>{var e;return(e=r==null?void 0:r.activeSheet$)==null?(0,m.of)(null):e},void 0,void 0,[]);return!r||!i?null:t&&(t.subUnitId===i.getSheetId()||t.subUnitId===e.getFocusFormulaEditorActiveRuleSubUnitId())?(0,S.jsx)(ue,{},t.rule.uid):(0,S.jsx)(fe,{workbook:r})},me=e=>{let{isTwoFormula:t=!1,value:n,onChange:r,showError:i,validResult:a}=e,o=(0,p.useDependency)(c.LocaleService),s=i?a==null?void 0:a.formula1:``,l=i?a==null?void 0:a.formula2:``;return t?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_.FormLayout,{error:s,children:(0,S.jsx)(_.Input,{className:`univer-w-full`,placeholder:o.t(`dataValidation.panel.formulaPlaceholder`),value:n==null?void 0:n.formula1,onChange:e=>{r==null||r({...n,formula1:e})}})}),(0,S.jsx)(`div`,{className:`-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400`,children:o.t(`dataValidation.panel.formulaAnd`)}),(0,S.jsx)(_.FormLayout,{error:l,children:(0,S.jsx)(_.Input,{className:`univer-w-full`,placeholder:o.t(`dataValidation.panel.formulaPlaceholder`),value:n==null?void 0:n.formula2,onChange:e=>{r==null||r({...n,formula2:e})}})})]}):(0,S.jsx)(_.FormLayout,{error:s,children:(0,S.jsx)(_.Input,{className:`univer-w-full`,placeholder:o.t(`dataValidation.panel.formulaPlaceholder`),value:n==null?void 0:n.formula1,onChange:e=>{r==null||r({formula1:e})}})})};function he(e){let{value:t,onChange:n,showError:r,validResult:i}=e,a=(0,p.useDependency)(c.LocaleService),o=r?i==null?void 0:i.formula1:``,s=r?i==null?void 0:i.formula2:``,[l,u]=(0,v.useState)(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_.FormLayout,{children:(0,S.jsx)(_.Checkbox,{checked:l,onChange:e=>{e?u(!0):(u(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:a.t(`dataValidation.checkbox.tips`)})}),l?(0,S.jsx)(_.FormLayout,{label:a.t(`dataValidation.checkbox.checked`),error:o,children:(0,S.jsx)(_.Input,{className:`univer-w-full`,placeholder:a.t(`dataValidation.panel.valuePlaceholder`),value:t==null?void 0:t.formula1,onChange:e=>{n==null||n({...t,formula1:e||void 0})}})}):null,l?(0,S.jsx)(_.FormLayout,{label:a.t(`dataValidation.checkbox.unchecked`),error:s,children:(0,S.jsx)(_.Input,{className:`univer-w-full`,placeholder:a.t(`dataValidation.panel.valuePlaceholder`),value:t==null?void 0:t.formula2,onChange:e=>{n==null||n({...t,formula2:e||void 0})}})}):null]})}function ge(e){var t;let{unitId:n,subUnitId:r,value:i,onChange:a,showError:o,validResult:s}=e,c=o?s==null?void 0:s.formula1:void 0,l=(0,v.useRef)(null),[u,d]=(0,v.useState)(!1);return(0,p.useSidebarClick)(e=>{var t;(t=l.current)!=null&&t.isClickOutSide(e)&&d(!1)}),(0,S.jsx)(_.FormLayout,{error:c,children:(0,S.jsx)(x.FormulaEditor,{ref:l,className:(0,_.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
|
+
`,_.borderClassName),initValue:(t=i==null?void 0:i.formula1)==null?`=`:t,unitId:n,subUnitId:r,isFocus:u,isSupportAcrossSheet:!0,onChange:e=>{let t=(e==null?``:e).trim();t!==(i==null?void 0:i.formula1)&&(a==null||a({...i,formula1:t}))},onFocus:()=>d(!0)})})}const _e=[`#FFFFFF`,`#FEE7E7`,`#FEF0E6`,`#EFFBD0`,`#E4F4FE`,`#E8ECFD`,`#F1EAFA`,`#FDE8F3`,`#E5E5E5`,`#FDCECE`,`#FDC49B`,`#DEF6A2`,`#9FDAFF`,`#D0D9FB`,`#E3D5F6`,`#FBD0E8`,`#656565`,`#FE4B4B`,`#FF8C51`,`#8BBB11`,`#0B9EFB`,`#3A60F7`,`#9E6DE3`,`#F248A6`],ve=e=>{let{value:t,onChange:n,disabled:r}=e,[i,a]=(0,v.useState)(!1);return(0,S.jsx)(_.Dropdown,{align:`start`,disabled:r,open:i,onOpenChange:a,overlay:(0,S.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:_e.map(e=>(0,S.jsx)(`div`,{className:(0,_.clsx)(`univer-box-border univer-size-4 univer-cursor-pointer univer-rounded`,_.borderClassName),style:{background:e},onClick:()=>{n(e),a(!1)}},e))}),children:(0,S.jsxs)(`div`,{className:(0,_.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
|
+
`,_.borderClassName),children:[(0,S.jsx)(`div`,{className:`univer-box-border univer-size-4 univer-rounded univer-text-base`,style:{background:t}}),(0,S.jsx)(y.MoreDownIcon,{})]})})},ye=e=>{let{item:t,commonProps:n,className:r}=e,{onItemChange:i,onItemDelete:a}=n;return(0,S.jsxs)(`div`,{className:(0,_.clsx)(`univer-flex univer-items-center univer-gap-2`,r),children:[!t.isRef&&(0,S.jsx)(`div`,{className:(0,_.clsx)(`univer-cursor-move`,`draggableHandle`),children:(0,S.jsx)(y.SequenceIcon,{})}),(0,S.jsx)(ve,{value:t.color,onChange:e=>{i(t.id,t.label,e)}}),(0,S.jsx)(_.Input,{disabled:t.isRef,value:t.label,onChange:e=>{i(t.id,e,t.color)}}),t.isRef?null:(0,S.jsx)(`div`,{className:`
|
|
37
|
+
univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base
|
|
38
|
+
hover:univer-bg-gray-200
|
|
39
|
+
`,children:(0,S.jsx)(y.DeleteIcon,{onClick:()=>a(t.id)})})]})};function be(e){let{value:t,onChange:n=()=>{},unitId:r,subUnitId:i,validResult:a,showError:o,ruleId:s}=e,{formula1:l=``,formula2:u=``}=t||{},[h,g]=(0,v.useState)(()=>(0,c.isFormulaString)(l)?`1`:`0`),[b,C]=(0,v.useState)(h===`1`?l:`=`),[w,T]=(0,v.useState)(h===`1`?l:`=`),E=(0,p.useDependency)(c.LocaleService),D=(0,p.useDependency)(f.DataValidatorRegistryService),O=(0,p.useDependency)(f.DataValidationModel),k=(0,p.useDependency)(d.DataValidationFormulaController),A=(0,p.useDependency)(j),[M,N]=(0,v.useState)(()=>u.split(`,`)),P=D.getValidatorItem(c.DataValidationType.LIST),[F,I]=(0,v.useState)([]),[L,R]=(0,v.useState)(``),z=o?a==null?void 0:a.formula1:``,B=(0,p.useObservable)((0,v.useMemo)(()=>O.ruleChange$.pipe((0,m.debounceTime)(16)),[])),V=(0,p.useEvent)(n);(0,v.useEffect)(()=>{(async()=>{await new Promise(e=>{setTimeout(()=>e(!0),100)});let e=O.getRuleById(r,i,s);(0,c.isFormulaString)(e==null?void 0:e.formula1)&&P&&e&&I(await P.getListAsync(e,r,i))})()},[O,B,P,s,i,r]),(0,v.useEffect)(()=>{(0,c.isFormulaString)(l)&&l!==w&&(C(l),T(w))},[w,l]);let[H,U]=(0,v.useState)(()=>{let e=h===`1`?[]:(0,d.deserializeListOptions)(l),t=u.split(`,`);return e.map((e,n)=>({label:e,color:t[n]||`#ECECEC`,isRef:!1,id:(0,c.generateRandomId)(4)}))}),W=(e,t,n)=>{let r=H.find(t=>t.id===e);r&&(r.label=t,r.color=n,U([...H]))},G=e=>{let t=H.findIndex(t=>t.id===e);t!==-1&&(H.splice(t,1),U([...H]))},K=u.split(`,`),q=(0,v.useMemo)(()=>F.map((e,t)=>({label:e,color:K[t]||`#ECECEC`,id:`${t}`,isRef:!0})),[K,F]),J=(e,t,n)=>{let r=[...M];r[+e]=n,N(r),V({formula1:l,formula2:r.join(`,`)})},Y=()=>{U([...H,{label:``,color:`#ECECEC`,isRef:!1,id:(0,c.generateRandomId)(4)}])};(0,v.useEffect)(()=>{if(h===`1`)return;let e=new Set,t=[];H.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}))})}),V({formula1:(0,d.serializeListOptions)(t.map(e=>e.label)),formula2:t.map(e=>e.color===`#ECECEC`?``:e.color).join(`,`)})},[H,V,h,w,M]);let ee=(0,p.useEvent)(async e=>{if(!(0,c.isFormulaString)(e)){V==null||V({formula1:``,formula2:u});return}k.getFormulaRefCheck(e)?(V==null||V({formula1:(0,c.isFormulaString)(e)?e:``,formula2:u}),R(``)):(V==null||V({formula1:``,formula2:u}),C(`=`),R(E.t(`dataValidation.validFail.formulaError`)))}),te=(0,v.useRef)(null),[X,ne]=(0,v.useState)(!1);return(0,p.useSidebarClick)(e=>{var t;(t=te.current)!=null&&t.isClickOutSide(e)&&ne(!1)}),(0,v.useEffect)(()=>{X?A.setFocusFormulaEditorActiveRuleSubUnitId(i):A.setFocusFormulaEditorActiveRuleSubUnitId(null)},[X,i,A]),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_.FormLayout,{label:E.t(`dataValidation.list.options`),children:(0,S.jsxs)(_.RadioGroup,{value:h,onChange:e=>{g(e),C(w),e===`1`&&V({formula1:w===`=`?``:w,formula2:M.join(`,`)})},children:[(0,S.jsx)(_.Radio,{value:`0`,children:E.t(`dataValidation.list.customOptions`)}),(0,S.jsx)(_.Radio,{value:`1`,children:E.t(`dataValidation.list.refOptions`)})]})}),h===`1`?(0,S.jsxs)(_.FormLayout,{error:z||L||void 0,children:[(0,S.jsx)(x.FormulaEditor,{ref:te,className:(0,_.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
|
+
`,_.borderClassName),initValue:b,unitId:r,subUnitId:i,isFocus:X,isSupportAcrossSheet:!0,onFocus:()=>ne(!0),onChange:(e=``)=>{let t=(e==null?``:e).trim();T(t),ee(t)}}),q.length>0&&(0,S.jsx)(`div`,{className:`univer-mt-3`,children:q.map(e=>(0,S.jsx)(ye,{className:`univer-mb-3`,item:e,commonProps:{onItemChange:J}},e.id))})]}):(0,S.jsx)(_.FormLayout,{error:z,children:(0,S.jsxs)(`div`,{className:`-univer-mt-3`,children:[(0,S.jsx)(_.DraggableList,{list:H,onListChange:U,rowHeight:28,margin:[0,12],draggableHandle:`.draggableHandle`,itemRender:e=>(0,S.jsx)(ye,{item:e,commonProps:{onItemChange:W,onItemDelete:G}},e.id),idKey:`id`}),(0,S.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:Y,children:[(0,S.jsx)(y.IncreaseIcon,{className:`univer-mr-1`}),E.t(`dataValidation.list.add`)]})]})})]})}const xe=[[d.CUSTOM_FORMULA_INPUT_NAME,ge],[d.BASE_FORMULA_INPUT_NAME,me],[d.LIST_FORMULA_INPUT_NAME,be],[d.CHECKBOX_FORMULA_INPUT_NAME,he]];function Se(e){var t;let{value:n,onChange:r}=e,i=(0,p.useDependency)(c.LocaleService);return(0,S.jsx)(_.FormLayout,{label:i.t(`dataValidation.renderMode.label`),children:(0,S.jsxs)(_.RadioGroup,{value:`${(t=n.renderMode)==null?c.DataValidationRenderMode.CUSTOM:t}`,onChange:e=>r({...n,renderMode:+e}),children:[(0,S.jsx)(_.Radio,{value:`${c.DataValidationRenderMode.CUSTOM}`,children:i.t(`dataValidation.renderMode.chip`)}),(0,S.jsx)(_.Radio,{value:`${c.DataValidationRenderMode.ARROW}`,children:i.t(`dataValidation.renderMode.arrow`)}),(0,S.jsx)(_.Radio,{value:`${c.DataValidationRenderMode.TEXT}`,children:i.t(`dataValidation.renderMode.text`)})]})})}Se.componentKey=`LIST_RENDER_MODE_OPTION_INPUT`;function Ce(e){var t;let{value:n,onChange:r}=e,i=(0,p.useDependency)(c.LocaleService);return(0,S.jsx)(_.FormLayout,{children:(0,S.jsx)(_.Checkbox,{checked:(t=n.bizInfo)==null?void 0:t.showTime,onChange:e=>{r({...n,bizInfo:{...n.bizInfo,showTime:e}})},children:i.t(`dataValidation.showTime.label`)})})}Ce.componentKey=`DATE_SHOW_TIME_OPTION`;let we=class{_calc(e,t){var n,r,i;let{vt:a,ht:o}=t||{},s=e.endX-e.startX-12,l=e.endY-e.startY,u=((n=t==null?void 0:t.fs)==null?10:n)*1.6,d=0,f=0;switch(a){case c.VerticalAlign.TOP:f=0;break;case c.VerticalAlign.BOTTOM:f=0+(l-u);break;default:f=0+(l-u)/2;break}switch(o){case c.HorizontalAlign.LEFT:d=6;break;case c.HorizontalAlign.RIGHT:d=6+(s-u);break;default:d=6+(s-u)/2;break}return{left:e.startX+d,top:e.startY+f,width:((r=t==null?void 0:t.fs)==null?10:r)*1.6,height:((i=t==null?void 0:t.fs)==null?10:i)*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,t,n){var r,i,a;let{formula1:o=d.CHECKBOX_FORMULA_1,formula2:s=d.CHECKBOX_FORMULA_2}=e,l=await this._formulaService.getRuleFormulaResult(t,n,e.uid),u=(0,d.getFormulaResult)(l==null||(r=l[0])==null||(r=r.result)==null||(r=r[0])==null?void 0:r[0]),f=(0,d.getFormulaResult)(l==null||(i=l[1])==null||(i=i.result)==null||(i=i[0])==null?void 0:i[0]),p=(0,d.isLegalFormulaResult)(String(u))&&(0,d.isLegalFormulaResult)(String(f));return{formula1:(0,c.isFormulaString)(o)?(0,d.getFormulaResult)(l==null||(a=l[0])==null||(a=a.result)==null||(a=a[0])==null?void 0:a[0]):o,formula2:(0,c.isFormulaString)(s)?f:s,isFormulaValid:p}}drawWith(e,t){var n,r,i,a;let{style:o,primaryWithCoord:s,unitId:c,subUnitId:u,worksheet:f,row:p,col:m}=t,h=s.isMergedMainCell?s.mergeInfo:s,g=(0,d.getCellValueOrigin)(f.getCellRaw(p,m)),_=this._dataValidationModel.getRuleByLocation(c,u,p,m);if(!_)return;let v=this._dataValidationModel.getValidator(_.type);if(!v||!((n=v.skipDefaultFontRender)!=null&&n.call(v,_,g,{unitId:c,subUnitId:u,row:p,column:m})))return;let{formula1:y}=v.parseFormulaSync(_,c,u),b=this._calc(h,o),{a:x,d:S}=e.getTransform(),C=(0,l.fixLineWidthByScale)(b.left,x),w=(0,l.fixLineWidthByScale)(b.top,S),T=l.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=((r=o==null?void 0:o.fs)==null?10:r)*1.6,A=String(g)===String(y),j=this._themeService.getColorFromTheme(`primary.600`);l.CheckboxShape.drawWith(e,{checked:A,width:k,height:k,fill:(i=o==null||(a=o.cl)==null?void 0:a.rgb)==null?j:i}),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:r,unitId:i,subUnitId:a,worksheet:o,row:s,col:c}=e,l=(0,d.getCellValueOrigin)(o.getCellRaw(s,c)),f=this._dataValidationModel.getRuleByLocation(i,a,s,c);if(!f)return;let p=this._dataValidationModel.getValidator(f.type);if(!p||!((n=p.skipDefaultFontRender)!=null&&n.call(p,f,l,{unitId:i,subUnitId:a,row:s,column:c})))return;let{formula1:m,formula2:h}=await this._parseFormula(f,i,a),g={range:{startColumn:r.actualColumn,endColumn:r.actualColumn,startRow:r.actualRow,endRow:r.actualRow},value:{v:String(l)===(0,d.transformCheckboxValue)(String(m))?h:m,p:null}};this._commandService.executeCommand(u.SetRangeValuesCommand.id,g)}onPointerEnter(e,t){var n;(n=(0,l.getCurrentTypeOfRenderer)(c.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null||n.setCursor(l.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n;(n=(0,l.getCurrentTypeOfRenderer)(c.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null||n.setCursor(l.CURSOR_TYPE.DEFAULT)}};we=A([k(0,c.ICommandService),k(1,c.IUniverInstanceService),k(2,(0,c.Inject)(d.DataValidationFormulaService)),k(3,(0,c.Inject)(c.ThemeService)),k(4,(0,c.Inject)(l.IRenderManagerService)),k(5,(0,c.Inject)(d.SheetDataValidationModel))],we);let Q=class{constructor(e){this.injector=e,O(this,`canvasRender`,null),O(this,`dropdownType`,void 0),O(this,`optionsInput`,void 0),O(this,`formulaInput`,d.LIST_FORMULA_INPUT_NAME)}};Q=A([k(0,(0,c.Inject)(c.Injector))],Q);var Te=class extends Q{constructor(...e){super(...e),O(this,`id`,c.DataValidationType.CHECKBOX),O(this,`canvasRender`,this.injector.createInstance(we)),O(this,`formulaInput`,d.CHECKBOX_FORMULA_INPUT_NAME)}},Ee=class extends Q{constructor(...e){super(...e),O(this,`id`,c.DataValidationType.CUSTOM),O(this,`formulaInput`,d.CUSTOM_FORMULA_INPUT_NAME)}},De=class extends Q{constructor(...e){super(...e),O(this,`id`,c.DataValidationType.DATE),O(this,`formulaInput`,`data-validation.formula-input`),O(this,`optionsInput`,Ce.componentKey),O(this,`dropdownType`,f.DataValidatorDropdownType.DATE)}},Oe=class extends Q{constructor(...e){super(...e),O(this,`id`,c.DataValidationType.DECIMAL),O(this,`formulaInput`,d.BASE_FORMULA_INPUT_NAME)}};function ke(e,t){let n=l.FontCache.getTextSize(e,t),r=n.width+8,{ba:i,bd:a}=n;return{width:r,height:i+a+0,ba:i}}function Ae(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 l.Shape{static drawWith(e,t){let{fontString:n,info:r,fill:i,color:a}=t,{layout:o,text:s}=r;e.save(),l.Rect.drawWith(e,{width:o.width,height:o.height,radius:8,fill:i||`#ECECEC`}),e.translateWithPrecision(4,o.ba),e.font=n,e.fillStyle=a,e.fillText(s,0,0),e.restore()}};const Me=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 Ne=class{constructor(e,t,n,r){this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=r,O(this,`zIndex`,void 0),O(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,t,n,r,i){let a=n-14+4,o=4;switch(i){case c.VerticalAlign.MIDDLE:o=(r-14)/2+4;break;case c.VerticalAlign.BOTTOM:o=r-14+4;break;default:break}e.save(),e.translateWithPrecision(t.startX+a,t.startY+o),e.fillStyle=`#565656`,e.fill(Me),e.restore()}drawWith(e,t,n,r){var i,a;let{primaryWithCoord:o,row:s,col:u,style:f,data:p,subUnitId:m}=t,h=o.isMergedMainCell?o.mergeInfo:o,{leftOffset:g=0,rightOffset:_=0,topOffset:v=0,downOffset:y=0}=(p==null?void 0:p.fontRenderExtension)||{},b=this._ensureMap(m),x=this._generateKey(s,u),S=o.isMergedMainCell?o.mergeInfo.startRow:s,C=o.isMergedMainCell?o.mergeInfo.startColumn:u,w=this._dataValidationModel.getRuleByLocation(t.unitId,t.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=(i=typeof k==`object`?k==null?void 0:k.rgb:k)==null?`#000`:i,j=(0,l.getFontStyleString)(f==null?void 0:f),{vt:M,ht:N}=f||{},P=M==null?c.VerticalAlign.MIDDLE:M,F=(a=(0,d.getCellValueOrigin)(p))==null?``:a,I=T.parseCellValue(F),L=T.getListWithColorMap(w),R=Ae(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 c.VerticalAlign.MIDDLE:z=(R.contentHeight-R.totalHeight)/2;break;case c.VerticalAlign.BOTTOM:z=R.contentHeight-R.totalHeight;break;default:break}e.translateWithPrecision(0,z),R.lines.forEach((t,n)=>{e.save();let{width:r,height:i,items:a}=t,o=0;switch(N){case c.HorizontalAlign.RIGHT:o=R.contentWidth-r;break;case c.HorizontalAlign.CENTER:o=(R.contentWidth-r)/2;break;default:break}e.translate(o,n*(i+4)),a.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:n,style:r,data:i,row:a,col:o}=e,{leftOffset:s=0,rightOffset:c=0,topOffset:u=0,downOffset:f=0}=(i==null?void 0:i.fontRenderExtension)||{},p=n.isMergedMainCell?n.mergeInfo:n,m={startX:p.startX+s,endX:p.endX-c,startY:p.startY+u,endY:p.endY-f},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,o);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,d.getCellValueOrigin)(i))==null?``:t;return Ae(g.parseCellValue(y),(0,l.getFontStyleString)(r==null?void 0:r),_,v).cellAutoHeight}calcCellAutoWidth(e){var t;let{primaryWithCoord:n,style:r,data:i,row:a,col:o}=e,{leftOffset:s=0,rightOffset:c=0,topOffset:u=0,downOffset:f=0}=(i==null?void 0:i.fontRenderExtension)||{},p=n.isMergedMainCell?n.mergeInfo:n,m={startX:p.startX+s,endX:p.endX-c,startY:p.startY+u,endY:p.endY-f},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,o);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,d.getCellValueOrigin)(i))==null?``:t;return Ae(g.parseCellValue(y),(0,l.getFontStyleString)(r==null?void 0:r),_,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(H.id,o)}onPointerEnter(e,t){var n;return(n=(0,l.getCurrentTypeOfRenderer)(c.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null?void 0:n.setCursor(l.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n;return(n=(0,l.getCurrentTypeOfRenderer)(c.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null?void 0:n.setCursor(l.CURSOR_TYPE.DEFAULT)}};Ne=A([k(0,c.ICommandService),k(1,c.IUniverInstanceService),k(2,(0,c.Inject)(l.IRenderManagerService)),k(3,(0,c.Inject)(d.SheetDataValidationModel))],Ne);var Pe=class extends Q{constructor(...e){super(...e),O(this,`id`,c.DataValidationType.LIST_MULTIPLE),O(this,`canvasRender`,this.injector.createInstance(Ne)),O(this,`dropdownType`,f.DataValidatorDropdownType.MULTIPLE_LIST)}};const Fe=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 Ie(e,t,n,r,i,a,o=!0){let s=0,l=o?3:0;switch(i){case c.VerticalAlign.BOTTOM:s=t-r-l;break;case c.VerticalAlign.MIDDLE:s=(t-r)/2;break;default:s=l;break}s=Math.max(3,s);let u=0;switch(a){case c.HorizontalAlign.CENTER:u=(e-n)/2;break;case c.HorizontalAlign.RIGHT:u=e-n;break;default:break}return u=Math.max(6,u),{paddingLeft:u,paddingTop:s}}let Le=class{constructor(e,t,n,r,i){this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=r,this._dataValidationModel=i,O(this,`_dropdownInfoMap`,new Map),O(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,t,n,r,i,a,o){let{t:s=c.DEFAULT_STYLES.pd.t,b:l=c.DEFAULT_STYLES.pd.b}=o,u=n-14,d;switch(a){case c.VerticalAlign.MIDDLE:d=(r-4)/2;break;case c.VerticalAlign.BOTTOM:d=r-l-i-3+(i/2-4/2);break;default:d=s+3+(i/2-4/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+d),e.fillStyle=`#565656`,e.fill(Fe),e.restore()}drawWith(e,t,n){var r,i,a,o;let{primaryWithCoord:s,row:u,col:f,style:p,data:m,subUnitId:h}=t,g=s.isMergedMainCell?s.mergeInfo:s,_=s.isMergedMainCell?s.mergeInfo.startRow:u,v=s.isMergedMainCell?s.mergeInfo.startColumn:f,y=this._dataValidationModel.getRuleByLocation(t.unitId,t.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(c.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(u,f),A=b.getListWithColorMap(y),j=(0,d.getCellValueOrigin)(m),M=`${j==null?``:j}`,N=A[M],{tb:P,vt:F,ht:I,pd:L}=p||{};P=(r=P)==null?c.WrapStrategy.WRAP:r,F=(i=F)==null?c.VerticalAlign.BOTTOM:i,I=(a=I)==null?c.DEFAULT_STYLES.ht:a,L=(o=L)==null?c.DEFAULT_STYLES.pd:o;let R=(0,l.getFontStyleString)(p).fontCache;if(y.renderMode===c.DataValidationRenderMode.ARROW){var z,B,V;let{l:t=c.DEFAULT_STYLES.pd.l,t:r=c.DEFAULT_STYLES.pd.t,r:i=c.DEFAULT_STYLES.pd.r,b:a=c.DEFAULT_STYLES.pd.b}=L,o=E-t-i-14-4,s=new l.DocSimpleSkeleton(M,R,P===c.WrapStrategy.WRAP,o,1/0);s.calculate();let u=s.getTotalWidth(),d=s.getTotalHeight(),{paddingTop:f,paddingLeft:m}=Ie(o,D-r-a,u,d,F,I,!0);this._drawDownIcon(e,T,E,D,d,F,L),e.save(),e.translateWithPrecision(T.startX+t,T.startY+r),e.beginPath(),e.rect(0,0,E-t-i,D-r-a),e.clip(),e.translateWithPrecision(0,f),e.save(),e.translateWithPrecision(m,0),e.beginPath(),e.rect(0,0,o,d),e.clip(),l.Text.drawWith(e,{text:M,fontStyle:R,width:o,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===c.WrapStrategy.WRAP,hAlign:c.HorizontalAlign.LEFT},s),e.restore(),e.restore(),O.set(k,{left:T.endX-14+n.rowHeaderWidth,top:T.startY+r+n.columnHeaderHeight,width:14,height:D-r-a})}else{var H,U,W;e.save(),e.translateWithPrecision(T.startX,T.startY),e.beginPath(),e.rect(0,0,E,D),e.clip();let t=E-12-4-14-4,r=new l.DocSimpleSkeleton(M,R,P===c.WrapStrategy.WRAP,t,1/0);r.calculate();let i=r.getTotalWidth(),a=r.getTotalHeight(),o=a+2,s=Math.max(E-12,1),{paddingTop:u}=Ie(s,D,i,o,F,I);e.translateWithPrecision(6,u),l.Rect.drawWith(e,{width:s,height:o,fill:N||`#ECECEC`,radius:8}),e.save(),e.translateWithPrecision(4,1),e.beginPath(),e.rect(0,0,t,a),e.clip(),l.Text.drawWith(e,{text:M,fontStyle:R,width:t,height:a,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===c.WrapStrategy.WRAP,hAlign:c.HorizontalAlign.LEFT},r),e.restore(),e.translateWithPrecision(t+4+4,(a-4)/2),e.fillStyle=`#565656`,e.fill(Fe),e.restore(),O.set(k,{left:T.startX+6+n.rowHeaderWidth,top:T.startY+u+n.columnHeaderHeight,width:s,height:o})}}calcCellAutoHeight(e){var t;let{primaryWithCoord:n,style:r,data:i,row:a,col:o}=e,s=n.isMergedMainCell?n.mergeInfo:n,{leftOffset:u=0,rightOffset:f=0,topOffset:p=0,downOffset:m=0}=(i==null?void 0:i.fontRenderExtension)||{},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,o);if(!h||h.renderMode===c.DataValidationRenderMode.TEXT)return;let g={startX:s.startX+u,endX:s.endX-f,startY:s.startY+p,endY:s.endY-m},_=g.endX-g.startX,v=(0,d.getCellValueOrigin)(i),y=`${v==null?``:v}`,{tb:b,pd:x}=r||{},{t:S=c.DEFAULT_STYLES.pd.t,b:C=c.DEFAULT_STYLES.pd.b}=x==null?{}:x;if(b=(t=b)==null?c.WrapStrategy.WRAP:t,h.renderMode===c.DataValidationRenderMode.ARROW){let{l:e=c.DEFAULT_STYLES.pd.l,r:t=c.DEFAULT_STYLES.pd.r}=x==null?{}:x,n=_-e-t-14-4,i=new l.DocSimpleSkeleton(y,(0,l.getFontStyleString)(r).fontCache,b===c.WrapStrategy.WRAP,n,1/0);return i.calculate(),i.getTotalHeight()+S+C+6}else{let e=Math.max(_-12-4-14-4,10),t=new l.DocSimpleSkeleton(y,(0,l.getFontStyleString)(r).fontCache,b===c.WrapStrategy.WRAP,e,1/0);return t.calculate(),t.getTotalHeight()+6+2}}calcCellAutoWidth(e){var t;let{primaryWithCoord:n,style:r,data:i,row:a,col:o}=e,s=n.isMergedMainCell?n.mergeInfo:n,{leftOffset:u=0,rightOffset:f=0,topOffset:p=0,downOffset:m=0}=(i==null?void 0:i.fontRenderExtension)||{},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,o);if(!h||h.renderMode===c.DataValidationRenderMode.TEXT)return;let g={startX:s.startX+u,endX:s.endX-f,startY:s.startY+p,endY:s.endY-m},_=g.endX-g.startX,v=(0,d.getCellValueOrigin)(i),y=`${v==null?``:v}`,{tb:b,pd:x}=r||{},{l:S=c.DEFAULT_STYLES.pd.l,r:C=c.DEFAULT_STYLES.pd.r}=x==null?{}:x;b=(t=b)==null?c.WrapStrategy.WRAP:t;let w=26;switch(h.renderMode){case c.DataValidationRenderMode.ARROW:w=18+C+S;break;case c.DataValidationRenderMode.CUSTOM:w=34+C+S+8/2+1;break;default:w=34+C+S+8/2+1}let T=_-w,E=new l.DocSimpleSkeleton(y,(0,l.getFontStyleString)(r).fontCache,b===c.WrapStrategy.WRAP,T,1/0);return E.calculate(),E.getTotalWidth()+w}isHit(e,t){let{subUnitId:n,row:r,col:i}=t,a=this._ensureMap(n).get(this._generateKey(r,i)),o=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,i);if(!o||!a||o.renderMode===c.DataValidationRenderMode.TEXT)return!1;let{top:s,left:l,width:u,height:d}=a,{x:f,y:p}=e;return f>=l&&f<=l+u&&p>=s&&p<=s+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(H.id,o)}onPointerEnter(e,t){var n;(n=(0,l.getCurrentTypeOfRenderer)(c.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null||n.setCursor(l.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n;(n=(0,l.getCurrentTypeOfRenderer)(c.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(n=n.mainComponent)==null||n.setCursor(l.CURSOR_TYPE.DEFAULT)}};Le=A([k(0,c.IUniverInstanceService),k(1,(0,c.Inject)(c.LocaleService)),k(2,c.ICommandService),k(3,(0,c.Inject)(l.IRenderManagerService)),k(4,(0,c.Inject)(d.SheetDataValidationModel))],Le);var Re=class extends Q{constructor(...e){super(...e),O(this,`id`,c.DataValidationType.LIST),O(this,`canvasRender`,this.injector.createInstance(Le)),O(this,`dropdownType`,f.DataValidatorDropdownType.LIST),O(this,`optionsInput`,Se.componentKey),O(this,`formulaInput`,d.LIST_FORMULA_INPUT_NAME)}},ze=class extends Q{constructor(...e){super(...e),O(this,`id`,c.DataValidationType.TEXT_LENGTH),O(this,`formulaInput`,d.BASE_FORMULA_INPUT_NAME)}},Be=class extends Q{constructor(...e){super(...e),O(this,`id`,c.DataValidationType.WHOLE),O(this,`formulaInput`,d.BASE_FORMULA_INPUT_NAME)}};let Ve=class extends c.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[`DataValidationIcon`,y.DataValidationIcon],[R,pe],[Se.componentKey,Se],[Ce.componentKey,Ce],...xe].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Oe,Be,ze,De,Te,Re,Pe,Ee].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)})}};Ve=A([k(0,(0,c.Inject)(c.Injector)),k(1,(0,c.Inject)(p.ComponentManager)),k(2,(0,c.Inject)(f.DataValidatorRegistryService))],Ve);let $=class extends c.Plugin{constructor(e=N,t,n,r){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=r;let{menu:i,...a}=(0,c.merge)({},N,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(M,a)}onStarting(){[[j],[L],[K],[q],[Z],[Y],[J],[Ve]].forEach(e=>{this._injector.add(e)}),[W,H,U,B,z,V].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(J),this._injector.get(Y),this._injector.get(l.IRenderManagerService).registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[oe])}onRendered(){this._injector.get(Ve),this._injector.get(Z)}onSteady(){this._injector.get(q)}};O($,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),O($,`packageName`,C),O($,`version`,w),O($,`type`,c.UniverInstanceType.UNIVER_SHEET),$=A([k(1,(0,c.Inject)(c.Injector)),k(2,c.ICommandService),k(3,c.IConfigService)],$);let He=class extends c.Plugin{constructor(e=N,t,n,r){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=r;let{menu:i,...a}=(0,c.merge)({},N,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(M,a)}onStarting(){[[j],[L],[K],[q],[Z],[Y],[J],[P],[Ve]].forEach(e=>{this._injector.add(e)}),[W,H,U,B,z,V].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(J),this._injector.get(Y),this._injector.get(P),this._injector.get(K),this._injector.get(l.IRenderManagerService).registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[oe])}onRendered(){this._injector.get(Ve),this._injector.get(Z)}onSteady(){this._injector.get(q)}};O(He,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),O(He,`packageName`,C),O(He,`version`,w),O(He,`type`,c.UniverInstanceType.UNIVER_SHEET),He=A([(0,c.DependentOn)(d.UniverSheetsDataValidationPlugin),k(1,(0,c.Inject)(c.Injector)),k(2,c.ICommandService),k(3,c.IConfigService)],He),Object.defineProperty(exports,`BaseSheetDataValidatorView`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`UniverSheetsDataValidationMobileUIPlugin`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`UniverSheetsDataValidationUIPlugin`,{enumerable:!0,get:function(){return He}});
|
package/lib/cjs/locale/ca-ES.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={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`}}};module.exports=e;
|
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={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`}}};module.exports=e;
|
package/lib/cjs/locale/es-ES.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e={dataValidation:{title:`Validación de datos`,validFail:{value:`Por favor, introduce un valor`,common:`Por favor, introduce un valor o fórmula`,number:`Por favor, introduce un número o fórmula`,formula:`Por favor, introduce una fórmula`,integer:`Por favor, introduce un entero o fórmula`,date:`Por favor, introduce una fecha o fórmula`,list:`Por favor, introduce opciones`,listInvalid:`La fuente de la lista debe ser una lista delimitada o una referencia a una sola fila o columna`,checkboxEqual:`Introduce valores diferentes para los contenidos de celda marcados y desmarcados.`,formulaError:`El rango de referencia contiene datos invisibles, ajusta el rango`,listIntersects:`El rango seleccionado no puede cruzarse con el ámbito de las reglas`,primitive:`No se permiten fórmulas para valores personalizados marcados y desmarcados.`},panel:{title:`Gestión de validación de datos`,addTitle:`Crear nueva validación de datos`,removeAll:`Eliminar todo`,add:`Añadir regla`,range:`Rangos`,type:`Tipo`,options:`Opciones avanzadas`,operator:`Operador`,removeRule:`Eliminar`,done:`Hecho`,formulaPlaceholder:`Por favor, introduce valor o fórmula`,valuePlaceholder:`Por favor, introduce valor`,formulaAnd:`y`,invalid:`Inválido`,showWarning:`Mostrar advertencia`,rejectInput:`Rechazar entrada`,messageInfo:`Mensaje de ayuda`,showInfo:`Mostrar texto de ayuda para la celda seleccionada`,rangeError:`Los rangos no son válidos`,allowBlank:`Permitir valores en blanco`},operators:{between:`entre`,greaterThan:`mayor que`,greaterThanOrEqual:`mayor o igual que`,lessThan:`menor que`,lessThanOrEqual:`menor o igual que`,equal:`igual`,notEqual:`no igual`,notBetween:`no entre`,legal:`es tipo legal`},ruleName:{between:`Está entre {FORMULA1} y {FORMULA2}`,greaterThan:`Es mayor que {FORMULA1}`,greaterThanOrEqual:`Es mayor o igual que {FORMULA1}`,lessThan:`Es menor que {FORMULA1}`,lessThanOrEqual:`Es menor o igual que {FORMULA1}`,equal:`Es igual a {FORMULA1}`,notEqual:`No es igual a {FORMULA1}`,notBetween:`No está entre {FORMULA1} y {FORMULA2}`,legal:`Es un {TYPE} legal`},errorMsg:{between:`El valor debe estar entre {FORMULA1} y {FORMULA2}`,greaterThan:`El valor debe ser mayor que {FORMULA1}`,greaterThanOrEqual:`El valor debe ser mayor o igual que {FORMULA1}`,lessThan:`El valor debe ser menor que {FORMULA1}`,lessThanOrEqual:`El valor debe ser menor o igual que {FORMULA1}`,equal:`El valor debe ser igual a {FORMULA1}`,notEqual:`El valor no debe ser igual a {FORMULA1}`,notBetween:`El valor no debe estar entre {FORMULA1} y {FORMULA2}`,legal:`El valor debe ser un {TYPE} legal`},any:{title:`Cualquier valor`,error:`El contenido de esta celda viola la regla de validación`},date:{title:`Fecha`,operators:{between:`entre`,greaterThan:`después de`,greaterThanOrEqual:`en o después de`,lessThan:`antes de`,lessThanOrEqual:`en o antes de`,equal:`igual`,notEqual:`no igual`,notBetween:`no entre`,legal:`es una fecha legal`},ruleName:{between:`está entre {FORMULA1} y {FORMULA2}`,greaterThan:`es después de {FORMULA1}`,greaterThanOrEqual:`es en o después de {FORMULA1}`,lessThan:`es antes de {FORMULA1}`,lessThanOrEqual:`es en o antes de {FORMULA1}`,equal:`es {FORMULA1}`,notEqual:`no es {FORMULA1}`,notBetween:`no está entre {FORMULA1}`,legal:`es una fecha legal`},errorMsg:{between:`El valor debe ser una fecha legal y estar entre {FORMULA1} y {FORMULA2}`,greaterThan:`El valor debe ser una fecha legal y después de {FORMULA1}`,greaterThanOrEqual:`El valor debe ser una fecha legal y en o después de {FORMULA1}`,lessThan:`El valor debe ser una fecha legal y antes de {FORMULA1}`,lessThanOrEqual:`El valor debe ser una fecha legal y en o antes de {FORMULA1}`,equal:`El valor debe ser una fecha legal y {FORMULA1}`,notEqual:`El valor debe ser una fecha legal y no {FORMULA1}`,notBetween:`El valor debe ser una fecha legal y no estar entre {FORMULA1}`,legal:`El valor debe ser una fecha legal`}},list:{title:`Desplegable`,name:`El valor contiene uno del rango`,error:`La entrada debe estar dentro del rango especificado`,emptyError:`Por favor, introduce un valor`,add:`Añadir`,dropdown:`Seleccionar`,options:`Opciones`,customOptions:`Personalizado`,refOptions:`De un rango`,formulaError:`La fuente de la lista debe ser una lista delimitada de datos o una referencia a una sola fila o columna.`,edit:`Editar`},listMultiple:{title:`Desplegable-múltiple`,dropdown:`Selección múltiple`},textLength:{title:`Longitud del texto`,errorMsg:{between:`La longitud del texto debe estar entre {FORMULA1} y {FORMULA2}`,greaterThan:`La longitud del texto debe ser mayor que {FORMULA1}`,greaterThanOrEqual:`La longitud del texto debe ser mayor o igual que {FORMULA1}`,lessThan:`La longitud del texto debe ser menor que {FORMULA1}`,lessThanOrEqual:`La longitud del texto debe ser menor o igual que {FORMULA1}`,equal:`La longitud del texto debe ser {FORMULA1}`,notEqual:`La longitud del texto no debe ser {FORMULA1}`,notBetween:`La longitud del texto no debe estar entre {FORMULA1}`}},decimal:{title:`Número`},whole:{title:`Entero`},checkbox:{title:`Casilla de verificación`,error:`El contenido de esta celda viola su regla de validación`,tips:`Usa valores personalizados dentro de las celdas`,checked:`Valor seleccionado`,unchecked:`Valor no seleccionado`},custom:{title:`Fórmula personalizada`,error:`El contenido de esta celda viola su regla de validación`,validFail:`Por favor, introduce una fórmula válida`,ruleName:`La fórmula personalizada es {FORMULA1}`},alert:{title:`Error`,ok:`OK`},error:{title:`Inválido:`},renderMode:{arrow:`Flecha`,chip:`Chip`,text:`Texto plano`,label:`Estilo de visualización`},showTime:{label:`Mostrar selector de hora`}}};module.exports=e;
|