@univerjs/sheets-data-validation 0.5.2 → 0.5.3-nightly.202501051605

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/facade.js CHANGED
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var p=(n,t,e)=>t in n?m(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var d=(n,t,e)=>p(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/sheets-data-validation"),s=require("@univerjs/sheets/facade"),a=require("@univerjs/core"),h=require("@univerjs/data-validation"),c=require("@univerjs/engine-formula"),_=require("rxjs");class l{constructor(t){d(this,"_rule");this._rule=t!=null?t:{uid:a.generateRandomId(),ranges:void 0,type:a.DataValidationType.CUSTOM}}build(){return new u(this._rule)}copy(){return new l({...this._rule,uid:a.generateRandomId()})}getAllowInvalid(){return this._rule.errorStyle!==a.DataValidationErrorStyle.STOP}getCriteriaType(){return this._rule.type}getCriteriaValues(){return[this._rule.operator,this._rule.formula1,this._rule.formula2]}getHelpText(){return this._rule.error}requireCheckbox(t,e){return this._rule.type=a.DataValidationType.CHECKBOX,this._rule.formula1=t,this._rule.formula2=e,this}requireDateAfter(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.operator=a.DataValidationOperator.GREATER_THAN,this}requireDateBefore(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN,this}requireDateBetween(t,e){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=a.DataValidationOperator.BETWEEN,this}requireDateEqualTo(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.EQUAL,this}requireDateNotBetween(t,e){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=a.DataValidationOperator.NOT_BETWEEN,this}requireDateOnOrAfter(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.GREATER_THAN_OR_EQUAL,this}requireDateOnOrBefore(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN_OR_EQUAL,this}requireFormulaSatisfied(t){return this._rule.type=a.DataValidationType.CUSTOM,this._rule.formula1=t,this._rule.formula2=void 0,this}requireNumberBetween(t,e,i){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=a.DataValidationOperator.BETWEEN,this._rule.type=i?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberGreaterThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.GREATER_THAN,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberGreaterThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.GREATER_THAN_OR_EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberLessThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberLessThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN_OR_EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberNotBetween(t,e,i){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=a.DataValidationOperator.NOT_BETWEEN,this._rule.type=i?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberNotEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.NOT_EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireValueInList(t,e,i){return this._rule.type=e?a.DataValidationType.LIST_MULTIPLE:a.DataValidationType.LIST,this._rule.formula1=t.join(","),this._rule.formula2=void 0,this._rule.showDropDown=i!=null?i:!0,this}requireValueInRange(t,e,i){return this._rule.type=e?a.DataValidationType.LIST_MULTIPLE:a.DataValidationType.LIST,this._rule.formula1=`=${c.serializeRangeToRefString({unitId:t.getUnitId(),sheetName:t.getSheetName(),range:t.getRange()})}`,this._rule.formula2=void 0,this._rule.showDropDown=i!=null?i:!0,this}setAllowInvalid(t){return this._rule.errorStyle=t?a.DataValidationErrorStyle.WARNING:a.DataValidationErrorStyle.STOP,this}setHelpText(t){return this._rule.error=t,this._rule.showErrorMessage=!0,this}withCriteriaValues(t,e){return this._rule.type=t,this._rule.operator=e[0],this._rule.formula1=e[1],this._rule.formula2=e[2],this}setOptions(t){return Object.assign(this._rule,t),this}}class u{constructor(t,e,i){d(this,"rule");d(this,"_worksheet");d(this,"_injector");this._injector=i,this.rule=t,this._worksheet=e}getAllowInvalid(){return this.rule.errorStyle!==a.DataValidationErrorStyle.STOP}getCriteriaType(){return this.rule.type}getCriteriaValues(){return[this.rule.operator,this.rule.formula1,this.rule.formula2]}getHelpText(){return this.rule.error}copy(){return new l(this.rule)}getApplied(){if(!this._worksheet)return!1;const e=this._injector.get(h.DataValidationModel).getRuleById(this._worksheet.getUnitId(),this._worksheet.getSheetId(),this.rule.uid);return!!(e&&e.ranges.length)}getRanges(){if(!this.getApplied())return[];const t=this._injector.get(a.IUniverInstanceService).getUnit(this._worksheet.getUnitId());return this.rule.ranges.map(e=>this._injector.createInstance(s.FRange,t,this._worksheet,e))}getUnitId(){var t;return(t=this._worksheet)==null?void 0:t.getUnitId()}getSheetId(){var t;return(t=this._worksheet)==null?void 0:t.getSheetId()}setCriteria(t,e){return this.getApplied()&&!this._injector.get(a.ICommandService).syncExecuteCommand(o.UpdateSheetDataValidationSettingCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,setting:{operator:e[0],formula1:e[1],formula2:e[2],type:this.rule.type}})?!1:(this.rule.operator=e[0],this.rule.formula1=e[1],this.rule.formula2=e[2],this.rule.type=t,!0)}setOptions(t){return this.getApplied()&&!this._injector.get(a.ICommandService).syncExecuteCommand(o.UpdateSheetDataValidationOptionsCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,options:{...h.getRuleOptions(this.rule),...t}})?!1:(Object.assign(this.rule,t),!0)}setRanges(t){return this.getApplied()&&!this._injector.get(a.ICommandService).syncExecuteCommand(o.UpdateSheetDataValidationRangeCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,ranges:t.map(r=>r.getRange())})?!1:(this.rule.ranges=t.map(e=>e.getRange()),!0)}delete(){return this.getApplied()?this._injector.get(a.ICommandService).syncExecuteCommand(o.RemoveSheetDataValidationCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid}):!1}}class D extends s.FRange{async setDataValidation(t){if(!t)return this._commandService.executeCommand(o.ClearRangeDataValidationCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]}),this;const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:{...t.rule,ranges:[this._range]}};return await this._commandService.executeCommand(o.AddSheetDataValidationCommand.id,e),this}getDataValidation(){const e=this._injector.get(o.SheetsDataValidationValidatorService).getDataValidation(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]);return e&&new u(e,this._worksheet,this._injector)}getDataValidations(){return this._injector.get(o.SheetsDataValidationValidatorService).getDataValidations(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]).map(e=>new u(e,this._worksheet,this._injector))}async getValidatorStatus(){return this._injector.get(o.SheetsDataValidationValidatorService).validatorRanges(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range])}}s.FRange.extend(D);class g{static newDataValidation(){return new l}newDataValidation(){return new l}}a.FUniver.extend(g);class V extends s.FWorkbook{_initialize(){Object.defineProperty(this,"_dataValidationModel",{get(){return this._injector.get(o.SheetDataValidationModel)}})}getValidatorStatus(){return this._injector.get(o.SheetsDataValidationValidatorService).validatorWorkbook(this._workbook.getUnitId())}onDataValidationChange(t){return a.toDisposable(this._dataValidationModel.ruleChange$.pipe(_.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onDataValidationStatusChange(t){return a.toDisposable(this._dataValidationModel.validStatusChange$.pipe(_.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onBeforeAddDataValidation(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.AddSheetDataValidationCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeAddDataValidation")}}))}onBeforeUpdateDataValidationCriteria(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.UpdateSheetDataValidationSettingCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria")}}))}onBeforeUpdateDataValidationRange(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.UpdateSheetDataValidationRangeCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange")}}))}onBeforeUpdateDataValidationOptions(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.UpdateSheetDataValidationOptionsCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions")}}))}onBeforeDeleteDataValidation(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.RemoveSheetDataValidationCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation")}}))}onBeforeDeleteAllDataValidation(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.RemoveSheetAllDataValidationCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation")}}))}}s.FWorkbook.extend(V);class f extends s.FWorksheet{getDataValidations(){return this._injector.get(h.DataValidationModel).getRules(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>new u(e,this._worksheet,this._injector))}getValidatorStatus(){return this._injector.get(o.SheetsDataValidationValidatorService).validatorWorksheet(this._workbook.getUnitId(),this._worksheet.getSheetId())}}s.FWorksheet.extend(f);exports.FDataValidation=u;exports.FDataValidationBuilder=l;
1
+ "use strict";var m=Object.defineProperty;var p=(n,t,e)=>t in n?m(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var d=(n,t,e)=>p(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/sheets-data-validation"),s=require("@univerjs/sheets/facade"),a=require("@univerjs/core"),h=require("@univerjs/data-validation"),c=require("@univerjs/engine-formula"),_=require("rxjs");class l{constructor(t){d(this,"_rule");this._rule=t!=null?t:{uid:a.generateRandomId(),ranges:void 0,type:a.DataValidationType.CUSTOM}}build(){return new u(this._rule)}copy(){return new l({...this._rule,uid:a.generateRandomId()})}getAllowInvalid(){return this._rule.errorStyle!==a.DataValidationErrorStyle.STOP}getCriteriaType(){return this._rule.type}getCriteriaValues(){return[this._rule.operator,this._rule.formula1,this._rule.formula2]}getHelpText(){return this._rule.error}requireCheckbox(t,e){return this._rule.type=a.DataValidationType.CHECKBOX,this._rule.formula1=t,this._rule.formula2=e,this}requireDateAfter(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.operator=a.DataValidationOperator.GREATER_THAN,this}requireDateBefore(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN,this}requireDateBetween(t,e){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=a.DataValidationOperator.BETWEEN,this}requireDateEqualTo(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.EQUAL,this}requireDateNotBetween(t,e){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=a.DataValidationOperator.NOT_BETWEEN,this}requireDateOnOrAfter(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.GREATER_THAN_OR_EQUAL,this}requireDateOnOrBefore(t){return this._rule.type=a.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN_OR_EQUAL,this}requireFormulaSatisfied(t){return this._rule.type=a.DataValidationType.CUSTOM,this._rule.formula1=t,this._rule.formula2=void 0,this}requireNumberBetween(t,e,i){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=a.DataValidationOperator.BETWEEN,this._rule.type=i?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberGreaterThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.GREATER_THAN,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberGreaterThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.GREATER_THAN_OR_EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberLessThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberLessThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.LESS_THAN_OR_EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberNotBetween(t,e,i){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=a.DataValidationOperator.NOT_BETWEEN,this._rule.type=i?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireNumberNotEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=a.DataValidationOperator.NOT_EQUAL,this._rule.type=e?a.DataValidationType.WHOLE:a.DataValidationType.DECIMAL,this}requireValueInList(t,e,i){return this._rule.type=e?a.DataValidationType.LIST_MULTIPLE:a.DataValidationType.LIST,this._rule.formula1=t.join(","),this._rule.formula2=void 0,this._rule.showDropDown=i!=null?i:!0,this}requireValueInRange(t,e,i){return this._rule.type=e?a.DataValidationType.LIST_MULTIPLE:a.DataValidationType.LIST,this._rule.formula1=`=${c.serializeRangeToRefString({unitId:t.getUnitId(),sheetName:t.getSheetName(),range:t.getRange()})}`,this._rule.formula2=void 0,this._rule.showDropDown=i!=null?i:!0,this}setAllowInvalid(t){return this._rule.errorStyle=t?a.DataValidationErrorStyle.WARNING:a.DataValidationErrorStyle.STOP,this}setHelpText(t){return this._rule.error=t,this._rule.showErrorMessage=!0,this}withCriteriaValues(t,e){return this._rule.type=t,this._rule.operator=e[0],this._rule.formula1=e[1],this._rule.formula2=e[2],this}setAllowBlank(t){return this._rule.allowBlank=t,this}setOptions(t){return Object.assign(this._rule,t),this}}class u{constructor(t,e,i){d(this,"rule");d(this,"_worksheet");d(this,"_injector");this._injector=i,this.rule=t,this._worksheet=e}getAllowInvalid(){return this.rule.errorStyle!==a.DataValidationErrorStyle.STOP}getCriteriaType(){return this.rule.type}getCriteriaValues(){return[this.rule.operator,this.rule.formula1,this.rule.formula2]}getHelpText(){return this.rule.error}copy(){return new l(this.rule)}getApplied(){if(!this._worksheet)return!1;const e=this._injector.get(h.DataValidationModel).getRuleById(this._worksheet.getUnitId(),this._worksheet.getSheetId(),this.rule.uid);return!!(e&&e.ranges.length)}getRanges(){if(!this.getApplied())return[];const t=this._injector.get(a.IUniverInstanceService).getUnit(this._worksheet.getUnitId());return this.rule.ranges.map(e=>this._injector.createInstance(s.FRange,t,this._worksheet,e))}getUnitId(){var t;return(t=this._worksheet)==null?void 0:t.getUnitId()}getSheetId(){var t;return(t=this._worksheet)==null?void 0:t.getSheetId()}setCriteria(t,e,i=!0){if(this.getApplied()&&!this._injector.get(a.ICommandService).syncExecuteCommand(o.UpdateSheetDataValidationSettingCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,setting:{operator:e[0],formula1:e[1],formula2:e[2],type:this.rule.type,allowBlank:i}}))throw new Error("setCriteria failed");return this.rule.operator=e[0],this.rule.formula1=e[1],this.rule.formula2=e[2],this.rule.type=t,this.rule.allowBlank=i,this}setOptions(t){if(this.getApplied()&&!this._injector.get(a.ICommandService).syncExecuteCommand(o.UpdateSheetDataValidationOptionsCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,options:{...h.getRuleOptions(this.rule),...t}}))throw new Error("setOptions failed");return Object.assign(this.rule,t),this}setRanges(t){if(this.getApplied()&&!this._injector.get(a.ICommandService).syncExecuteCommand(o.UpdateSheetDataValidationRangeCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,ranges:t.map(r=>r.getRange())}))throw new Error("setRanges failed");return this.rule.ranges=t.map(e=>e.getRange()),this}delete(){return this.getApplied()?this._injector.get(a.ICommandService).syncExecuteCommand(o.RemoveSheetDataValidationCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid}):!1}}class g extends s.FRange{setDataValidation(t){if(!t)return this._commandService.syncExecuteCommand(o.ClearRangeDataValidationCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]}),this;const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:{...t.rule,ranges:[this._range]}};return this._commandService.syncExecuteCommand(o.AddSheetDataValidationCommand.id,e),this}getDataValidation(){const e=this._injector.get(o.SheetsDataValidationValidatorService).getDataValidation(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]);return e&&new u(e,this._worksheet,this._injector)}getDataValidations(){return this._injector.get(o.SheetsDataValidationValidatorService).getDataValidations(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]).map(e=>new u(e,this._worksheet,this._injector))}async getValidatorStatus(){return this._injector.get(o.SheetsDataValidationValidatorService).validatorRanges(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range])}}s.FRange.extend(g);class D{static newDataValidation(){return new l}newDataValidation(){return new l}}a.FUniver.extend(D);class V extends s.FWorkbook{_initialize(){Object.defineProperty(this,"_dataValidationModel",{get(){return this._injector.get(o.SheetDataValidationModel)}})}getValidatorStatus(){return this._injector.get(o.SheetsDataValidationValidatorService).validatorWorkbook(this._workbook.getUnitId())}onDataValidationChange(t){return a.toDisposable(this._dataValidationModel.ruleChange$.pipe(_.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onDataValidationStatusChange(t){return a.toDisposable(this._dataValidationModel.validStatusChange$.pipe(_.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onBeforeAddDataValidation(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.AddSheetDataValidationCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeAddDataValidation")}}))}onBeforeUpdateDataValidationCriteria(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.UpdateSheetDataValidationSettingCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria")}}))}onBeforeUpdateDataValidationRange(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.UpdateSheetDataValidationRangeCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange")}}))}onBeforeUpdateDataValidationOptions(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.UpdateSheetDataValidationOptionsCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions")}}))}onBeforeDeleteDataValidation(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.RemoveSheetDataValidationCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation")}}))}onBeforeDeleteAllDataValidation(t){return a.toDisposable(this._commandService.beforeCommandExecuted((e,i)=>{const r=e.params;if(e.id===o.RemoveSheetAllDataValidationCommand.id){if(r.unitId!==this._workbook.getUnitId())return;if(t(r,i)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation")}}))}}s.FWorkbook.extend(V);class f extends s.FWorksheet{getDataValidations(){return this._injector.get(h.DataValidationModel).getRules(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>new u(e,this._worksheet,this._injector))}getValidatorStatus(){return this._injector.get(o.SheetsDataValidationValidatorService).validatorWorksheet(this._workbook.getUnitId(),this._worksheet.getSheetId())}}s.FWorksheet.extend(f);exports.FDataValidation=u;exports.FDataValidationBuilder=l;
package/lib/es/facade.js CHANGED
@@ -1,10 +1,10 @@
1
- var w = Object.defineProperty;
2
- var V = (s, e, t) => e in s ? w(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
1
+ var b = Object.defineProperty;
2
+ var V = (s, e, t) => e in s ? b(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
3
  var u = (s, e, t) => V(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { UpdateSheetDataValidationSettingCommand as f, UpdateSheetDataValidationOptionsCommand as S, UpdateSheetDataValidationRangeCommand as I, RemoveSheetDataValidationCommand as E, ClearRangeDataValidationCommand as U, AddSheetDataValidationCommand as D, SheetsDataValidationValidatorService as l, SheetDataValidationModel as T, RemoveSheetAllDataValidationCommand as A } from "@univerjs/sheets-data-validation";
5
- import { FRange as c, FWorkbook as k, FWorksheet as v } from "@univerjs/sheets/facade";
6
- import { generateRandomId as g, DataValidationType as r, DataValidationErrorStyle as _, DataValidationOperator as o, IUniverInstanceService as C, ICommandService as d, FUniver as y, toDisposable as n } from "@univerjs/core";
7
- import { DataValidationModel as b, getRuleOptions as L } from "@univerjs/data-validation";
4
+ import { UpdateSheetDataValidationSettingCommand as f, UpdateSheetDataValidationOptionsCommand as S, UpdateSheetDataValidationRangeCommand as E, RemoveSheetDataValidationCommand as I, ClearRangeDataValidationCommand as U, AddSheetDataValidationCommand as D, SheetsDataValidationValidatorService as l, SheetDataValidationModel as A, RemoveSheetAllDataValidationCommand as C } from "@univerjs/sheets-data-validation";
5
+ import { FRange as c, FWorkbook as k, FWorksheet as w } from "@univerjs/sheets/facade";
6
+ import { generateRandomId as g, DataValidationType as i, DataValidationErrorStyle as _, DataValidationOperator as o, IUniverInstanceService as T, ICommandService as d, FUniver as y, toDisposable as n } from "@univerjs/core";
7
+ import { DataValidationModel as v, getRuleOptions as L } from "@univerjs/data-validation";
8
8
  import { serializeRangeToRefString as O } from "@univerjs/engine-formula";
9
9
  import { filter as p } from "rxjs";
10
10
  class h {
@@ -13,7 +13,7 @@ class h {
13
13
  this._rule = e != null ? e : {
14
14
  uid: g(),
15
15
  ranges: void 0,
16
- type: r.CUSTOM
16
+ type: i.CUSTOM
17
17
  };
18
18
  }
19
19
  /**
@@ -75,7 +75,7 @@ class h {
75
75
  * @returns The current instance of the FDataValidationBuilder class to allow for method chaining
76
76
  */
77
77
  requireCheckbox(e, t) {
78
- return this._rule.type = r.CHECKBOX, this._rule.formula1 = e, this._rule.formula2 = t, this;
78
+ return this._rule.type = i.CHECKBOX, this._rule.formula1 = e, this._rule.formula2 = t, this;
79
79
  }
80
80
  /**
81
81
  * Set the data validation type to DATE and configure the validation rules to be after a specific date
@@ -84,7 +84,7 @@ class h {
84
84
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining
85
85
  */
86
86
  requireDateAfter(e) {
87
- return this._rule.type = r.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.operator = o.GREATER_THAN, this;
87
+ return this._rule.type = i.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.operator = o.GREATER_THAN, this;
88
88
  }
89
89
  /**
90
90
  * Set the data validation type to DATE and configure the validation rules to be before a specific date
@@ -93,7 +93,7 @@ class h {
93
93
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining
94
94
  */
95
95
  requireDateBefore(e) {
96
- return this._rule.type = r.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = o.LESS_THAN, this;
96
+ return this._rule.type = i.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = o.LESS_THAN, this;
97
97
  }
98
98
  /**
99
99
  * Set the data validation type to DATE and configure the validation rules to be within a specific date range
@@ -103,7 +103,7 @@ class h {
103
103
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining
104
104
  */
105
105
  requireDateBetween(e, t) {
106
- return this._rule.type = r.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = o.BETWEEN, this;
106
+ return this._rule.type = i.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = o.BETWEEN, this;
107
107
  }
108
108
  /**
109
109
  * Set the data validation type to DATE and configure the validation rules to be equal to a specific date
@@ -112,7 +112,7 @@ class h {
112
112
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining
113
113
  */
114
114
  requireDateEqualTo(e) {
115
- return this._rule.type = r.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = o.EQUAL, this;
115
+ return this._rule.type = i.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = o.EQUAL, this;
116
116
  }
117
117
  /**
118
118
  * Set the data validation type to DATE and configure the validation rules to be not within a specific date range
@@ -122,7 +122,7 @@ class h {
122
122
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining
123
123
  */
124
124
  requireDateNotBetween(e, t) {
125
- return this._rule.type = r.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = o.NOT_BETWEEN, this;
125
+ return this._rule.type = i.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = t.toLocaleDateString(), this._rule.operator = o.NOT_BETWEEN, this;
126
126
  }
127
127
  /**
128
128
  * Set the data validation type to DATE and configure the validation rules to be on or after a specific date
@@ -131,7 +131,7 @@ class h {
131
131
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining
132
132
  */
133
133
  requireDateOnOrAfter(e) {
134
- return this._rule.type = r.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = o.GREATER_THAN_OR_EQUAL, this;
134
+ return this._rule.type = i.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = o.GREATER_THAN_OR_EQUAL, this;
135
135
  }
136
136
  /**
137
137
  * Set the data validation type to DATE and configure the validation rules to be on or before a specific date
@@ -140,7 +140,7 @@ class h {
140
140
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining
141
141
  */
142
142
  requireDateOnOrBefore(e) {
143
- return this._rule.type = r.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = o.LESS_THAN_OR_EQUAL, this;
143
+ return this._rule.type = i.DATE, this._rule.formula1 = e.toLocaleDateString(), this._rule.formula2 = void 0, this._rule.operator = o.LESS_THAN_OR_EQUAL, this;
144
144
  }
145
145
  /**
146
146
  * Requires that a custom formula be satisfied.
@@ -150,7 +150,7 @@ class h {
150
150
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
151
151
  */
152
152
  requireFormulaSatisfied(e) {
153
- return this._rule.type = r.CUSTOM, this._rule.formula1 = e, this._rule.formula2 = void 0, this;
153
+ return this._rule.type = i.CUSTOM, this._rule.formula1 = e, this._rule.formula2 = void 0, this;
154
154
  }
155
155
  /**
156
156
  * Requires the user to enter a number within a specific range, which can be integer or decimal.
@@ -161,8 +161,8 @@ class h {
161
161
  * @param isInteger Indicates whether the required number is an integer. Default is undefined, meaning it can be an integer or decimal.
162
162
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
163
163
  */
164
- requireNumberBetween(e, t, i) {
165
- return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = o.BETWEEN, this._rule.type = i ? r.WHOLE : r.DECIMAL, this;
164
+ requireNumberBetween(e, t, r) {
165
+ return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = o.BETWEEN, this._rule.type = r ? i.WHOLE : i.DECIMAL, this;
166
166
  }
167
167
  /**
168
168
  * Requires the user to enter a number that is equal to a specific value, which can be an integer or a decimal.
@@ -173,7 +173,7 @@ class h {
173
173
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
174
174
  */
175
175
  requireNumberEqualTo(e, t) {
176
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.EQUAL, this._rule.type = t ? r.WHOLE : r.DECIMAL, this;
176
+ return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.EQUAL, this._rule.type = t ? i.WHOLE : i.DECIMAL, this;
177
177
  }
178
178
  /**
179
179
  * Requires the user to enter a number that is greater than a specific value, which can be an integer or a decimal.
@@ -184,7 +184,7 @@ class h {
184
184
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
185
185
  */
186
186
  requireNumberGreaterThan(e, t) {
187
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.GREATER_THAN, this._rule.type = t ? r.WHOLE : r.DECIMAL, this;
187
+ return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.GREATER_THAN, this._rule.type = t ? i.WHOLE : i.DECIMAL, this;
188
188
  }
189
189
  /**
190
190
  * Requires the user to enter a number that is greater than or equal to a specific value, which can be an integer or a decimal.
@@ -195,7 +195,7 @@ class h {
195
195
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
196
196
  */
197
197
  requireNumberGreaterThanOrEqualTo(e, t) {
198
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.GREATER_THAN_OR_EQUAL, this._rule.type = t ? r.WHOLE : r.DECIMAL, this;
198
+ return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.GREATER_THAN_OR_EQUAL, this._rule.type = t ? i.WHOLE : i.DECIMAL, this;
199
199
  }
200
200
  /**
201
201
  * Requires the user to enter a number that is less than a specific value, which can be an integer or a decimal.
@@ -206,7 +206,7 @@ class h {
206
206
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
207
207
  */
208
208
  requireNumberLessThan(e, t) {
209
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.LESS_THAN, this._rule.type = t ? r.WHOLE : r.DECIMAL, this;
209
+ return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.LESS_THAN, this._rule.type = t ? i.WHOLE : i.DECIMAL, this;
210
210
  }
211
211
  /**
212
212
  * Sets the data validation rule to require a number less than or equal to a specified value
@@ -217,7 +217,7 @@ class h {
217
217
  * @return The current instance of the DataValidationBuilder class, allowing for method chaining
218
218
  */
219
219
  requireNumberLessThanOrEqualTo(e, t) {
220
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.LESS_THAN_OR_EQUAL, this._rule.type = t ? r.WHOLE : r.DECIMAL, this;
220
+ return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.LESS_THAN_OR_EQUAL, this._rule.type = t ? i.WHOLE : i.DECIMAL, this;
221
221
  }
222
222
  /**
223
223
  * Sets a data validation rule that requires the user to enter a number outside a specified range
@@ -228,8 +228,8 @@ class h {
228
228
  * @param isInteger Optional parameter, indicating whether the number to be verified is an integer. Default value is false
229
229
  * @return An instance of the FDataValidationBuilder class, allowing for method chaining
230
230
  */
231
- requireNumberNotBetween(e, t, i) {
232
- return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = o.NOT_BETWEEN, this._rule.type = i ? r.WHOLE : r.DECIMAL, this;
231
+ requireNumberNotBetween(e, t, r) {
232
+ return this._rule.formula1 = `${e}`, this._rule.formula2 = `${t}`, this._rule.operator = o.NOT_BETWEEN, this._rule.type = r ? i.WHOLE : i.DECIMAL, this;
233
233
  }
234
234
  /**
235
235
  * Creates a data validation rule that requires the user to enter a number that is not equal to a specific value
@@ -240,7 +240,7 @@ class h {
240
240
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining
241
241
  */
242
242
  requireNumberNotEqualTo(e, t) {
243
- return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.NOT_EQUAL, this._rule.type = t ? r.WHOLE : r.DECIMAL, this;
243
+ return this._rule.formula1 = `${e}`, this._rule.formula2 = void 0, this._rule.operator = o.NOT_EQUAL, this._rule.type = t ? i.WHOLE : i.DECIMAL, this;
244
244
  }
245
245
  /**
246
246
  * Sets a data validation rule that requires the user to enter a value from a list of specific values.
@@ -251,8 +251,8 @@ class h {
251
251
  * @param showDropdown Optional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.
252
252
  * @return An instance of the FDataValidationBuilder class, allowing for method chaining.
253
253
  */
254
- requireValueInList(e, t, i) {
255
- return this._rule.type = t ? r.LIST_MULTIPLE : r.LIST, this._rule.formula1 = e.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !0, this;
254
+ requireValueInList(e, t, r) {
255
+ return this._rule.type = t ? i.LIST_MULTIPLE : i.LIST, this._rule.formula1 = e.join(","), this._rule.formula2 = void 0, this._rule.showDropDown = r != null ? r : !0, this;
256
256
  }
257
257
  /**
258
258
  * Sets a data validation rule that requires the user to enter a value within a specific range.
@@ -263,12 +263,12 @@ class h {
263
263
  * @param showDropdown Optional parameter indicating whether to display the list in a dropdown. Default is true, meaning the list will be displayed as a dropdown.
264
264
  * @return The current instance of the FDataValidationBuilder class to allow for method chaining.
265
265
  */
266
- requireValueInRange(e, t, i) {
267
- return this._rule.type = t ? r.LIST_MULTIPLE : r.LIST, this._rule.formula1 = `=${O({
266
+ requireValueInRange(e, t, r) {
267
+ return this._rule.type = t ? i.LIST_MULTIPLE : i.LIST, this._rule.formula1 = `=${O({
268
268
  unitId: e.getUnitId(),
269
269
  sheetName: e.getSheetName(),
270
270
  range: e.getRange()
271
- })}`, this._rule.formula2 = void 0, this._rule.showDropDown = i != null ? i : !0, this;
271
+ })}`, this._rule.formula2 = void 0, this._rule.showDropDown = r != null ? r : !0, this;
272
272
  }
273
273
  /**
274
274
  * Sets whether to allow invalid data and configures the error style for data validation.
@@ -304,6 +304,9 @@ class h {
304
304
  withCriteriaValues(e, t) {
305
305
  return this._rule.type = e, this._rule.operator = t[0], this._rule.formula1 = t[1], this._rule.formula2 = t[2], this;
306
306
  }
307
+ setAllowBlank(e) {
308
+ return this._rule.allowBlank = e, this;
309
+ }
307
310
  /**
308
311
  * Sets the options for the data validation rule.
309
312
  * For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions
@@ -316,11 +319,11 @@ class h {
316
319
  }
317
320
  }
318
321
  class m {
319
- constructor(e, t, i) {
322
+ constructor(e, t, r) {
320
323
  u(this, "rule");
321
324
  u(this, "_worksheet");
322
325
  u(this, "_injector");
323
- this._injector = i, this.rule = e, this._worksheet = t;
326
+ this._injector = r, this.rule = e, this._worksheet = t;
324
327
  }
325
328
  /**
326
329
  * Gets whether invalid data is allowed based on the error style value.
@@ -371,7 +374,7 @@ class m {
371
374
  getApplied() {
372
375
  if (!this._worksheet)
373
376
  return !1;
374
- const t = this._injector.get(b).getRuleById(this._worksheet.getUnitId(), this._worksheet.getSheetId(), this.rule.uid);
377
+ const t = this._injector.get(v).getRuleById(this._worksheet.getUnitId(), this._worksheet.getSheetId(), this.rule.uid);
375
378
  return !!(t && t.ranges.length);
376
379
  }
377
380
  /**
@@ -382,7 +385,7 @@ class m {
382
385
  getRanges() {
383
386
  if (!this.getApplied())
384
387
  return [];
385
- const e = this._injector.get(C).getUnit(this._worksheet.getUnitId());
388
+ const e = this._injector.get(T).getUnit(this._worksheet.getUnitId());
386
389
  return this.rule.ranges.map((t) => this._injector.createInstance(c, e, this._worksheet, t));
387
390
  }
388
391
  /**
@@ -409,8 +412,8 @@ class m {
409
412
  * @param values An array containing the operator, formula1, and formula2 values.
410
413
  * @returns true if the criteria is set successfully, false otherwise.
411
414
  */
412
- setCriteria(e, t) {
413
- return this.getApplied() && !this._injector.get(d).syncExecuteCommand(f.id, {
415
+ setCriteria(e, t, r = !0) {
416
+ if (this.getApplied() && !this._injector.get(d).syncExecuteCommand(f.id, {
414
417
  unitId: this.getUnitId(),
415
418
  subUnitId: this.getSheetId(),
416
419
  ruleId: this.rule.uid,
@@ -418,9 +421,12 @@ class m {
418
421
  operator: t[0],
419
422
  formula1: t[1],
420
423
  formula2: t[2],
421
- type: this.rule.type
424
+ type: this.rule.type,
425
+ allowBlank: r
422
426
  }
423
- }) ? !1 : (this.rule.operator = t[0], this.rule.formula1 = t[1], this.rule.formula2 = t[2], this.rule.type = e, !0);
427
+ }))
428
+ throw new Error("setCriteria failed");
429
+ return this.rule.operator = t[0], this.rule.formula1 = t[1], this.rule.formula2 = t[2], this.rule.type = e, this.rule.allowBlank = r, this;
424
430
  }
425
431
  /**
426
432
  * Set the options for the data validation rule.
@@ -429,7 +435,7 @@ class m {
429
435
  * @returns true if the options are set successfully, false otherwise.
430
436
  */
431
437
  setOptions(e) {
432
- return this.getApplied() && !this._injector.get(d).syncExecuteCommand(S.id, {
438
+ if (this.getApplied() && !this._injector.get(d).syncExecuteCommand(S.id, {
433
439
  unitId: this.getUnitId(),
434
440
  subUnitId: this.getSheetId(),
435
441
  ruleId: this.rule.uid,
@@ -437,7 +443,9 @@ class m {
437
443
  ...L(this.rule),
438
444
  ...e
439
445
  }
440
- }) ? !1 : (Object.assign(this.rule, e), !0);
446
+ }))
447
+ throw new Error("setOptions failed");
448
+ return Object.assign(this.rule, e), this;
441
449
  }
442
450
  /**
443
451
  * Set the ranges to the data validation rule.
@@ -445,19 +453,21 @@ class m {
445
453
  * @returns true if the ranges are set successfully, false otherwise.
446
454
  */
447
455
  setRanges(e) {
448
- return this.getApplied() && !this._injector.get(d).syncExecuteCommand(I.id, {
456
+ if (this.getApplied() && !this._injector.get(d).syncExecuteCommand(E.id, {
449
457
  unitId: this.getUnitId(),
450
458
  subUnitId: this.getSheetId(),
451
459
  ruleId: this.rule.uid,
452
460
  ranges: e.map((a) => a.getRange())
453
- }) ? !1 : (this.rule.ranges = e.map((t) => t.getRange()), !0);
461
+ }))
462
+ throw new Error("setRanges failed");
463
+ return this.rule.ranges = e.map((t) => t.getRange()), this;
454
464
  }
455
465
  /**
456
466
  * Delete the data validation rule from the worksheet.
457
467
  * @returns true if the rule is deleted successfully, false otherwise.
458
468
  */
459
469
  delete() {
460
- return this.getApplied() ? this._injector.get(d).syncExecuteCommand(E.id, {
470
+ return this.getApplied() ? this._injector.get(d).syncExecuteCommand(I.id, {
461
471
  unitId: this.getUnitId(),
462
472
  subUnitId: this.getSheetId(),
463
473
  ruleId: this.rule.uid
@@ -465,9 +475,9 @@ class m {
465
475
  }
466
476
  }
467
477
  class R extends c {
468
- async setDataValidation(e) {
478
+ setDataValidation(e) {
469
479
  if (!e)
470
- return this._commandService.executeCommand(U.id, {
480
+ return this._commandService.syncExecuteCommand(U.id, {
471
481
  unitId: this._workbook.getUnitId(),
472
482
  subUnitId: this._worksheet.getSheetId(),
473
483
  ranges: [this._range]
@@ -480,7 +490,7 @@ class R extends c {
480
490
  ranges: [this._range]
481
491
  }
482
492
  };
483
- return await this._commandService.executeCommand(D.id, t), this;
493
+ return this._commandService.syncExecuteCommand(D.id, t), this;
484
494
  }
485
495
  getDataValidation() {
486
496
  const t = this._injector.get(l).getDataValidation(
@@ -522,7 +532,7 @@ class x extends k {
522
532
  _initialize() {
523
533
  Object.defineProperty(this, "_dataValidationModel", {
524
534
  get() {
525
- return this._injector.get(T);
535
+ return this._injector.get(A);
526
536
  }
527
537
  });
528
538
  }
@@ -556,76 +566,76 @@ class x extends k {
556
566
  * @returns A disposable object that can be used to unsubscribe from the event
557
567
  */
558
568
  onBeforeAddDataValidation(e) {
559
- return n(this._commandService.beforeCommandExecuted((t, i) => {
569
+ return n(this._commandService.beforeCommandExecuted((t, r) => {
560
570
  const a = t.params;
561
571
  if (t.id === D.id) {
562
572
  if (a.unitId !== this._workbook.getUnitId())
563
573
  return;
564
- if (e(a, i) === !1)
574
+ if (e(a, r) === !1)
565
575
  throw new Error("Command is stopped by the hook onBeforeAddDataValidation");
566
576
  }
567
577
  }));
568
578
  }
569
579
  onBeforeUpdateDataValidationCriteria(e) {
570
- return n(this._commandService.beforeCommandExecuted((t, i) => {
580
+ return n(this._commandService.beforeCommandExecuted((t, r) => {
571
581
  const a = t.params;
572
582
  if (t.id === f.id) {
573
583
  if (a.unitId !== this._workbook.getUnitId())
574
584
  return;
575
- if (e(a, i) === !1)
585
+ if (e(a, r) === !1)
576
586
  throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria");
577
587
  }
578
588
  }));
579
589
  }
580
590
  onBeforeUpdateDataValidationRange(e) {
581
- return n(this._commandService.beforeCommandExecuted((t, i) => {
591
+ return n(this._commandService.beforeCommandExecuted((t, r) => {
582
592
  const a = t.params;
583
- if (t.id === I.id) {
593
+ if (t.id === E.id) {
584
594
  if (a.unitId !== this._workbook.getUnitId())
585
595
  return;
586
- if (e(a, i) === !1)
596
+ if (e(a, r) === !1)
587
597
  throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange");
588
598
  }
589
599
  }));
590
600
  }
591
601
  onBeforeUpdateDataValidationOptions(e) {
592
- return n(this._commandService.beforeCommandExecuted((t, i) => {
602
+ return n(this._commandService.beforeCommandExecuted((t, r) => {
593
603
  const a = t.params;
594
604
  if (t.id === S.id) {
595
605
  if (a.unitId !== this._workbook.getUnitId())
596
606
  return;
597
- if (e(a, i) === !1)
607
+ if (e(a, r) === !1)
598
608
  throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions");
599
609
  }
600
610
  }));
601
611
  }
602
612
  onBeforeDeleteDataValidation(e) {
603
- return n(this._commandService.beforeCommandExecuted((t, i) => {
613
+ return n(this._commandService.beforeCommandExecuted((t, r) => {
604
614
  const a = t.params;
605
- if (t.id === E.id) {
615
+ if (t.id === I.id) {
606
616
  if (a.unitId !== this._workbook.getUnitId())
607
617
  return;
608
- if (e(a, i) === !1)
618
+ if (e(a, r) === !1)
609
619
  throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation");
610
620
  }
611
621
  }));
612
622
  }
613
623
  onBeforeDeleteAllDataValidation(e) {
614
- return n(this._commandService.beforeCommandExecuted((t, i) => {
624
+ return n(this._commandService.beforeCommandExecuted((t, r) => {
615
625
  const a = t.params;
616
- if (t.id === A.id) {
626
+ if (t.id === C.id) {
617
627
  if (a.unitId !== this._workbook.getUnitId())
618
628
  return;
619
- if (e(a, i) === !1)
629
+ if (e(a, r) === !1)
620
630
  throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation");
621
631
  }
622
632
  }));
623
633
  }
624
634
  }
625
635
  k.extend(x);
626
- class M extends v {
636
+ class B extends w {
627
637
  getDataValidations() {
628
- return this._injector.get(b).getRules(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((t) => new m(t, this._worksheet, this._injector));
638
+ return this._injector.get(v).getRules(this._workbook.getUnitId(), this._worksheet.getSheetId()).map((t) => new m(t, this._worksheet, this._injector));
629
639
  }
630
640
  getValidatorStatus() {
631
641
  return this._injector.get(l).validatorWorksheet(
@@ -634,7 +644,7 @@ class M extends v {
634
644
  );
635
645
  }
636
646
  }
637
- v.extend(M);
647
+ w.extend(B);
638
648
  export {
639
649
  m as FDataValidation,
640
650
  h as FDataValidationBuilder
@@ -236,6 +236,7 @@ export declare class FDataValidationBuilder {
236
236
  * @return The current instance of the FDataValidationBuilder class, allowing for method chaining.
237
237
  */
238
238
  withCriteriaValues(type: DataValidationType | string, values: [DataValidationOperator, string, string]): this;
239
+ setAllowBlank(allowBlank: boolean): FDataValidationBuilder;
239
240
  /**
240
241
  * Sets the options for the data validation rule.
241
242
  * For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions
@@ -67,20 +67,20 @@ export declare class FDataValidation {
67
67
  * @param values An array containing the operator, formula1, and formula2 values.
68
68
  * @returns true if the criteria is set successfully, false otherwise.
69
69
  */
70
- setCriteria(type: DataValidationType, values: [DataValidationOperator, string, string]): boolean;
70
+ setCriteria(type: DataValidationType, values: [DataValidationOperator, string, string], allowBlank?: boolean): FDataValidation;
71
71
  /**
72
72
  * Set the options for the data validation rule.
73
73
  * For details of options, please refer to https://univer.ai/typedoc/@univerjs/core/interfaces/IDataValidationRuleOptions
74
74
  * @param options An object containing the options to set. `IDataValidationRuleOptions`
75
75
  * @returns true if the options are set successfully, false otherwise.
76
76
  */
77
- setOptions(options: Partial<IDataValidationRuleOptions>): boolean;
77
+ setOptions(options: Partial<IDataValidationRuleOptions>): FDataValidation;
78
78
  /**
79
79
  * Set the ranges to the data validation rule.
80
80
  * @param ranges new ranges array.
81
81
  * @returns true if the ranges are set successfully, false otherwise.
82
82
  */
83
- setRanges(ranges: FRange[]): boolean;
83
+ setRanges(ranges: FRange[]): FDataValidation;
84
84
  /**
85
85
  * Delete the data validation rule from the worksheet.
86
86
  * @returns true if the rule is deleted successfully, false otherwise.
@@ -7,7 +7,7 @@ export interface IFRangeDataValidationMixin {
7
7
  * @param rule data validation rule, build by `FUniver.newDataValidation`
8
8
  * @returns current range
9
9
  */
10
- setDataValidation(this: FRange, rule: Nullable<FDataValidation>): Promise<FRange>;
10
+ setDataValidation(this: FRange, rule: Nullable<FDataValidation>): FRange;
11
11
  /**
12
12
  * get first data validation rule in current range
13
13
  * @returns data validation rule
@@ -21,7 +21,7 @@ export interface IFRangeDataValidationMixin {
21
21
  getValidatorStatus(): Promise<Promise<DataValidationStatus>[][]>;
22
22
  }
23
23
  export declare class FRangeDataValidationMixin extends FRange implements IFRangeDataValidationMixin {
24
- setDataValidation(rule: Nullable<FDataValidation>): Promise<FRange>;
24
+ setDataValidation(rule: Nullable<FDataValidation>): FRange;
25
25
  getDataValidation(): Nullable<FDataValidation>;
26
26
  getDataValidations(): FDataValidation[];
27
27
  getValidatorStatus(): Promise<Promise<DataValidationStatus>[][]>;
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(n,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/sheets-data-validation"),require("@univerjs/sheets/facade"),require("@univerjs/core"),require("@univerjs/data-validation"),require("@univerjs/engine-formula"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets-data-validation","@univerjs/sheets/facade","@univerjs/core","@univerjs/data-validation","@univerjs/engine-formula","rxjs"],a):(n=typeof globalThis<"u"?globalThis:n||self,a(n.UniverSheetsDataValidationFacade={},n.UniverSheetsDataValidation,n.UniverSheetsFacade,n.UniverCore,n.UniverDataValidation,n.UniverEngineFormula,n.rxjs))})(this,function(n,a,s,i,_,p,m){"use strict";var V=Object.defineProperty;var I=(n,a,s)=>a in n?V(n,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[a]=s;var d=(n,a,s)=>I(n,typeof a!="symbol"?a+"":a,s);class l{constructor(t){d(this,"_rule");this._rule=t!=null?t:{uid:i.generateRandomId(),ranges:void 0,type:i.DataValidationType.CUSTOM}}build(){return new u(this._rule)}copy(){return new l({...this._rule,uid:i.generateRandomId()})}getAllowInvalid(){return this._rule.errorStyle!==i.DataValidationErrorStyle.STOP}getCriteriaType(){return this._rule.type}getCriteriaValues(){return[this._rule.operator,this._rule.formula1,this._rule.formula2]}getHelpText(){return this._rule.error}requireCheckbox(t,e){return this._rule.type=i.DataValidationType.CHECKBOX,this._rule.formula1=t,this._rule.formula2=e,this}requireDateAfter(t){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.operator=i.DataValidationOperator.GREATER_THAN,this}requireDateBefore(t){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.LESS_THAN,this}requireDateBetween(t,e){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=i.DataValidationOperator.BETWEEN,this}requireDateEqualTo(t){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.EQUAL,this}requireDateNotBetween(t,e){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=i.DataValidationOperator.NOT_BETWEEN,this}requireDateOnOrAfter(t){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.GREATER_THAN_OR_EQUAL,this}requireDateOnOrBefore(t){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.LESS_THAN_OR_EQUAL,this}requireFormulaSatisfied(t){return this._rule.type=i.DataValidationType.CUSTOM,this._rule.formula1=t,this._rule.formula2=void 0,this}requireNumberBetween(t,e,r){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=i.DataValidationOperator.BETWEEN,this._rule.type=r?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.EQUAL,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberGreaterThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.GREATER_THAN,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberGreaterThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.GREATER_THAN_OR_EQUAL,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberLessThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.LESS_THAN,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberLessThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.LESS_THAN_OR_EQUAL,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberNotBetween(t,e,r){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=i.DataValidationOperator.NOT_BETWEEN,this._rule.type=r?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberNotEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.NOT_EQUAL,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireValueInList(t,e,r){return this._rule.type=e?i.DataValidationType.LIST_MULTIPLE:i.DataValidationType.LIST,this._rule.formula1=t.join(","),this._rule.formula2=void 0,this._rule.showDropDown=r!=null?r:!0,this}requireValueInRange(t,e,r){return this._rule.type=e?i.DataValidationType.LIST_MULTIPLE:i.DataValidationType.LIST,this._rule.formula1=`=${p.serializeRangeToRefString({unitId:t.getUnitId(),sheetName:t.getSheetName(),range:t.getRange()})}`,this._rule.formula2=void 0,this._rule.showDropDown=r!=null?r:!0,this}setAllowInvalid(t){return this._rule.errorStyle=t?i.DataValidationErrorStyle.WARNING:i.DataValidationErrorStyle.STOP,this}setHelpText(t){return this._rule.error=t,this._rule.showErrorMessage=!0,this}withCriteriaValues(t,e){return this._rule.type=t,this._rule.operator=e[0],this._rule.formula1=e[1],this._rule.formula2=e[2],this}setOptions(t){return Object.assign(this._rule,t),this}}class u{constructor(t,e,r){d(this,"rule");d(this,"_worksheet");d(this,"_injector");this._injector=r,this.rule=t,this._worksheet=e}getAllowInvalid(){return this.rule.errorStyle!==i.DataValidationErrorStyle.STOP}getCriteriaType(){return this.rule.type}getCriteriaValues(){return[this.rule.operator,this.rule.formula1,this.rule.formula2]}getHelpText(){return this.rule.error}copy(){return new l(this.rule)}getApplied(){if(!this._worksheet)return!1;const e=this._injector.get(_.DataValidationModel).getRuleById(this._worksheet.getUnitId(),this._worksheet.getSheetId(),this.rule.uid);return!!(e&&e.ranges.length)}getRanges(){if(!this.getApplied())return[];const t=this._injector.get(i.IUniverInstanceService).getUnit(this._worksheet.getUnitId());return this.rule.ranges.map(e=>this._injector.createInstance(s.FRange,t,this._worksheet,e))}getUnitId(){var t;return(t=this._worksheet)==null?void 0:t.getUnitId()}getSheetId(){var t;return(t=this._worksheet)==null?void 0:t.getSheetId()}setCriteria(t,e){return this.getApplied()&&!this._injector.get(i.ICommandService).syncExecuteCommand(a.UpdateSheetDataValidationSettingCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,setting:{operator:e[0],formula1:e[1],formula2:e[2],type:this.rule.type}})?!1:(this.rule.operator=e[0],this.rule.formula1=e[1],this.rule.formula2=e[2],this.rule.type=t,!0)}setOptions(t){return this.getApplied()&&!this._injector.get(i.ICommandService).syncExecuteCommand(a.UpdateSheetDataValidationOptionsCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,options:{..._.getRuleOptions(this.rule),...t}})?!1:(Object.assign(this.rule,t),!0)}setRanges(t){return this.getApplied()&&!this._injector.get(i.ICommandService).syncExecuteCommand(a.UpdateSheetDataValidationRangeCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,ranges:t.map(o=>o.getRange())})?!1:(this.rule.ranges=t.map(e=>e.getRange()),!0)}delete(){return this.getApplied()?this._injector.get(i.ICommandService).syncExecuteCommand(a.RemoveSheetDataValidationCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid}):!1}}class g extends s.FRange{async setDataValidation(t){if(!t)return this._commandService.executeCommand(a.ClearRangeDataValidationCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]}),this;const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:{...t.rule,ranges:[this._range]}};return await this._commandService.executeCommand(a.AddSheetDataValidationCommand.id,e),this}getDataValidation(){const e=this._injector.get(a.SheetsDataValidationValidatorService).getDataValidation(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]);return e&&new u(e,this._worksheet,this._injector)}getDataValidations(){return this._injector.get(a.SheetsDataValidationValidatorService).getDataValidations(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]).map(e=>new u(e,this._worksheet,this._injector))}async getValidatorStatus(){return this._injector.get(a.SheetsDataValidationValidatorService).validatorRanges(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range])}}s.FRange.extend(g);class D{static newDataValidation(){return new l}newDataValidation(){return new l}}i.FUniver.extend(D);class f extends s.FWorkbook{_initialize(){Object.defineProperty(this,"_dataValidationModel",{get(){return this._injector.get(a.SheetDataValidationModel)}})}getValidatorStatus(){return this._injector.get(a.SheetsDataValidationValidatorService).validatorWorkbook(this._workbook.getUnitId())}onDataValidationChange(t){return i.toDisposable(this._dataValidationModel.ruleChange$.pipe(m.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onDataValidationStatusChange(t){return i.toDisposable(this._dataValidationModel.validStatusChange$.pipe(m.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onBeforeAddDataValidation(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.AddSheetDataValidationCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeAddDataValidation")}}))}onBeforeUpdateDataValidationCriteria(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.UpdateSheetDataValidationSettingCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria")}}))}onBeforeUpdateDataValidationRange(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.UpdateSheetDataValidationRangeCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange")}}))}onBeforeUpdateDataValidationOptions(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.UpdateSheetDataValidationOptionsCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions")}}))}onBeforeDeleteDataValidation(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.RemoveSheetDataValidationCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation")}}))}onBeforeDeleteAllDataValidation(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.RemoveSheetAllDataValidationCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation")}}))}}s.FWorkbook.extend(f);class S extends s.FWorksheet{getDataValidations(){return this._injector.get(_.DataValidationModel).getRules(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>new u(e,this._worksheet,this._injector))}getValidatorStatus(){return this._injector.get(a.SheetsDataValidationValidatorService).validatorWorksheet(this._workbook.getUnitId(),this._worksheet.getSheetId())}}s.FWorksheet.extend(S),n.FDataValidation=u,n.FDataValidationBuilder=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
1
+ (function(n,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/sheets-data-validation"),require("@univerjs/sheets/facade"),require("@univerjs/core"),require("@univerjs/data-validation"),require("@univerjs/engine-formula"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets-data-validation","@univerjs/sheets/facade","@univerjs/core","@univerjs/data-validation","@univerjs/engine-formula","rxjs"],a):(n=typeof globalThis<"u"?globalThis:n||self,a(n.UniverSheetsDataValidationFacade={},n.UniverSheetsDataValidation,n.UniverSheetsFacade,n.UniverCore,n.UniverDataValidation,n.UniverEngineFormula,n.rxjs))})(this,function(n,a,s,i,_,p,m){"use strict";var V=Object.defineProperty;var E=(n,a,s)=>a in n?V(n,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[a]=s;var d=(n,a,s)=>E(n,typeof a!="symbol"?a+"":a,s);class l{constructor(t){d(this,"_rule");this._rule=t!=null?t:{uid:i.generateRandomId(),ranges:void 0,type:i.DataValidationType.CUSTOM}}build(){return new u(this._rule)}copy(){return new l({...this._rule,uid:i.generateRandomId()})}getAllowInvalid(){return this._rule.errorStyle!==i.DataValidationErrorStyle.STOP}getCriteriaType(){return this._rule.type}getCriteriaValues(){return[this._rule.operator,this._rule.formula1,this._rule.formula2]}getHelpText(){return this._rule.error}requireCheckbox(t,e){return this._rule.type=i.DataValidationType.CHECKBOX,this._rule.formula1=t,this._rule.formula2=e,this}requireDateAfter(t){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.operator=i.DataValidationOperator.GREATER_THAN,this}requireDateBefore(t){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.LESS_THAN,this}requireDateBetween(t,e){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=i.DataValidationOperator.BETWEEN,this}requireDateEqualTo(t){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.EQUAL,this}requireDateNotBetween(t,e){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=i.DataValidationOperator.NOT_BETWEEN,this}requireDateOnOrAfter(t){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.GREATER_THAN_OR_EQUAL,this}requireDateOnOrBefore(t){return this._rule.type=i.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.LESS_THAN_OR_EQUAL,this}requireFormulaSatisfied(t){return this._rule.type=i.DataValidationType.CUSTOM,this._rule.formula1=t,this._rule.formula2=void 0,this}requireNumberBetween(t,e,r){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=i.DataValidationOperator.BETWEEN,this._rule.type=r?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.EQUAL,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberGreaterThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.GREATER_THAN,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberGreaterThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.GREATER_THAN_OR_EQUAL,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberLessThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.LESS_THAN,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberLessThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.LESS_THAN_OR_EQUAL,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberNotBetween(t,e,r){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=i.DataValidationOperator.NOT_BETWEEN,this._rule.type=r?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireNumberNotEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=i.DataValidationOperator.NOT_EQUAL,this._rule.type=e?i.DataValidationType.WHOLE:i.DataValidationType.DECIMAL,this}requireValueInList(t,e,r){return this._rule.type=e?i.DataValidationType.LIST_MULTIPLE:i.DataValidationType.LIST,this._rule.formula1=t.join(","),this._rule.formula2=void 0,this._rule.showDropDown=r!=null?r:!0,this}requireValueInRange(t,e,r){return this._rule.type=e?i.DataValidationType.LIST_MULTIPLE:i.DataValidationType.LIST,this._rule.formula1=`=${p.serializeRangeToRefString({unitId:t.getUnitId(),sheetName:t.getSheetName(),range:t.getRange()})}`,this._rule.formula2=void 0,this._rule.showDropDown=r!=null?r:!0,this}setAllowInvalid(t){return this._rule.errorStyle=t?i.DataValidationErrorStyle.WARNING:i.DataValidationErrorStyle.STOP,this}setHelpText(t){return this._rule.error=t,this._rule.showErrorMessage=!0,this}withCriteriaValues(t,e){return this._rule.type=t,this._rule.operator=e[0],this._rule.formula1=e[1],this._rule.formula2=e[2],this}setAllowBlank(t){return this._rule.allowBlank=t,this}setOptions(t){return Object.assign(this._rule,t),this}}class u{constructor(t,e,r){d(this,"rule");d(this,"_worksheet");d(this,"_injector");this._injector=r,this.rule=t,this._worksheet=e}getAllowInvalid(){return this.rule.errorStyle!==i.DataValidationErrorStyle.STOP}getCriteriaType(){return this.rule.type}getCriteriaValues(){return[this.rule.operator,this.rule.formula1,this.rule.formula2]}getHelpText(){return this.rule.error}copy(){return new l(this.rule)}getApplied(){if(!this._worksheet)return!1;const e=this._injector.get(_.DataValidationModel).getRuleById(this._worksheet.getUnitId(),this._worksheet.getSheetId(),this.rule.uid);return!!(e&&e.ranges.length)}getRanges(){if(!this.getApplied())return[];const t=this._injector.get(i.IUniverInstanceService).getUnit(this._worksheet.getUnitId());return this.rule.ranges.map(e=>this._injector.createInstance(s.FRange,t,this._worksheet,e))}getUnitId(){var t;return(t=this._worksheet)==null?void 0:t.getUnitId()}getSheetId(){var t;return(t=this._worksheet)==null?void 0:t.getSheetId()}setCriteria(t,e,r=!0){if(this.getApplied()&&!this._injector.get(i.ICommandService).syncExecuteCommand(a.UpdateSheetDataValidationSettingCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,setting:{operator:e[0],formula1:e[1],formula2:e[2],type:this.rule.type,allowBlank:r}}))throw new Error("setCriteria failed");return this.rule.operator=e[0],this.rule.formula1=e[1],this.rule.formula2=e[2],this.rule.type=t,this.rule.allowBlank=r,this}setOptions(t){if(this.getApplied()&&!this._injector.get(i.ICommandService).syncExecuteCommand(a.UpdateSheetDataValidationOptionsCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,options:{..._.getRuleOptions(this.rule),...t}}))throw new Error("setOptions failed");return Object.assign(this.rule,t),this}setRanges(t){if(this.getApplied()&&!this._injector.get(i.ICommandService).syncExecuteCommand(a.UpdateSheetDataValidationRangeCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,ranges:t.map(o=>o.getRange())}))throw new Error("setRanges failed");return this.rule.ranges=t.map(e=>e.getRange()),this}delete(){return this.getApplied()?this._injector.get(i.ICommandService).syncExecuteCommand(a.RemoveSheetDataValidationCommand.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid}):!1}}class g extends s.FRange{setDataValidation(t){if(!t)return this._commandService.syncExecuteCommand(a.ClearRangeDataValidationCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]}),this;const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:{...t.rule,ranges:[this._range]}};return this._commandService.syncExecuteCommand(a.AddSheetDataValidationCommand.id,e),this}getDataValidation(){const e=this._injector.get(a.SheetsDataValidationValidatorService).getDataValidation(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]);return e&&new u(e,this._worksheet,this._injector)}getDataValidations(){return this._injector.get(a.SheetsDataValidationValidatorService).getDataValidations(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]).map(e=>new u(e,this._worksheet,this._injector))}async getValidatorStatus(){return this._injector.get(a.SheetsDataValidationValidatorService).validatorRanges(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range])}}s.FRange.extend(g);class D{static newDataValidation(){return new l}newDataValidation(){return new l}}i.FUniver.extend(D);class f extends s.FWorkbook{_initialize(){Object.defineProperty(this,"_dataValidationModel",{get(){return this._injector.get(a.SheetDataValidationModel)}})}getValidatorStatus(){return this._injector.get(a.SheetsDataValidationValidatorService).validatorWorkbook(this._workbook.getUnitId())}onDataValidationChange(t){return i.toDisposable(this._dataValidationModel.ruleChange$.pipe(m.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onDataValidationStatusChange(t){return i.toDisposable(this._dataValidationModel.validStatusChange$.pipe(m.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onBeforeAddDataValidation(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.AddSheetDataValidationCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeAddDataValidation")}}))}onBeforeUpdateDataValidationCriteria(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.UpdateSheetDataValidationSettingCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria")}}))}onBeforeUpdateDataValidationRange(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.UpdateSheetDataValidationRangeCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange")}}))}onBeforeUpdateDataValidationOptions(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.UpdateSheetDataValidationOptionsCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions")}}))}onBeforeDeleteDataValidation(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.RemoveSheetDataValidationCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation")}}))}onBeforeDeleteAllDataValidation(t){return i.toDisposable(this._commandService.beforeCommandExecuted((e,r)=>{const o=e.params;if(e.id===a.RemoveSheetAllDataValidationCommand.id){if(o.unitId!==this._workbook.getUnitId())return;if(t(o,r)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation")}}))}}s.FWorkbook.extend(f);class S extends s.FWorksheet{getDataValidations(){return this._injector.get(_.DataValidationModel).getRules(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>new u(e,this._worksheet,this._injector))}getValidatorStatus(){return this._injector.get(a.SheetsDataValidationValidatorService).validatorWorksheet(this._workbook.getUnitId(),this._worksheet.getSheetId())}}s.FWorksheet.extend(S),n.FDataValidation=u,n.FDataValidationBuilder=l,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-data-validation",
3
- "version": "0.5.2",
3
+ "version": "0.5.3-nightly.202501051605",
4
4
  "private": false,
5
5
  "description": "Data validation for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,38 +53,20 @@
53
53
  "rxjs": ">=7.0.0"
54
54
  },
55
55
  "dependencies": {
56
- "@univerjs/protocol": "0.1.39",
57
- "@univerjs/data-validation": "0.5.2",
58
- "@univerjs/engine-formula": "0.5.2",
59
- "@univerjs/sheets": "0.5.2",
60
- "@univerjs/core": "0.5.2",
61
- "@univerjs/sheets-formula": "0.5.2"
56
+ "@univerjs/protocol": "0.1.40",
57
+ "@univerjs/core": "0.5.3-nightly.202501051605",
58
+ "@univerjs/data-validation": "0.5.3-nightly.202501051605",
59
+ "@univerjs/engine-formula": "0.5.3-nightly.202501051605",
60
+ "@univerjs/sheets": "0.5.3-nightly.202501051605",
61
+ "@univerjs/sheets-formula": "0.5.3-nightly.202501051605"
62
62
  },
63
63
  "devDependencies": {
64
64
  "less": "^4.2.1",
65
65
  "rxjs": "^7.8.1",
66
66
  "typescript": "^5.7.2",
67
- "vite": "^6.0.3",
67
+ "vite": "^6.0.6",
68
68
  "vitest": "^2.1.8",
69
- "@univerjs-infra/shared": "0.5.2"
70
- },
71
- "space": {
72
- ".": {
73
- "import": "./lib/es/index.js",
74
- "require": "./lib/cjs/index.js",
75
- "types": "./lib/types/index.d.ts"
76
- },
77
- "./*": {
78
- "import": "./lib/es/*",
79
- "require": "./lib/cjs/*",
80
- "types": "./lib/types/index.d.ts"
81
- },
82
- "./facade": {
83
- "import": "./lib/es/facade.js",
84
- "require": "./lib/cjs/facade.js",
85
- "types": "./lib/types/facade/index.d.ts"
86
- },
87
- "./lib/*": "./lib/*"
69
+ "@univerjs-infra/shared": "0.5.3"
88
70
  },
89
71
  "scripts": {
90
72
  "dev": "vite",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS