@univerjs/data-validation 0.21.1 → 0.22.0-insiders.20260513-09bbeca

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/README.md CHANGED
@@ -1,37 +1,38 @@
1
1
  # @univerjs/data-validation
2
2
 
3
- ## Package Overview
4
-
5
- | Package Name | UMD Namespace | Version | License | Downloads | Contains CSS | Contains i18n locales |
6
- | --- | --- | --- | --- | --- | :---: | :---: |
7
- | `@univerjs/data-validation` | `UniverDataValidation` | [![][npm-version-shield]][npm-version-link] | ![][npm-license-shield] | ![][npm-downloads-shield] | ❌ | ❌ |
8
-
9
- ## Introduction
3
+ [![npm version](https://img.shields.io/npm/v/@univerjs/data-validation?style=flat-square)](https://npmjs.com/package/@univerjs/data-validation)
4
+ [![license](https://img.shields.io/npm/l/@univerjs/data-validation?style=flat-square)](https://npmjs.com/package/@univerjs/data-validation)
5
+ [![downloads](https://img.shields.io/npm/dm/@univerjs/data-validation?style=flat-square)](https://npmjs.com/package/@univerjs/data-validation)
10
6
 
11
- > `@univerjs/data-validation` provides Univer Sheet with basic capabilities for data validation computation.
7
+ `@univerjs/data-validation` provides the shared data validation model and rule services used by sheet data validation features.
12
8
 
13
- ## Usage
9
+ ## Package Overview
14
10
 
15
- ### Installation
11
+ | Package | UMD global | CSS | Locales | Facade entry |
12
+ | --- | --- | :---: | :---: | :---: |
13
+ | `@univerjs/data-validation` | `UniverDataValidation` | No | No | No |
16
14
 
17
- ```shell
18
- # Using npm
19
- npm i @univerjs/data-validation
15
+ ## Installation
20
16
 
21
- # Using pnpm
17
+ ```sh
22
18
  pnpm add @univerjs/data-validation
19
+ # or
20
+ npm install @univerjs/data-validation
23
21
  ```
24
22
 
25
- ### Register the plugin
23
+ Keep all `@univerjs/*` packages on the same version.
26
24
 
27
- ```typescript
25
+ ## Usage
26
+
27
+ ```ts
28
28
  import { UniverDataValidationPlugin } from '@univerjs/data-validation';
29
29
 
30
30
  univer.registerPlugin(UniverDataValidationPlugin);
31
31
  ```
32
32
 
33
- <!-- Links -->
34
- [npm-version-shield]: https://img.shields.io/npm/v/@univerjs/data-validation?style=flat-square
35
- [npm-version-link]: https://npmjs.com/package/@univerjs/data-validation
36
- [npm-license-shield]: https://img.shields.io/npm/l/@univerjs/data-validation?style=flat-square
37
- [npm-downloads-shield]: https://img.shields.io/npm/dm/@univerjs/data-validation?style=flat-square
33
+ ## Resources
34
+
35
+ - [Documentation](https://docs.univer.ai)
36
+ - [NPM package](https://npmjs.com/package/@univerjs/data-validation)
37
+ - [GitHub repository](https://github.com/dream-num/univer)
38
+
package/lib/cjs/index.js CHANGED
@@ -54,7 +54,7 @@ let UpdateRuleType = /* @__PURE__ */ function(UpdateRuleType) {
54
54
  }({});
55
55
 
56
56
  //#endregion
57
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
57
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
58
58
  function _typeof(o) {
59
59
  "@babel/helpers - typeof";
60
60
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -65,7 +65,7 @@ function _typeof(o) {
65
65
  }
66
66
 
67
67
  //#endregion
68
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
68
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
69
69
  function toPrimitive(t, r) {
70
70
  if ("object" != _typeof(t) || !t) return t;
71
71
  var e = t[Symbol.toPrimitive];
@@ -78,14 +78,14 @@ function toPrimitive(t, r) {
78
78
  }
79
79
 
80
80
  //#endregion
81
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
81
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
82
82
  function toPropertyKey(t) {
83
83
  var i = toPrimitive(t, "string");
84
84
  return "symbol" == _typeof(i) ? i : i + "";
85
85
  }
86
86
 
87
87
  //#endregion
88
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
88
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
89
89
  function _defineProperty(e, r, t) {
90
90
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
91
91
  value: t,
@@ -96,7 +96,7 @@ function _defineProperty(e, r, t) {
96
96
  }
97
97
 
98
98
  //#endregion
99
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
99
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
100
100
  function __decorateParam(paramIndex, decorator) {
101
101
  return function(target, key) {
102
102
  decorator(target, key, paramIndex);
@@ -104,7 +104,7 @@ function __decorateParam(paramIndex, decorator) {
104
104
  }
105
105
 
106
106
  //#endregion
107
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
107
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
108
108
  function __decorate(decorators, target, key, desc) {
109
109
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
110
110
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -161,16 +161,16 @@ let DataValidationModel = class DataValidationModel extends _univerjs_core.Dispo
161
161
  if (!oldRule) throw new Error(`Data validation rule is not found, ruleId: ${ruleId}.`);
162
162
  const rule = { ...oldRule };
163
163
  switch (payload.type) {
164
- case UpdateRuleType.RANGE:
164
+ case 1:
165
165
  rule.ranges = payload.payload;
166
166
  break;
167
- case UpdateRuleType.SETTING:
167
+ case 0:
168
168
  Object.assign(rule, getRuleSetting(payload.payload));
169
169
  break;
170
- case UpdateRuleType.OPTIONS:
170
+ case 2:
171
171
  Object.assign(rule, getRuleOptions(payload.payload));
172
172
  break;
173
- case UpdateRuleType.ALL:
173
+ case 3:
174
174
  Object.assign(rule, payload.payload);
175
175
  break;
176
176
  default: break;
@@ -364,7 +364,7 @@ DataValidationResourceController = __decorate([
364
364
  //#endregion
365
365
  //#region package.json
366
366
  var name = "@univerjs/data-validation";
367
- var version = "0.21.1";
367
+ var version = "0.22.0-insiders.20260513-09bbeca";
368
368
 
369
369
  //#endregion
370
370
  //#region src/services/data-validator-registry.service.ts
@@ -515,7 +515,7 @@ const UpdateDataValidationOptionsCommand = {
515
515
  subUnitId,
516
516
  ruleId,
517
517
  payload: {
518
- type: UpdateRuleType.OPTIONS,
518
+ type: 2,
519
519
  payload: options
520
520
  }
521
521
  };
@@ -528,7 +528,7 @@ const UpdateDataValidationOptionsCommand = {
528
528
  subUnitId,
529
529
  ruleId,
530
530
  payload: {
531
- type: UpdateRuleType.OPTIONS,
531
+ type: 2,
532
532
  payload: getRuleOptions(rule)
533
533
  }
534
534
  };
@@ -573,7 +573,7 @@ const UpdateDataValidationSettingCommand = {
573
573
  subUnitId,
574
574
  ruleId,
575
575
  payload: {
576
- type: UpdateRuleType.SETTING,
576
+ type: 0,
577
577
  payload: {
578
578
  ...setting,
579
579
  ...validator.normalizeFormula(newRule, unitId, subUnitId)
@@ -589,7 +589,7 @@ const UpdateDataValidationSettingCommand = {
589
589
  subUnitId,
590
590
  ruleId,
591
591
  payload: {
592
- type: UpdateRuleType.SETTING,
592
+ type: 0,
593
593
  payload: getRuleSetting(rule)
594
594
  }
595
595
  };
package/lib/es/index.js CHANGED
@@ -53,7 +53,7 @@ let UpdateRuleType = /* @__PURE__ */ function(UpdateRuleType) {
53
53
  }({});
54
54
 
55
55
  //#endregion
56
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
56
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
57
57
  function _typeof(o) {
58
58
  "@babel/helpers - typeof";
59
59
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -64,7 +64,7 @@ function _typeof(o) {
64
64
  }
65
65
 
66
66
  //#endregion
67
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
67
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
68
68
  function toPrimitive(t, r) {
69
69
  if ("object" != _typeof(t) || !t) return t;
70
70
  var e = t[Symbol.toPrimitive];
@@ -77,14 +77,14 @@ function toPrimitive(t, r) {
77
77
  }
78
78
 
79
79
  //#endregion
80
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
80
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
81
81
  function toPropertyKey(t) {
82
82
  var i = toPrimitive(t, "string");
83
83
  return "symbol" == _typeof(i) ? i : i + "";
84
84
  }
85
85
 
86
86
  //#endregion
87
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
87
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
88
88
  function _defineProperty(e, r, t) {
89
89
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
90
90
  value: t,
@@ -95,7 +95,7 @@ function _defineProperty(e, r, t) {
95
95
  }
96
96
 
97
97
  //#endregion
98
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
98
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
99
99
  function __decorateParam(paramIndex, decorator) {
100
100
  return function(target, key) {
101
101
  decorator(target, key, paramIndex);
@@ -103,7 +103,7 @@ function __decorateParam(paramIndex, decorator) {
103
103
  }
104
104
 
105
105
  //#endregion
106
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
106
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
107
107
  function __decorate(decorators, target, key, desc) {
108
108
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
109
109
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -160,16 +160,16 @@ let DataValidationModel = class DataValidationModel extends Disposable {
160
160
  if (!oldRule) throw new Error(`Data validation rule is not found, ruleId: ${ruleId}.`);
161
161
  const rule = { ...oldRule };
162
162
  switch (payload.type) {
163
- case UpdateRuleType.RANGE:
163
+ case 1:
164
164
  rule.ranges = payload.payload;
165
165
  break;
166
- case UpdateRuleType.SETTING:
166
+ case 0:
167
167
  Object.assign(rule, getRuleSetting(payload.payload));
168
168
  break;
169
- case UpdateRuleType.OPTIONS:
169
+ case 2:
170
170
  Object.assign(rule, getRuleOptions(payload.payload));
171
171
  break;
172
- case UpdateRuleType.ALL:
172
+ case 3:
173
173
  Object.assign(rule, payload.payload);
174
174
  break;
175
175
  default: break;
@@ -363,7 +363,7 @@ DataValidationResourceController = __decorate([
363
363
  //#endregion
364
364
  //#region package.json
365
365
  var name = "@univerjs/data-validation";
366
- var version = "0.21.1";
366
+ var version = "0.22.0-insiders.20260513-09bbeca";
367
367
 
368
368
  //#endregion
369
369
  //#region src/services/data-validator-registry.service.ts
@@ -514,7 +514,7 @@ const UpdateDataValidationOptionsCommand = {
514
514
  subUnitId,
515
515
  ruleId,
516
516
  payload: {
517
- type: UpdateRuleType.OPTIONS,
517
+ type: 2,
518
518
  payload: options
519
519
  }
520
520
  };
@@ -527,7 +527,7 @@ const UpdateDataValidationOptionsCommand = {
527
527
  subUnitId,
528
528
  ruleId,
529
529
  payload: {
530
- type: UpdateRuleType.OPTIONS,
530
+ type: 2,
531
531
  payload: getRuleOptions(rule)
532
532
  }
533
533
  };
@@ -572,7 +572,7 @@ const UpdateDataValidationSettingCommand = {
572
572
  subUnitId,
573
573
  ruleId,
574
574
  payload: {
575
- type: UpdateRuleType.SETTING,
575
+ type: 0,
576
576
  payload: {
577
577
  ...setting,
578
578
  ...validator.normalizeFormula(newRule, unitId, subUnitId)
@@ -588,7 +588,7 @@ const UpdateDataValidationSettingCommand = {
588
588
  subUnitId,
589
589
  ruleId,
590
590
  payload: {
591
- type: UpdateRuleType.SETTING,
591
+ type: 0,
592
592
  payload: getRuleSetting(rule)
593
593
  }
594
594
  };
package/lib/index.js CHANGED
@@ -53,7 +53,7 @@ let UpdateRuleType = /* @__PURE__ */ function(UpdateRuleType) {
53
53
  }({});
54
54
 
55
55
  //#endregion
56
- //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
56
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
57
57
  function _typeof(o) {
58
58
  "@babel/helpers - typeof";
59
59
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -64,7 +64,7 @@ function _typeof(o) {
64
64
  }
65
65
 
66
66
  //#endregion
67
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
67
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
68
68
  function toPrimitive(t, r) {
69
69
  if ("object" != _typeof(t) || !t) return t;
70
70
  var e = t[Symbol.toPrimitive];
@@ -77,14 +77,14 @@ function toPrimitive(t, r) {
77
77
  }
78
78
 
79
79
  //#endregion
80
- //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
80
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
81
81
  function toPropertyKey(t) {
82
82
  var i = toPrimitive(t, "string");
83
83
  return "symbol" == _typeof(i) ? i : i + "";
84
84
  }
85
85
 
86
86
  //#endregion
87
- //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
87
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
88
88
  function _defineProperty(e, r, t) {
89
89
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
90
90
  value: t,
@@ -95,7 +95,7 @@ function _defineProperty(e, r, t) {
95
95
  }
96
96
 
97
97
  //#endregion
98
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorateParam.js
98
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
99
99
  function __decorateParam(paramIndex, decorator) {
100
100
  return function(target, key) {
101
101
  decorator(target, key, paramIndex);
@@ -103,7 +103,7 @@ function __decorateParam(paramIndex, decorator) {
103
103
  }
104
104
 
105
105
  //#endregion
106
- //#region \0@oxc-project+runtime@0.124.0/helpers/decorate.js
106
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
107
107
  function __decorate(decorators, target, key, desc) {
108
108
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
109
109
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -160,16 +160,16 @@ let DataValidationModel = class DataValidationModel extends Disposable {
160
160
  if (!oldRule) throw new Error(`Data validation rule is not found, ruleId: ${ruleId}.`);
161
161
  const rule = { ...oldRule };
162
162
  switch (payload.type) {
163
- case UpdateRuleType.RANGE:
163
+ case 1:
164
164
  rule.ranges = payload.payload;
165
165
  break;
166
- case UpdateRuleType.SETTING:
166
+ case 0:
167
167
  Object.assign(rule, getRuleSetting(payload.payload));
168
168
  break;
169
- case UpdateRuleType.OPTIONS:
169
+ case 2:
170
170
  Object.assign(rule, getRuleOptions(payload.payload));
171
171
  break;
172
- case UpdateRuleType.ALL:
172
+ case 3:
173
173
  Object.assign(rule, payload.payload);
174
174
  break;
175
175
  default: break;
@@ -363,7 +363,7 @@ DataValidationResourceController = __decorate([
363
363
  //#endregion
364
364
  //#region package.json
365
365
  var name = "@univerjs/data-validation";
366
- var version = "0.21.1";
366
+ var version = "0.22.0-insiders.20260513-09bbeca";
367
367
 
368
368
  //#endregion
369
369
  //#region src/services/data-validator-registry.service.ts
@@ -514,7 +514,7 @@ const UpdateDataValidationOptionsCommand = {
514
514
  subUnitId,
515
515
  ruleId,
516
516
  payload: {
517
- type: UpdateRuleType.OPTIONS,
517
+ type: 2,
518
518
  payload: options
519
519
  }
520
520
  };
@@ -527,7 +527,7 @@ const UpdateDataValidationOptionsCommand = {
527
527
  subUnitId,
528
528
  ruleId,
529
529
  payload: {
530
- type: UpdateRuleType.OPTIONS,
530
+ type: 2,
531
531
  payload: getRuleOptions(rule)
532
532
  }
533
533
  };
@@ -572,7 +572,7 @@ const UpdateDataValidationSettingCommand = {
572
572
  subUnitId,
573
573
  ruleId,
574
574
  payload: {
575
- type: UpdateRuleType.SETTING,
575
+ type: 0,
576
576
  payload: {
577
577
  ...setting,
578
578
  ...validator.normalizeFormula(newRule, unitId, subUnitId)
@@ -588,7 +588,7 @@ const UpdateDataValidationSettingCommand = {
588
588
  subUnitId,
589
589
  ruleId,
590
590
  payload: {
591
- type: UpdateRuleType.SETTING,
591
+ type: 0,
592
592
  payload: getRuleSetting(rule)
593
593
  }
594
594
  };
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDataValidation={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function r(e){return{type:e.type,operator:e.operator,formula1:e.formula1,formula2:e.formula2,allowBlank:e.allowBlank}}function i(e){return{error:e.error,errorStyle:e.errorStyle,errorTitle:e.errorTitle,imeMode:e.imeMode,prompt:e.prompt,promptTitle:e.promptTitle,showDropDown:e.showDropDown,showErrorMessage:e.showErrorMessage,showInputMessage:e.showInputMessage,renderMode:e.renderMode,bizInfo:e.bizInfo}}let a=function(e){return e[e.SETTING=0]=`SETTING`,e[e.RANGE=1]=`RANGE`,e[e.OPTIONS=2]=`OPTIONS`,e[e.ALL=3]=`ALL`,e}({});function o(e){"@babel/helpers - typeof";return o=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},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){return function(n,r){t(n,r,e)}}function d(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 f=class extends t.Disposable{constructor(e){super(),this._logService=e,l(this,`_model`,new Map),l(this,`_ruleChange$`,new n.Subject),l(this,`ruleChange$`,this._ruleChange$.asObservable()),l(this,`ruleChangeDebounce$`,this.ruleChange$.pipe((0,n.debounceTime)(20))),this.disposeWithMe({dispose:()=>{this._ruleChange$.complete()}})}_ensureMap(e,t){this._model.has(e)||this._model.set(e,new Map);let n=this._model.get(e);if(n.has(t))return n.get(t);let r={map:new Map,list:[]};return n.set(t,r),r}_addSubUnitRule(e,t,n){let{map:r,list:i}=e,a=(Array.isArray(t)?t:[t]).filter(e=>!r.has(e.uid));typeof n==`number`&&n<i.length?i.splice(n,0,...a):i.push(...a),a.forEach(e=>{r.set(e.uid,e)})}_removeSubUnitRule(e,t){let{map:n,list:r}=e,i=r.findIndex(e=>e.uid===t);i>-1&&(r.splice(i,1),n.delete(t))}_updateSubUnitRule(e,t,n){let{map:o,list:s}=e,c=o.get(t),l=s.findIndex(e=>t===e.uid);if(!c)throw Error(`Data validation rule is not found, ruleId: ${t}.`);let u={...c};switch(n.type){case a.RANGE:u.ranges=n.payload;break;case a.SETTING:Object.assign(u,r(n.payload));break;case a.OPTIONS:Object.assign(u,i(n.payload));break;case a.ALL:Object.assign(u,n.payload);break;default:break}return s[l]=u,o.set(t,u),u}_addRuleSideEffect(e,t,n,r){if(!this._ensureMap(e,t).map.get(n.uid))return{rule:n,type:`add`,unitId:e,subUnitId:t,source:r}}addRule(e,t,n,r,i){try{let a=this._ensureMap(e,t),o=(Array.isArray(n)?n:[n]).map(n=>this._addRuleSideEffect(e,t,n,r));this._addSubUnitRule(a,n,i),o.forEach(e=>{e&&this._ruleChange$.next(e)})}catch(e){this._logService.error(e)}}updateRule(e,n,r,i,a){try{let o=this._ensureMap(e,n),s=t.Tools.deepClone(o.map.get(r));if(!s)throw Error(`Data validation rule is not found, ruleId: ${r}.`);let c=this._updateSubUnitRule(o,r,i);this._ruleChange$.next({rule:c,type:`update`,unitId:e,subUnitId:n,source:a,updatePayload:i,oldRule:s})}catch(e){this._logService.error(e)}}removeRule(e,t,n,r){try{let i=this._ensureMap(e,t),a=i.map.get(n);a&&(this._removeSubUnitRule(i,n),this._ruleChange$.next({rule:a,type:`remove`,unitId:e,subUnitId:t,source:r}))}catch(e){this._logService.error(e)}}getRuleById(e,t,n){return this._ensureMap(e,t).map.get(n)}getRuleIndex(e,t,n){return this._ensureMap(e,t).list.findIndex(e=>e.uid===n)}getRules(e,t){return[...this._ensureMap(e,t).list]}getUnitRules(e){let t=this._model.get(e);if(!t)return[];let n=[];return t.forEach((e,t)=>{n.push([t,e.list])}),n}deleteUnitRules(e){this._model.delete(e)}getSubUnitIds(e){var t,n;return Array.from((t=(n=this._model.get(e))==null?void 0:n.keys())==null?[]:t)}getAll(){return Array.from(this._model.keys()).map(e=>[e,this.getUnitRules(e)])}};f=d([u(0,t.ILogService)],f);let p={type:t.CommandType.MUTATION,id:`data-validation.mutation.addRule`,handler(e,t){if(!t)return!1;let{unitId:n,subUnitId:r,rule:i,index:a,source:o=`command`}=t;return e.get(f).addRule(n,r,i,o,a),!0}},m={type:t.CommandType.MUTATION,id:`data-validation.mutation.removeRule`,handler(e,t){if(!t)return!1;let{unitId:n,subUnitId:r,ruleId:i,source:a=`command`}=t,o=e.get(f);return Array.isArray(i)?i.forEach(e=>{o.removeRule(n,r,e,a)}):o.removeRule(n,r,i,a),!0}},h={type:t.CommandType.MUTATION,id:`data-validation.mutation.updateRule`,handler(e,t){if(!t)return!1;let{unitId:n,subUnitId:r,ruleId:i,payload:a,source:o=`command`}=t;return e.get(f).updateRule(n,r,i,a,o),!0}},g=class extends t.Disposable{constructor(e,t,n){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._dataValidationModel=n,this._initSnapshot()}_initSnapshot(){let e=e=>{let t=this._dataValidationModel.getUnitRules(e),n={};return t?(t.forEach(([e,t])=>{n[e]=t}),JSON.stringify(n)):``},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:`SHEET_DATA_VALIDATION_PLUGIN`,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._dataValidationModel.deleteUnitRules(e)},onLoad:(e,t)=>{Object.keys(t).forEach(n=>{t[n].forEach(t=>{this._dataValidationModel.addRule(e,n,t,`patched`)})})}}))}};g=d([u(0,t.IResourceManagerService),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(f))],g);var _=`@univerjs/data-validation`,v=`0.21.1`;let y=function(e){return e.SHEET=`sheet`,e}({});var b=class{constructor(){l(this,`_validatorByScopes`,new Map),l(this,`_validatorMap`,new Map),l(this,`_validatorsChange$`,new n.BehaviorSubject(void 0)),l(this,`validatorsChange$`,this._validatorsChange$.asObservable())}_addValidatorToScope(e,t){this._validatorByScopes.has(t)||this._validatorByScopes.set(t,[]);let n=this._validatorByScopes.get(t);if(n.findIndex(t=>t.id===e.id)>-1)throw Error(`Validator item with the same id ${e.id} has already been added!`);n.push(e)}_removeValidatorFromScope(e,t){let n=this._validatorByScopes.get(t);if(!n)return;let r=n.findIndex(t=>t.id===e.id);r>-1&&n.splice(r,1)}register(e){return this._validatorMap.set(e.id,e),Array.isArray(e.scopes)?e.scopes.forEach(t=>{this._addValidatorToScope(e,t)}):this._addValidatorToScope(e,e.scopes),this._validatorsChange$.next(),(0,t.toDisposable)(()=>{this._validatorMap.delete(e.id),Array.isArray(e.scopes)?e.scopes.forEach(t=>{this._removeValidatorFromScope(e,t)}):this._removeValidatorFromScope(e,e.scopes),this._validatorsChange$.next()})}getValidatorItem(e){return this._validatorMap.get(e)}getValidatorsByScope(e){return this._validatorByScopes.get(e)}};let x={type:t.CommandType.COMMAND,id:`data-validation.command.addRule`,async handler(e,n){if(e.get(t.ILogService).error("[Deprecated]: `AddDataValidationCommand` is deprecated, please use `AddSheetDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"),!n)return!1;let{rule:r,unitId:i,subUnitId:a}=n,o=e.get(t.ICommandService),s=e.get(t.IUndoRedoService),c={...n,rule:{...n.rule,ranges:[n.rule.range]}},l=[{id:p.id,params:c}],u=[{id:m.id,params:{unitId:i,subUnitId:a,ruleId:r.uid}}];return s.pushUndoRedo({unitID:i,redoMutations:l,undoMutations:u}),await o.executeCommand(p.id,c),!0}},S={type:t.CommandType.COMMAND,id:`data-validation.command.removeRule`,handler(e,n){if(e.get(t.ILogService).error("[Deprecated]: `RemoveDataValidationCommand` is deprecated, please use `RemoveSheetDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"),!n)return!1;let{unitId:r,subUnitId:i,ruleId:a}=n,o=e.get(t.ICommandService),s=e.get(t.IUndoRedoService),c=e.get(f),l=[{id:m.id,params:n}],u=[{id:p.id,params:{unitId:r,subUnitId:i,rule:{...c.getRuleById(r,i,a)},index:c.getRuleIndex(r,i,a)}}];return s.pushUndoRedo({undoMutations:u,redoMutations:l,unitID:n.unitId}),o.executeCommand(m.id,n),!0}},C={type:t.CommandType.COMMAND,id:`data-validation.command.updateDataValidationSetting`,handler(e,n){if(e.get(t.ILogService).warn("[Deprecated]: `UpdateDataValidationOptionsCommand` is deprecated, please use `UpdateSheetDataValidationOptionsCommand` in `@univerjs/sheets-data-validation` instead!"),!n)return!1;let r=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(f),{unitId:c,subUnitId:l,ruleId:u,options:d}=n,p=s.getRuleById(c,l,u);if(!p)return!1;let m={unitId:c,subUnitId:l,ruleId:u,payload:{type:a.OPTIONS,payload:d}},g=[{id:h.id,params:m}],_={unitId:c,subUnitId:l,ruleId:u,payload:{type:a.OPTIONS,payload:i(p)}},v=[{id:h.id,params:_}];return o.pushUndoRedo({unitID:c,redoMutations:g,undoMutations:v}),r.executeCommand(h.id,m),!0}},w={type:t.CommandType.COMMAND,id:`data-validation.command.updateDataValidationOptions`,handler(e,n){if(e.get(t.ILogService).error("[Deprecated]: `UpdateDataValidationSettingCommand` is deprecated, please use `UpdateSheetDataValidationSettingCommand` in `@univerjs/sheets-data-validation` instead!"),!n)return!1;let i=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(f),c=e.get(b),{unitId:l,subUnitId:u,ruleId:d,setting:p}=n,m=c.getValidatorItem(p.type);if(!m)return!1;let g=s.getRuleById(l,u,d);if(!g)return!1;let _={...g,...p};if(!m.validatorFormula(_,l,u).success)return!1;let v={unitId:l,subUnitId:u,ruleId:d,payload:{type:a.SETTING,payload:{...p,...m.normalizeFormula(_,l,u)}}},y=[{id:h.id,params:v}],x={unitId:l,subUnitId:u,ruleId:d,payload:{type:a.SETTING,payload:r(g)}},S=[{id:h.id,params:x}];return o.pushUndoRedo({unitID:l,redoMutations:y,undoMutations:S}),i.executeCommand(h.id,v),!0}},T={type:t.CommandType.COMMAND,id:`data-validation.command.removeAll`,handler(e,n){if(e.get(t.ILogService).error("[Deprecated]: `RemoveAllDataValidationCommand` is deprecated, please use `RemoveSheetAllDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"),!n)return!1;let{unitId:r,subUnitId:i}=n,a=e.get(t.ICommandService),o=e.get(f),s=e.get(t.IUndoRedoService),c=[...o.getRules(r,i)],l={unitId:r,subUnitId:i,ruleId:c.map(e=>e.uid)},u=[{id:m.id,params:l}],d=[{id:p.id,params:{unitId:r,subUnitId:i,rule:c}}];return s.pushUndoRedo({redoMutations:u,undoMutations:d,unitID:r}),a.executeCommand(m.id,l),!0}},E=`data-validation.config`;Symbol(E);let D={},O=class extends t.Plugin{constructor(e=D,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{...a}=(0,t.merge)({},D,this._config);this._configService.setConfig(E,a)}onStarting(){[[f],[b],[g]].forEach(e=>this._injector.add(e)),[x,T,C,w,S,p,h,m].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(g)}};l(O,`pluginName`,`UNIVER_DATA_VALIDATION_PLUGIN`),l(O,`packageName`,_),l(O,`version`,v),l(O,`type`,t.UniverInstanceType.UNIVER_SHEET),O=d([u(1,(0,t.Inject)(t.Injector)),u(2,t.ICommandService),u(3,t.IConfigService)],O),t.DataValidationOperator.BETWEEN,t.DataValidationOperator.EQUAL,t.DataValidationOperator.GREATER_THAN,t.DataValidationOperator.GREATER_THAN_OR_EQUAL,t.DataValidationOperator.LESS_THAN,t.DataValidationOperator.LESS_THAN_OR_EQUAL,t.DataValidationOperator.NOT_BETWEEN,t.DataValidationOperator.NOT_EQUAL;let k={[t.DataValidationOperator.BETWEEN]:`dataValidation.ruleName.between`,[t.DataValidationOperator.EQUAL]:`dataValidation.ruleName.equal`,[t.DataValidationOperator.GREATER_THAN]:`dataValidation.ruleName.greaterThan`,[t.DataValidationOperator.GREATER_THAN_OR_EQUAL]:`dataValidation.ruleName.greaterThanOrEqual`,[t.DataValidationOperator.LESS_THAN]:`dataValidation.ruleName.lessThan`,[t.DataValidationOperator.LESS_THAN_OR_EQUAL]:`dataValidation.ruleName.lessThanOrEqual`,[t.DataValidationOperator.NOT_BETWEEN]:`dataValidation.ruleName.notBetween`,[t.DataValidationOperator.NOT_EQUAL]:`dataValidation.ruleName.notEqual`,NONE:`dataValidation.ruleName.legal`},A={[t.DataValidationOperator.BETWEEN]:`dataValidation.errorMsg.between`,[t.DataValidationOperator.EQUAL]:`dataValidation.errorMsg.equal`,[t.DataValidationOperator.GREATER_THAN]:`dataValidation.errorMsg.greaterThan`,[t.DataValidationOperator.GREATER_THAN_OR_EQUAL]:`dataValidation.errorMsg.greaterThanOrEqual`,[t.DataValidationOperator.LESS_THAN]:`dataValidation.errorMsg.lessThan`,[t.DataValidationOperator.LESS_THAN_OR_EQUAL]:`dataValidation.errorMsg.lessThanOrEqual`,[t.DataValidationOperator.NOT_BETWEEN]:`dataValidation.errorMsg.notBetween`,[t.DataValidationOperator.NOT_EQUAL]:`dataValidation.errorMsg.notEqual`,NONE:`dataValidation.errorMsg.legal`},j={[t.DataValidationOperator.BETWEEN]:`dataValidation.textLength.errorMsg.between`,[t.DataValidationOperator.EQUAL]:`dataValidation.textLength.errorMsg.equal`,[t.DataValidationOperator.GREATER_THAN]:`dataValidation.textLength.errorMsg.greaterThan`,[t.DataValidationOperator.GREATER_THAN_OR_EQUAL]:`dataValidation.textLength.errorMsg.greaterThanOrEqual`,[t.DataValidationOperator.LESS_THAN]:`dataValidation.textLength.errorMsg.lessThan`,[t.DataValidationOperator.LESS_THAN_OR_EQUAL]:`dataValidation.textLength.errorMsg.lessThanOrEqual`,[t.DataValidationOperator.NOT_BETWEEN]:`dataValidation.textLength.errorMsg.notBetween`,[t.DataValidationOperator.NOT_EQUAL]:`dataValidation.textLength.errorMsg.notEqual`},M=[t.DataValidationOperator.BETWEEN,t.DataValidationOperator.NOT_BETWEEN],N=`{FORMULA1}`,P=`{FORMULA2}`,F=`{TYPE}`,I={[t.DataValidationOperator.BETWEEN]:`dataValidation.operators.between`,[t.DataValidationOperator.EQUAL]:`dataValidation.operators.equal`,[t.DataValidationOperator.GREATER_THAN]:`dataValidation.operators.greaterThan`,[t.DataValidationOperator.GREATER_THAN_OR_EQUAL]:`dataValidation.operators.greaterThanOrEqual`,[t.DataValidationOperator.LESS_THAN]:`dataValidation.operators.lessThan`,[t.DataValidationOperator.LESS_THAN_OR_EQUAL]:`dataValidation.operators.lessThanOrEqual`,[t.DataValidationOperator.NOT_BETWEEN]:`dataValidation.operators.notBetween`,[t.DataValidationOperator.NOT_EQUAL]:`dataValidation.operators.notEqual`},L=function(e){return e.DATE=`date`,e.TIME=`time`,e.DATETIME=`datetime`,e.LIST=`list`,e.MULTIPLE_LIST=`multipleList`,e.COLOR=`color`,e.CASCADE=`cascade`,e}({}),R=class{constructor(e,t){this.localeService=e,this.injector=t,l(this,`offsetFormulaByRange`,!0),l(this,`formulaInput`,void 0),l(this,`canvasRender`,null),l(this,`dropdownType`,void 0),l(this,`optionsInput`,void 0),l(this,`skipDefaultFontRender`,void 0)}get operatorNames(){return this.operators.map(e=>this.localeService.t(I[e]))}get titleStr(){return this.localeService.t(this.title)}generateRuleName(e){var t,n;if(!e.operator)return this.localeService.t(k.NONE).replace(F,this.titleStr);let r=this.localeService.t(k[e.operator]).replace(N,(t=e.formula1)==null?``:t).replace(P,(n=e.formula2)==null?``:n);return`${this.titleStr} ${r}`}generateRuleErrorMessage(e,t){var n,r;return e.operator?`${this.localeService.t(A[e.operator]).replace(N,(n=e.formula1)==null?``:n).replace(P,(r=e.formula2)==null?``:r)}`:this.localeService.t(A.NONE).replace(F,this.titleStr)}getExtraStyle(e,t,n,r,i){}getRuleFinalError(e,t){return e.showErrorMessage&&e.error?e.error:this.generateRuleErrorMessage(e,t)}isEmptyCellValue(e){return e===``||e==null}normalizeFormula(e,t,n){return{formula1:e.formula1,formula2:e.formula2}}async isValidType(e,t,n){return!0}transform(e,t,n){return e}async validatorIsEqual(e,t,n){let{formula1:r}=t,{value:i}=e;return Number.isNaN(r)?!0:i===r}async validatorIsNotEqual(e,t,n){let{formula1:r}=t;return Number.isNaN(r)?!0:e.value!==r}async validatorIsBetween(e,t,n){let{formula1:r,formula2:i}=t;if(Number.isNaN(r)||Number.isNaN(i))return!0;let a=Math.min(r,i),o=Math.max(r,i);return e.value>=a&&e.value<=o}async validatorIsNotBetween(e,t,n){let{formula1:r,formula2:i}=t;if(Number.isNaN(r)||Number.isNaN(i))return!0;let a=Math.min(r,i),o=Math.max(r,i);return e.value<a||e.value>o}async validatorIsGreaterThan(e,t,n){let{formula1:r}=t;return Number.isNaN(r)?!0:e.value>r}async validatorIsGreaterThanOrEqual(e,t,n){let{formula1:r}=t;return Number.isNaN(r)?!0:e.value>=r}async validatorIsLessThan(e,t,n){let{formula1:r}=t;return Number.isNaN(r)?!0:e.value<r}async validatorIsLessThanOrEqual(e,t,n){let{formula1:r}=t;return Number.isNaN(r)?!0:e.value<=r}async validator(e,n){let{value:r,unitId:i,subUnitId:a}=e,o=this.isEmptyCellValue(r),{allowBlank:s=!0,operator:c}=n;if(o)return s;let l=await this.parseFormula(n,i,a,e.row,e.column);if(!l.isFormulaValid||!await this.isValidType(e,l,n))return!1;if(!c)return!0;let u=this.transform(e,l,n);switch(c){case t.DataValidationOperator.BETWEEN:return this.validatorIsBetween(u,l,n);case t.DataValidationOperator.EQUAL:return this.validatorIsEqual(u,l,n);case t.DataValidationOperator.GREATER_THAN:return this.validatorIsGreaterThan(u,l,n);case t.DataValidationOperator.GREATER_THAN_OR_EQUAL:return this.validatorIsGreaterThanOrEqual(u,l,n);case t.DataValidationOperator.LESS_THAN:return this.validatorIsLessThan(u,l,n);case t.DataValidationOperator.LESS_THAN_OR_EQUAL:return this.validatorIsLessThanOrEqual(u,l,n);case t.DataValidationOperator.NOT_BETWEEN:return this.validatorIsNotBetween(u,l,n);case t.DataValidationOperator.NOT_EQUAL:return this.validatorIsNotEqual(u,l,n);default:throw Error(`Unknown operator.`)}}};R=d([u(0,(0,t.Inject)(t.LocaleService)),u(1,(0,t.Inject)(t.Injector))],R),e.AddDataValidationMutation=p,Object.defineProperty(e,`BaseDataValidator`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,`DataValidationModel`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,`DataValidationResourceController`,{enumerable:!0,get:function(){return g}}),e.DataValidatorDropdownType=L,e.DataValidatorRegistryScope=y,e.DataValidatorRegistryService=b,e.FORMULA1=N,e.FORMULA2=P,e.RemoveDataValidationMutation=m,e.TWO_FORMULA_OPERATOR_COUNT=M,e.TYPE=F,e.TextLengthErrorTitleMap=j,Object.defineProperty(e,`UniverDataValidationPlugin`,{enumerable:!0,get:function(){return O}}),e.UpdateDataValidationMutation=h,e.UpdateRuleType=a,e.getRuleOptions=i,e.getRuleSetting=r});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDataValidation={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function r(e){return{type:e.type,operator:e.operator,formula1:e.formula1,formula2:e.formula2,allowBlank:e.allowBlank}}function i(e){return{error:e.error,errorStyle:e.errorStyle,errorTitle:e.errorTitle,imeMode:e.imeMode,prompt:e.prompt,promptTitle:e.promptTitle,showDropDown:e.showDropDown,showErrorMessage:e.showErrorMessage,showInputMessage:e.showInputMessage,renderMode:e.renderMode,bizInfo:e.bizInfo}}let a=function(e){return e[e.SETTING=0]=`SETTING`,e[e.RANGE=1]=`RANGE`,e[e.OPTIONS=2]=`OPTIONS`,e[e.ALL=3]=`ALL`,e}({});function o(e){"@babel/helpers - typeof";return o=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},o(e)}function s(e,t){if(o(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(o(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function c(e){var t=s(e,`string`);return o(t)==`symbol`?t:t+``}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){return function(n,r){t(n,r,e)}}function d(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 f=class extends t.Disposable{constructor(e){super(),this._logService=e,l(this,`_model`,new Map),l(this,`_ruleChange$`,new n.Subject),l(this,`ruleChange$`,this._ruleChange$.asObservable()),l(this,`ruleChangeDebounce$`,this.ruleChange$.pipe((0,n.debounceTime)(20))),this.disposeWithMe({dispose:()=>{this._ruleChange$.complete()}})}_ensureMap(e,t){this._model.has(e)||this._model.set(e,new Map);let n=this._model.get(e);if(n.has(t))return n.get(t);let r={map:new Map,list:[]};return n.set(t,r),r}_addSubUnitRule(e,t,n){let{map:r,list:i}=e,a=(Array.isArray(t)?t:[t]).filter(e=>!r.has(e.uid));typeof n==`number`&&n<i.length?i.splice(n,0,...a):i.push(...a),a.forEach(e=>{r.set(e.uid,e)})}_removeSubUnitRule(e,t){let{map:n,list:r}=e,i=r.findIndex(e=>e.uid===t);i>-1&&(r.splice(i,1),n.delete(t))}_updateSubUnitRule(e,t,n){let{map:a,list:o}=e,s=a.get(t),c=o.findIndex(e=>t===e.uid);if(!s)throw Error(`Data validation rule is not found, ruleId: ${t}.`);let l={...s};switch(n.type){case 1:l.ranges=n.payload;break;case 0:Object.assign(l,r(n.payload));break;case 2:Object.assign(l,i(n.payload));break;case 3:Object.assign(l,n.payload);break;default:break}return o[c]=l,a.set(t,l),l}_addRuleSideEffect(e,t,n,r){if(!this._ensureMap(e,t).map.get(n.uid))return{rule:n,type:`add`,unitId:e,subUnitId:t,source:r}}addRule(e,t,n,r,i){try{let a=this._ensureMap(e,t),o=(Array.isArray(n)?n:[n]).map(n=>this._addRuleSideEffect(e,t,n,r));this._addSubUnitRule(a,n,i),o.forEach(e=>{e&&this._ruleChange$.next(e)})}catch(e){this._logService.error(e)}}updateRule(e,n,r,i,a){try{let o=this._ensureMap(e,n),s=t.Tools.deepClone(o.map.get(r));if(!s)throw Error(`Data validation rule is not found, ruleId: ${r}.`);let c=this._updateSubUnitRule(o,r,i);this._ruleChange$.next({rule:c,type:`update`,unitId:e,subUnitId:n,source:a,updatePayload:i,oldRule:s})}catch(e){this._logService.error(e)}}removeRule(e,t,n,r){try{let i=this._ensureMap(e,t),a=i.map.get(n);a&&(this._removeSubUnitRule(i,n),this._ruleChange$.next({rule:a,type:`remove`,unitId:e,subUnitId:t,source:r}))}catch(e){this._logService.error(e)}}getRuleById(e,t,n){return this._ensureMap(e,t).map.get(n)}getRuleIndex(e,t,n){return this._ensureMap(e,t).list.findIndex(e=>e.uid===n)}getRules(e,t){return[...this._ensureMap(e,t).list]}getUnitRules(e){let t=this._model.get(e);if(!t)return[];let n=[];return t.forEach((e,t)=>{n.push([t,e.list])}),n}deleteUnitRules(e){this._model.delete(e)}getSubUnitIds(e){var t,n;return Array.from((t=(n=this._model.get(e))==null?void 0:n.keys())==null?[]:t)}getAll(){return Array.from(this._model.keys()).map(e=>[e,this.getUnitRules(e)])}};f=d([u(0,t.ILogService)],f);let p={type:t.CommandType.MUTATION,id:`data-validation.mutation.addRule`,handler(e,t){if(!t)return!1;let{unitId:n,subUnitId:r,rule:i,index:a,source:o=`command`}=t;return e.get(f).addRule(n,r,i,o,a),!0}},m={type:t.CommandType.MUTATION,id:`data-validation.mutation.removeRule`,handler(e,t){if(!t)return!1;let{unitId:n,subUnitId:r,ruleId:i,source:a=`command`}=t,o=e.get(f);return Array.isArray(i)?i.forEach(e=>{o.removeRule(n,r,e,a)}):o.removeRule(n,r,i,a),!0}},h={type:t.CommandType.MUTATION,id:`data-validation.mutation.updateRule`,handler(e,t){if(!t)return!1;let{unitId:n,subUnitId:r,ruleId:i,payload:a,source:o=`command`}=t;return e.get(f).updateRule(n,r,i,a,o),!0}},g=class extends t.Disposable{constructor(e,t,n){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._dataValidationModel=n,this._initSnapshot()}_initSnapshot(){let e=e=>{let t=this._dataValidationModel.getUnitRules(e),n={};return t?(t.forEach(([e,t])=>{n[e]=t}),JSON.stringify(n)):``},n=e=>{if(!e)return{};try{return JSON.parse(e)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:`SHEET_DATA_VALIDATION_PLUGIN`,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:t=>e(t),parseJson:e=>n(e),onUnLoad:e=>{this._dataValidationModel.deleteUnitRules(e)},onLoad:(e,t)=>{Object.keys(t).forEach(n=>{t[n].forEach(t=>{this._dataValidationModel.addRule(e,n,t,`patched`)})})}}))}};g=d([u(0,t.IResourceManagerService),u(1,t.IUniverInstanceService),u(2,(0,t.Inject)(f))],g);var _=`@univerjs/data-validation`,v=`0.22.0-insiders.20260513-09bbeca`;let y=function(e){return e.SHEET=`sheet`,e}({});var b=class{constructor(){l(this,`_validatorByScopes`,new Map),l(this,`_validatorMap`,new Map),l(this,`_validatorsChange$`,new n.BehaviorSubject(void 0)),l(this,`validatorsChange$`,this._validatorsChange$.asObservable())}_addValidatorToScope(e,t){this._validatorByScopes.has(t)||this._validatorByScopes.set(t,[]);let n=this._validatorByScopes.get(t);if(n.findIndex(t=>t.id===e.id)>-1)throw Error(`Validator item with the same id ${e.id} has already been added!`);n.push(e)}_removeValidatorFromScope(e,t){let n=this._validatorByScopes.get(t);if(!n)return;let r=n.findIndex(t=>t.id===e.id);r>-1&&n.splice(r,1)}register(e){return this._validatorMap.set(e.id,e),Array.isArray(e.scopes)?e.scopes.forEach(t=>{this._addValidatorToScope(e,t)}):this._addValidatorToScope(e,e.scopes),this._validatorsChange$.next(),(0,t.toDisposable)(()=>{this._validatorMap.delete(e.id),Array.isArray(e.scopes)?e.scopes.forEach(t=>{this._removeValidatorFromScope(e,t)}):this._removeValidatorFromScope(e,e.scopes),this._validatorsChange$.next()})}getValidatorItem(e){return this._validatorMap.get(e)}getValidatorsByScope(e){return this._validatorByScopes.get(e)}};let x={type:t.CommandType.COMMAND,id:`data-validation.command.addRule`,async handler(e,n){if(e.get(t.ILogService).error("[Deprecated]: `AddDataValidationCommand` is deprecated, please use `AddSheetDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"),!n)return!1;let{rule:r,unitId:i,subUnitId:a}=n,o=e.get(t.ICommandService),s=e.get(t.IUndoRedoService),c={...n,rule:{...n.rule,ranges:[n.rule.range]}},l=[{id:p.id,params:c}],u=[{id:m.id,params:{unitId:i,subUnitId:a,ruleId:r.uid}}];return s.pushUndoRedo({unitID:i,redoMutations:l,undoMutations:u}),await o.executeCommand(p.id,c),!0}},S={type:t.CommandType.COMMAND,id:`data-validation.command.removeRule`,handler(e,n){if(e.get(t.ILogService).error("[Deprecated]: `RemoveDataValidationCommand` is deprecated, please use `RemoveSheetDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"),!n)return!1;let{unitId:r,subUnitId:i,ruleId:a}=n,o=e.get(t.ICommandService),s=e.get(t.IUndoRedoService),c=e.get(f),l=[{id:m.id,params:n}],u=[{id:p.id,params:{unitId:r,subUnitId:i,rule:{...c.getRuleById(r,i,a)},index:c.getRuleIndex(r,i,a)}}];return s.pushUndoRedo({undoMutations:u,redoMutations:l,unitID:n.unitId}),o.executeCommand(m.id,n),!0}},C={type:t.CommandType.COMMAND,id:`data-validation.command.updateDataValidationSetting`,handler(e,n){if(e.get(t.ILogService).warn("[Deprecated]: `UpdateDataValidationOptionsCommand` is deprecated, please use `UpdateSheetDataValidationOptionsCommand` in `@univerjs/sheets-data-validation` instead!"),!n)return!1;let r=e.get(t.ICommandService),a=e.get(t.IUndoRedoService),o=e.get(f),{unitId:s,subUnitId:c,ruleId:l,options:u}=n,d=o.getRuleById(s,c,l);if(!d)return!1;let p={unitId:s,subUnitId:c,ruleId:l,payload:{type:2,payload:u}},m=[{id:h.id,params:p}],g={unitId:s,subUnitId:c,ruleId:l,payload:{type:2,payload:i(d)}},_=[{id:h.id,params:g}];return a.pushUndoRedo({unitID:s,redoMutations:m,undoMutations:_}),r.executeCommand(h.id,p),!0}},w={type:t.CommandType.COMMAND,id:`data-validation.command.updateDataValidationOptions`,handler(e,n){if(e.get(t.ILogService).error("[Deprecated]: `UpdateDataValidationSettingCommand` is deprecated, please use `UpdateSheetDataValidationSettingCommand` in `@univerjs/sheets-data-validation` instead!"),!n)return!1;let i=e.get(t.ICommandService),a=e.get(t.IUndoRedoService),o=e.get(f),s=e.get(b),{unitId:c,subUnitId:l,ruleId:u,setting:d}=n,p=s.getValidatorItem(d.type);if(!p)return!1;let m=o.getRuleById(c,l,u);if(!m)return!1;let g={...m,...d};if(!p.validatorFormula(g,c,l).success)return!1;let _={unitId:c,subUnitId:l,ruleId:u,payload:{type:0,payload:{...d,...p.normalizeFormula(g,c,l)}}},v=[{id:h.id,params:_}],y={unitId:c,subUnitId:l,ruleId:u,payload:{type:0,payload:r(m)}},x=[{id:h.id,params:y}];return a.pushUndoRedo({unitID:c,redoMutations:v,undoMutations:x}),i.executeCommand(h.id,_),!0}},T={type:t.CommandType.COMMAND,id:`data-validation.command.removeAll`,handler(e,n){if(e.get(t.ILogService).error("[Deprecated]: `RemoveAllDataValidationCommand` is deprecated, please use `RemoveSheetAllDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"),!n)return!1;let{unitId:r,subUnitId:i}=n,a=e.get(t.ICommandService),o=e.get(f),s=e.get(t.IUndoRedoService),c=[...o.getRules(r,i)],l={unitId:r,subUnitId:i,ruleId:c.map(e=>e.uid)},u=[{id:m.id,params:l}],d=[{id:p.id,params:{unitId:r,subUnitId:i,rule:c}}];return s.pushUndoRedo({redoMutations:u,undoMutations:d,unitID:r}),a.executeCommand(m.id,l),!0}},E=`data-validation.config`;Symbol(E);let D={},O=class extends t.Plugin{constructor(e=D,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{...a}=(0,t.merge)({},D,this._config);this._configService.setConfig(E,a)}onStarting(){[[f],[b],[g]].forEach(e=>this._injector.add(e)),[x,T,C,w,S,p,h,m].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(g)}};l(O,`pluginName`,`UNIVER_DATA_VALIDATION_PLUGIN`),l(O,`packageName`,_),l(O,`version`,v),l(O,`type`,t.UniverInstanceType.UNIVER_SHEET),O=d([u(1,(0,t.Inject)(t.Injector)),u(2,t.ICommandService),u(3,t.IConfigService)],O),t.DataValidationOperator.BETWEEN,t.DataValidationOperator.EQUAL,t.DataValidationOperator.GREATER_THAN,t.DataValidationOperator.GREATER_THAN_OR_EQUAL,t.DataValidationOperator.LESS_THAN,t.DataValidationOperator.LESS_THAN_OR_EQUAL,t.DataValidationOperator.NOT_BETWEEN,t.DataValidationOperator.NOT_EQUAL;let k={[t.DataValidationOperator.BETWEEN]:`dataValidation.ruleName.between`,[t.DataValidationOperator.EQUAL]:`dataValidation.ruleName.equal`,[t.DataValidationOperator.GREATER_THAN]:`dataValidation.ruleName.greaterThan`,[t.DataValidationOperator.GREATER_THAN_OR_EQUAL]:`dataValidation.ruleName.greaterThanOrEqual`,[t.DataValidationOperator.LESS_THAN]:`dataValidation.ruleName.lessThan`,[t.DataValidationOperator.LESS_THAN_OR_EQUAL]:`dataValidation.ruleName.lessThanOrEqual`,[t.DataValidationOperator.NOT_BETWEEN]:`dataValidation.ruleName.notBetween`,[t.DataValidationOperator.NOT_EQUAL]:`dataValidation.ruleName.notEqual`,NONE:`dataValidation.ruleName.legal`},A={[t.DataValidationOperator.BETWEEN]:`dataValidation.errorMsg.between`,[t.DataValidationOperator.EQUAL]:`dataValidation.errorMsg.equal`,[t.DataValidationOperator.GREATER_THAN]:`dataValidation.errorMsg.greaterThan`,[t.DataValidationOperator.GREATER_THAN_OR_EQUAL]:`dataValidation.errorMsg.greaterThanOrEqual`,[t.DataValidationOperator.LESS_THAN]:`dataValidation.errorMsg.lessThan`,[t.DataValidationOperator.LESS_THAN_OR_EQUAL]:`dataValidation.errorMsg.lessThanOrEqual`,[t.DataValidationOperator.NOT_BETWEEN]:`dataValidation.errorMsg.notBetween`,[t.DataValidationOperator.NOT_EQUAL]:`dataValidation.errorMsg.notEqual`,NONE:`dataValidation.errorMsg.legal`},j={[t.DataValidationOperator.BETWEEN]:`dataValidation.textLength.errorMsg.between`,[t.DataValidationOperator.EQUAL]:`dataValidation.textLength.errorMsg.equal`,[t.DataValidationOperator.GREATER_THAN]:`dataValidation.textLength.errorMsg.greaterThan`,[t.DataValidationOperator.GREATER_THAN_OR_EQUAL]:`dataValidation.textLength.errorMsg.greaterThanOrEqual`,[t.DataValidationOperator.LESS_THAN]:`dataValidation.textLength.errorMsg.lessThan`,[t.DataValidationOperator.LESS_THAN_OR_EQUAL]:`dataValidation.textLength.errorMsg.lessThanOrEqual`,[t.DataValidationOperator.NOT_BETWEEN]:`dataValidation.textLength.errorMsg.notBetween`,[t.DataValidationOperator.NOT_EQUAL]:`dataValidation.textLength.errorMsg.notEqual`},M=[t.DataValidationOperator.BETWEEN,t.DataValidationOperator.NOT_BETWEEN],N=`{FORMULA1}`,P=`{FORMULA2}`,F=`{TYPE}`,I={[t.DataValidationOperator.BETWEEN]:`dataValidation.operators.between`,[t.DataValidationOperator.EQUAL]:`dataValidation.operators.equal`,[t.DataValidationOperator.GREATER_THAN]:`dataValidation.operators.greaterThan`,[t.DataValidationOperator.GREATER_THAN_OR_EQUAL]:`dataValidation.operators.greaterThanOrEqual`,[t.DataValidationOperator.LESS_THAN]:`dataValidation.operators.lessThan`,[t.DataValidationOperator.LESS_THAN_OR_EQUAL]:`dataValidation.operators.lessThanOrEqual`,[t.DataValidationOperator.NOT_BETWEEN]:`dataValidation.operators.notBetween`,[t.DataValidationOperator.NOT_EQUAL]:`dataValidation.operators.notEqual`},L=function(e){return e.DATE=`date`,e.TIME=`time`,e.DATETIME=`datetime`,e.LIST=`list`,e.MULTIPLE_LIST=`multipleList`,e.COLOR=`color`,e.CASCADE=`cascade`,e}({}),R=class{constructor(e,t){this.localeService=e,this.injector=t,l(this,`offsetFormulaByRange`,!0),l(this,`formulaInput`,void 0),l(this,`canvasRender`,null),l(this,`dropdownType`,void 0),l(this,`optionsInput`,void 0),l(this,`skipDefaultFontRender`,void 0)}get operatorNames(){return this.operators.map(e=>this.localeService.t(I[e]))}get titleStr(){return this.localeService.t(this.title)}generateRuleName(e){var t,n;if(!e.operator)return this.localeService.t(k.NONE).replace(F,this.titleStr);let r=this.localeService.t(k[e.operator]).replace(N,(t=e.formula1)==null?``:t).replace(P,(n=e.formula2)==null?``:n);return`${this.titleStr} ${r}`}generateRuleErrorMessage(e,t){var n,r;return e.operator?`${this.localeService.t(A[e.operator]).replace(N,(n=e.formula1)==null?``:n).replace(P,(r=e.formula2)==null?``:r)}`:this.localeService.t(A.NONE).replace(F,this.titleStr)}getExtraStyle(e,t,n,r,i){}getRuleFinalError(e,t){return e.showErrorMessage&&e.error?e.error:this.generateRuleErrorMessage(e,t)}isEmptyCellValue(e){return e===``||e==null}normalizeFormula(e,t,n){return{formula1:e.formula1,formula2:e.formula2}}async isValidType(e,t,n){return!0}transform(e,t,n){return e}async validatorIsEqual(e,t,n){let{formula1:r}=t,{value:i}=e;return Number.isNaN(r)?!0:i===r}async validatorIsNotEqual(e,t,n){let{formula1:r}=t;return Number.isNaN(r)?!0:e.value!==r}async validatorIsBetween(e,t,n){let{formula1:r,formula2:i}=t;if(Number.isNaN(r)||Number.isNaN(i))return!0;let a=Math.min(r,i),o=Math.max(r,i);return e.value>=a&&e.value<=o}async validatorIsNotBetween(e,t,n){let{formula1:r,formula2:i}=t;if(Number.isNaN(r)||Number.isNaN(i))return!0;let a=Math.min(r,i),o=Math.max(r,i);return e.value<a||e.value>o}async validatorIsGreaterThan(e,t,n){let{formula1:r}=t;return Number.isNaN(r)?!0:e.value>r}async validatorIsGreaterThanOrEqual(e,t,n){let{formula1:r}=t;return Number.isNaN(r)?!0:e.value>=r}async validatorIsLessThan(e,t,n){let{formula1:r}=t;return Number.isNaN(r)?!0:e.value<r}async validatorIsLessThanOrEqual(e,t,n){let{formula1:r}=t;return Number.isNaN(r)?!0:e.value<=r}async validator(e,n){let{value:r,unitId:i,subUnitId:a}=e,o=this.isEmptyCellValue(r),{allowBlank:s=!0,operator:c}=n;if(o)return s;let l=await this.parseFormula(n,i,a,e.row,e.column);if(!l.isFormulaValid||!await this.isValidType(e,l,n))return!1;if(!c)return!0;let u=this.transform(e,l,n);switch(c){case t.DataValidationOperator.BETWEEN:return this.validatorIsBetween(u,l,n);case t.DataValidationOperator.EQUAL:return this.validatorIsEqual(u,l,n);case t.DataValidationOperator.GREATER_THAN:return this.validatorIsGreaterThan(u,l,n);case t.DataValidationOperator.GREATER_THAN_OR_EQUAL:return this.validatorIsGreaterThanOrEqual(u,l,n);case t.DataValidationOperator.LESS_THAN:return this.validatorIsLessThan(u,l,n);case t.DataValidationOperator.LESS_THAN_OR_EQUAL:return this.validatorIsLessThanOrEqual(u,l,n);case t.DataValidationOperator.NOT_BETWEEN:return this.validatorIsNotBetween(u,l,n);case t.DataValidationOperator.NOT_EQUAL:return this.validatorIsNotEqual(u,l,n);default:throw Error(`Unknown operator.`)}}};R=d([u(0,(0,t.Inject)(t.LocaleService)),u(1,(0,t.Inject)(t.Injector))],R),e.AddDataValidationMutation=p,Object.defineProperty(e,`BaseDataValidator`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,`DataValidationModel`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,`DataValidationResourceController`,{enumerable:!0,get:function(){return g}}),e.DataValidatorDropdownType=L,e.DataValidatorRegistryScope=y,e.DataValidatorRegistryService=b,e.FORMULA1=N,e.FORMULA2=P,e.RemoveDataValidationMutation=m,e.TWO_FORMULA_OPERATOR_COUNT=M,e.TYPE=F,e.TextLengthErrorTitleMap=j,Object.defineProperty(e,`UniverDataValidationPlugin`,{enumerable:!0,get:function(){return O}}),e.UpdateDataValidationMutation=h,e.UpdateRuleType=a,e.getRuleOptions=i,e.getRuleSetting=r});
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@univerjs/data-validation",
3
- "version": "0.21.1",
3
+ "version": "0.22.0-insiders.20260513-09bbeca",
4
4
  "private": false,
5
- "description": "Data validation library for Univer",
6
- "author": "DreamNum <developer@univer.ai>",
5
+ "description": "Shared data validation models and rule services for Univer.",
6
+ "author": "DreamNum Co., Ltd. <developer@univer.ai>",
7
7
  "license": "Apache-2.0",
8
8
  "funding": {
9
9
  "type": "opencollective",
@@ -18,7 +18,11 @@
18
18
  "url": "https://github.com/dream-num/univer/issues"
19
19
  },
20
20
  "keywords": [
21
- "univer"
21
+ "univer",
22
+ "data-validation",
23
+ "validation",
24
+ "rules",
25
+ "plugin"
22
26
  ],
23
27
  "exports": {
24
28
  ".": {
@@ -48,15 +52,15 @@
48
52
  "rxjs": ">=7.0.0"
49
53
  },
50
54
  "dependencies": {
51
- "@univerjs/core": "0.21.1"
55
+ "@univerjs/core": "0.22.0-insiders.20260513-09bbeca"
52
56
  },
53
57
  "devDependencies": {
54
58
  "rxjs": "^7.8.2",
55
- "typescript": "^6.0.2",
56
- "vitest": "^4.1.4",
57
- "@univerjs-infra/shared": "0.21.1",
58
- "@univerjs/protocol": "0.21.1",
59
- "@univerjs/sheets": "0.21.1"
59
+ "typescript": "^6.0.3",
60
+ "vitest": "^4.1.5",
61
+ "@univerjs-infra/shared": "0.22.0",
62
+ "@univerjs/protocol": "0.22.0-insiders.20260513-09bbeca",
63
+ "@univerjs/sheets": "0.22.0-insiders.20260513-09bbeca"
60
64
  },
61
65
  "scripts": {
62
66
  "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