123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742 |
- import {
- BehaviorSubject,
- Bi,
- El,
- Fe,
- Mt,
- Ot,
- Pt,
- Ra,
- SE,
- Subject,
- Vr,
- Ze,
- _n,
- ar,
- cn,
- debounceTime,
- nt,
- nu,
- ot,
- re
- } from "./chunk-23V3HWTR.js";
- // node_modules/.pnpm/@univerjs+data-validation@0.5.5_@grpc+grpc-js@1.13.4_react@18.3.1_rxjs@7.8.1/node_modules/@univerjs/data-validation/lib/es/index.js
- var J = Object.defineProperty;
- var z = (t, e, r) => e in t ? J(t, e, { enumerable: true, configurable: true, writable: true, value: r }) : t[e] = r;
- var c = (t, e, r) => z(t, typeof e != "symbol" ? e + "" : e, r);
- function q(t) {
- return {
- type: t.type,
- operator: t.operator,
- formula1: t.formula1,
- formula2: t.formula2,
- allowBlank: t.allowBlank
- };
- }
- function H(t) {
- return {
- error: t.error,
- errorStyle: t.errorStyle,
- errorTitle: t.errorTitle,
- imeMode: t.imeMode,
- prompt: t.prompt,
- promptTitle: t.promptTitle,
- showDropDown: t.showDropDown,
- showErrorMessage: t.showErrorMessage,
- showInputMessage: t.showInputMessage,
- renderMode: t.renderMode,
- bizInfo: t.bizInfo
- };
- }
- var h = ((t) => (t[t.SETTING = 0] = "SETTING", t[t.RANGE = 1] = "RANGE", t[t.OPTIONS = 2] = "OPTIONS", t[t.ALL = 3] = "ALL", t))(h || {});
- var ne = Object.defineProperty;
- var ie = Object.getOwnPropertyDescriptor;
- var se = (t, e, r, a) => {
- for (var o = a > 1 ? void 0 : a ? ie(e, r) : e, n = t.length - 1, i; n >= 0; n--)
- (i = t[n]) && (o = (a ? i(e, r, o) : i(o)) || o);
- return a && o && ne(e, r, o), o;
- };
- var de = (t, e) => (r, a) => e(r, a, t);
- var m = class extends nt {
- constructor(e) {
- super();
- c(this, "_model", /* @__PURE__ */ new Map());
- c(this, "_ruleChange$", new Subject());
- c(this, "ruleChange$", this._ruleChange$.asObservable());
- c(this, "ruleChangeDebounce$", this.ruleChange$.pipe(debounceTime(20)));
- this._logService = e, this.disposeWithMe({
- dispose: () => {
- this._ruleChange$.complete();
- }
- });
- }
- _ensureMap(e, r) {
- this._model.has(e) || this._model.set(e, /* @__PURE__ */ new Map());
- const a = this._model.get(e);
- if (a.has(r))
- return a.get(r);
- const o = { map: /* @__PURE__ */ new Map(), list: [] };
- return a.set(r, o), o;
- }
- _addSubUnitRule(e, r, a) {
- const { map: o, list: n } = e, l = (Array.isArray(r) ? r : [r]).filter((d) => !o.has(d.uid));
- typeof a == "number" && a < n.length ? n.splice(a, 0, ...l) : n.push(...l), l.forEach((d) => {
- o.set(d.uid, d);
- });
- }
- _removeSubUnitRule(e, r) {
- const { map: a, list: o } = e, n = o.findIndex((i) => i.uid === r);
- n > -1 && (o.splice(n, 1), a.delete(r));
- }
- _updateSubUnitRule(e, r, a) {
- const { map: o, list: n } = e, i = o.get(r), l = n.findIndex((u) => r === u.uid);
- if (!i)
- throw new Error(`Data validation rule is not found, ruleId: ${r}.`);
- const d = { ...i };
- switch (a.type) {
- case h.RANGE: {
- d.ranges = a.payload;
- break;
- }
- case h.SETTING: {
- Object.assign(d, q(a.payload));
- break;
- }
- case h.OPTIONS: {
- Object.assign(d, H(a.payload));
- break;
- }
- case h.ALL: {
- Object.assign(d, a.payload);
- break;
- }
- }
- return n[l] = d, o.set(r, d), d;
- }
- _addRuleSideEffect(e, r, a, o) {
- if (!this._ensureMap(e, r).map.get(a.uid))
- return {
- rule: a,
- type: "add",
- unitId: e,
- subUnitId: r,
- source: o
- };
- }
- addRule(e, r, a, o, n) {
- try {
- const i = this._ensureMap(e, r), d = (Array.isArray(a) ? a : [a]).map((u) => this._addRuleSideEffect(e, r, u, o));
- this._addSubUnitRule(i, a, n), d.forEach((u) => {
- u && this._ruleChange$.next(u);
- });
- } catch (i) {
- this._logService.error(i);
- }
- }
- updateRule(e, r, a, o, n) {
- try {
- const i = this._ensureMap(e, r), l = re.deepClone(i.map.get(a));
- if (!l)
- throw new Error(`Data validation rule is not found, ruleId: ${a}.`);
- const d = this._updateSubUnitRule(i, a, o);
- this._ruleChange$.next({
- rule: d,
- type: "update",
- unitId: e,
- subUnitId: r,
- source: n,
- updatePayload: o,
- oldRule: l
- });
- } catch (i) {
- this._logService.error(i);
- }
- }
- removeRule(e, r, a, o) {
- try {
- const n = this._ensureMap(e, r), i = n.map.get(a);
- i && (this._removeSubUnitRule(n, a), this._ruleChange$.next({
- rule: i,
- type: "remove",
- unitId: e,
- subUnitId: r,
- source: o
- }));
- } catch (n) {
- this._logService.error(n);
- }
- }
- getRuleById(e, r, a) {
- return this._ensureMap(e, r).map.get(a);
- }
- getRuleIndex(e, r, a) {
- return this._ensureMap(e, r).list.findIndex((n) => n.uid === a);
- }
- getRules(e, r) {
- return [...this._ensureMap(e, r).list];
- }
- getUnitRules(e) {
- const r = this._model.get(e);
- if (!r)
- return [];
- const a = [];
- return r.forEach((o, n) => {
- a.push([n, o.list]);
- }), a;
- }
- deleteUnitRules(e) {
- this._model.delete(e);
- }
- getSubUnitIds(e) {
- var r, a;
- return Array.from((a = (r = this._model.get(e)) == null ? void 0 : r.keys()) != null ? a : []);
- }
- getAll() {
- return Array.from(this._model.keys()).map((e) => [e, this.getUnitRules(e)]);
- }
- };
- m = se([
- de(0, Mt)
- ], m);
- var le = Object.defineProperty;
- var ue = Object.getOwnPropertyDescriptor;
- var ce = (t, e, r, a) => {
- for (var o = a > 1 ? void 0 : a ? ue(e, r) : e, n = t.length - 1, i; n >= 0; n--)
- (i = t[n]) && (o = (a ? i(e, r, o) : i(o)) || o);
- return a && o && le(e, r, o), o;
- };
- var y = (t, e) => (r, a) => e(r, a, t);
- var pe = "SHEET_DATA_VALIDATION_PLUGIN";
- var I = class extends nt {
- constructor(t, e, r) {
- super(), this._resourceManagerService = t, this._univerInstanceService = e, this._dataValidationModel = r, this._initSnapshot();
- }
- _initSnapshot() {
- const t = (r) => {
- const a = this._dataValidationModel.getUnitRules(r), o = {};
- return a ? (a.forEach(([n, i]) => {
- o[n] = i;
- }), JSON.stringify(o)) : "";
- }, e = (r) => {
- if (!r)
- return {};
- try {
- return JSON.parse(r);
- } catch {
- return {};
- }
- };
- this.disposeWithMe(
- this._resourceManagerService.registerPluginResource({
- pluginName: pe,
- businesses: [Fe.UNIVER_SHEET],
- toJson: (r) => t(r),
- parseJson: (r) => e(r),
- onUnLoad: (r) => {
- this._dataValidationModel.deleteUnitRules(r);
- },
- onLoad: (r, a) => {
- Object.keys(a).forEach((o) => {
- a[o].forEach((i) => {
- this._dataValidationModel.addRule(r, o, i, "patched");
- });
- });
- }
- })
- );
- }
- };
- I = ce([
- y(0, Bi),
- y(1, _n),
- y(2, ot(m))
- ], I);
- var me = ((t) => (t.SHEET = "sheet", t))(me || {});
- var j = class {
- constructor() {
- c(this, "_validatorByScopes", /* @__PURE__ */ new Map());
- c(this, "_validatorMap", /* @__PURE__ */ new Map());
- c(this, "_validatorsChange$", new BehaviorSubject(void 0));
- c(this, "validatorsChange$", this._validatorsChange$.asObservable());
- }
- _addValidatorToScope(e, r) {
- this._validatorByScopes.has(r) || this._validatorByScopes.set(r, []);
- const a = this._validatorByScopes.get(r);
- if (a.findIndex((o) => o.id === e.id) > -1)
- throw new Error(`Validator item with the same id ${e.id} has already been added!`);
- a.push(e);
- }
- _removeValidatorFromScope(e, r) {
- const a = this._validatorByScopes.get(r);
- if (!a)
- return;
- const o = a.findIndex((n) => n.id === e.id);
- o > -1 && a.splice(o, 1);
- }
- register(e) {
- return this._validatorMap.set(e.id, e), Array.isArray(e.scopes) ? e.scopes.forEach((r) => {
- this._addValidatorToScope(e, r);
- }) : this._addValidatorToScope(e, e.scopes), this._validatorsChange$.next(), Ze(() => {
- this._validatorMap.delete(e.id), Array.isArray(e.scopes) ? e.scopes.forEach((r) => {
- this._removeValidatorFromScope(e, r);
- }) : this._removeValidatorFromScope(e, e.scopes), this._validatorsChange$.next();
- });
- }
- getValidatorItem(e) {
- return this._validatorMap.get(e);
- }
- getValidatorsByScope(e) {
- return this._validatorByScopes.get(e);
- }
- };
- var S = {
- type: ar.MUTATION,
- id: "data-validation.mutation.addRule",
- handler(t, e) {
- if (!e)
- return false;
- const { unitId: r, subUnitId: a, rule: o, index: n, source: i = "command" } = e;
- return t.get(m).addRule(r, a, o, i, n), true;
- }
- };
- var v = {
- type: ar.MUTATION,
- id: "data-validation.mutation.removeRule",
- handler(t, e) {
- if (!e)
- return false;
- const { unitId: r, subUnitId: a, ruleId: o, source: n = "command" } = e, i = t.get(m);
- return Array.isArray(o) ? o.forEach((l) => {
- i.removeRule(r, a, l, n);
- }) : i.removeRule(r, a, o, n), true;
- }
- };
- var f = {
- type: ar.MUTATION,
- id: "data-validation.mutation.updateRule",
- handler(t, e) {
- if (!e)
- return false;
- const { unitId: r, subUnitId: a, ruleId: o, payload: n, source: i = "command" } = e;
- return t.get(m).updateRule(r, a, o, n, i), true;
- }
- };
- var he = {
- type: ar.COMMAND,
- id: "data-validation.command.addRule",
- async handler(t, e) {
- if (t.get(Mt).error("[Deprecated]: `AddDataValidationCommand` is deprecated, please use `AddSheetDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
- return false;
- const { rule: a, unitId: o, subUnitId: n } = e, i = t.get(Pt), l = t.get(cn), d = {
- ...e,
- rule: {
- ...e.rule,
- ranges: [e.rule.range]
- }
- }, u = [{
- id: S.id,
- params: d
- }], p = [{
- id: v.id,
- params: {
- unitId: o,
- subUnitId: n,
- ruleId: a.uid
- }
- }];
- return l.pushUndoRedo({
- unitID: o,
- redoMutations: u,
- undoMutations: p
- }), await i.executeCommand(S.id, d), true;
- }
- };
- var _e = {
- type: ar.COMMAND,
- id: "data-validation.command.removeRule",
- handler(t, e) {
- if (t.get(Mt).error("[Deprecated]: `RemoveDataValidationCommand` is deprecated, please use `RemoveSheetDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
- return false;
- const { unitId: a, subUnitId: o, ruleId: n } = e, i = t.get(Pt), l = t.get(cn), d = t.get(m), u = [{
- id: v.id,
- params: e
- }], p = [{
- id: S.id,
- params: {
- unitId: a,
- subUnitId: o,
- rule: {
- ...d.getRuleById(a, o, n)
- },
- index: d.getRuleIndex(a, o, n)
- }
- }];
- return l.pushUndoRedo({
- undoMutations: p,
- redoMutations: u,
- unitID: e.unitId
- }), i.executeCommand(v.id, e), true;
- }
- };
- var Ee = {
- type: ar.COMMAND,
- id: "data-validation.command.updateDataValidationSetting",
- handler(t, e) {
- if (t.get(Mt).warn("[Deprecated]: `UpdateDataValidationOptionsCommand` is deprecated, please use `UpdateSheetDataValidationOptionsCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
- return false;
- const a = t.get(Pt), o = t.get(cn), n = t.get(m), { unitId: i, subUnitId: l, ruleId: d, options: u } = e, p = n.getRuleById(i, l, d);
- if (!p)
- return false;
- const _ = {
- unitId: i,
- subUnitId: l,
- ruleId: d,
- payload: {
- type: h.OPTIONS,
- payload: u
- }
- }, g = [{
- id: f.id,
- params: _
- }], M = {
- unitId: i,
- subUnitId: l,
- ruleId: d,
- payload: {
- type: h.OPTIONS,
- payload: H(p)
- }
- }, R = [{
- id: f.id,
- params: M
- }];
- return o.pushUndoRedo({
- unitID: i,
- redoMutations: g,
- undoMutations: R
- }), a.executeCommand(f.id, _), true;
- }
- };
- var ge = {
- type: ar.COMMAND,
- id: "data-validation.command.updateDataValidationOptions",
- handler(t, e) {
- if (t.get(Mt).error("[Deprecated]: `UpdateDataValidationSettingCommand` is deprecated, please use `UpdateSheetDataValidationSettingCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
- return false;
- const a = t.get(Pt), o = t.get(cn), n = t.get(m), i = t.get(j), { unitId: l, subUnitId: d, ruleId: u, setting: p } = e, _ = i.getValidatorItem(p.type);
- if (!_)
- return false;
- const g = n.getRuleById(l, d, u);
- if (!g)
- return false;
- const M = { ...g, ...p };
- if (!_.validatorFormula(M, l, d).success)
- return false;
- const R = {
- unitId: l,
- subUnitId: d,
- ruleId: u,
- payload: {
- type: h.SETTING,
- payload: {
- ...p,
- ..._.normalizeFormula(M, l, d)
- }
- }
- }, Q = [{
- id: f.id,
- params: R
- }], F = {
- unitId: l,
- subUnitId: d,
- ruleId: u,
- payload: {
- type: h.SETTING,
- payload: q(g)
- }
- }, W = [{
- id: f.id,
- params: F
- }];
- return o.pushUndoRedo({
- unitID: l,
- redoMutations: Q,
- undoMutations: W
- }), a.executeCommand(f.id, R), true;
- }
- };
- var fe = {
- type: ar.COMMAND,
- id: "data-validation.command.removeAll",
- handler(t, e) {
- if (t.get(Mt).error("[Deprecated]: `RemoveAllDataValidationCommand` is deprecated, please use `RemoveSheetAllDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
- return false;
- const { unitId: a, subUnitId: o } = e, n = t.get(Pt), i = t.get(m), l = t.get(cn), d = [...i.getRules(a, o)], u = {
- unitId: a,
- subUnitId: o,
- ruleId: d.map((g) => g.uid)
- }, p = [{
- id: v.id,
- params: u
- }], _ = [{
- id: S.id,
- params: {
- unitId: a,
- subUnitId: o,
- rule: d
- }
- }];
- return l.pushUndoRedo({
- redoMutations: p,
- undoMutations: _,
- unitID: a
- }), n.executeCommand(v.id, u), true;
- }
- };
- var ve = "data-validation.config";
- var U = {};
- var Ne = Object.defineProperty;
- var Te = Object.getOwnPropertyDescriptor;
- var Se = (t, e, r, a) => {
- for (var o = a > 1 ? void 0 : a ? Te(e, r) : e, n = t.length - 1, i; n >= 0; n--)
- (i = t[n]) && (o = (a ? i(e, r, o) : i(o)) || o);
- return a && o && Ne(e, r, o), o;
- };
- var L = (t, e) => (r, a) => e(r, a, t);
- var Ae = "UNIVER_DATA_VALIDATION_PLUGIN";
- var V;
- var D = (V = class extends Ra {
- constructor(t = U, e, r, a) {
- super(), this._config = t, this._injector = e, this._commandService = r, this._configService = a;
- const { ...o } = nu(
- {},
- U,
- this._config
- );
- this._configService.setConfig(ve, o);
- }
- onStarting() {
- [
- [m],
- [j],
- [I]
- ].forEach((t) => this._injector.add(t)), [
- // command
- he,
- fe,
- Ee,
- ge,
- _e,
- // mutation
- S,
- f,
- v
- ].forEach((t) => {
- this._commandService.registerCommand(t);
- });
- }
- onReady() {
- this._injector.get(I);
- }
- }, c(V, "pluginName", Ae), c(V, "type", Fe.UNIVER_SHEET), V);
- D = Se([
- L(1, ot(Ot)),
- L(2, Pt),
- L(3, SE)
- ], D);
- El.BETWEEN + "", El.EQUAL + "", El.GREATER_THAN + "", El.GREATER_THAN_OR_EQUAL + "", El.LESS_THAN + "", El.LESS_THAN_OR_EQUAL + "", El.NOT_BETWEEN + "", El.NOT_EQUAL + "";
- var Me = {
- [El.BETWEEN]: "dataValidation.ruleName.between",
- [El.EQUAL]: "dataValidation.ruleName.equal",
- [El.GREATER_THAN]: "dataValidation.ruleName.greaterThan",
- [El.GREATER_THAN_OR_EQUAL]: "dataValidation.ruleName.greaterThanOrEqual",
- [El.LESS_THAN]: "dataValidation.ruleName.lessThan",
- [El.LESS_THAN_OR_EQUAL]: "dataValidation.ruleName.lessThanOrEqual",
- [El.NOT_BETWEEN]: "dataValidation.ruleName.notBetween",
- [El.NOT_EQUAL]: "dataValidation.ruleName.notEqual"
- };
- var Re = {
- [El.BETWEEN]: "dataValidation.errorMsg.between",
- [El.EQUAL]: "dataValidation.errorMsg.equal",
- [El.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
- [El.GREATER_THAN_OR_EQUAL]: "dataValidation.errorMsg.greaterThanOrEqual",
- [El.LESS_THAN]: "dataValidation.errorMsg.lessThan",
- [El.LESS_THAN_OR_EQUAL]: "dataValidation.errorMsg.lessThanOrEqual",
- [El.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
- [El.NOT_EQUAL]: "dataValidation.errorMsg.notEqual"
- };
- var we = {
- [El.BETWEEN]: "dataValidation.textLength.errorMsg.between",
- [El.EQUAL]: "dataValidation.textLength.errorMsg.equal",
- [El.GREATER_THAN]: "dataValidation.textLength.errorMsg.greaterThan",
- [El.GREATER_THAN_OR_EQUAL]: "dataValidation.textLength.errorMsg.greaterThanOrEqual",
- [El.LESS_THAN]: "dataValidation.textLength.errorMsg.lessThan",
- [El.LESS_THAN_OR_EQUAL]: "dataValidation.textLength.errorMsg.lessThanOrEqual",
- [El.NOT_BETWEEN]: "dataValidation.textLength.errorMsg.notBetween",
- [El.NOT_EQUAL]: "dataValidation.textLength.errorMsg.notEqual"
- };
- var be = [
- El.BETWEEN,
- El.NOT_BETWEEN
- ];
- var Ve = Object.defineProperty;
- var Oe = Object.getOwnPropertyDescriptor;
- var Ie = (t, e, r, a) => {
- for (var o = a > 1 ? void 0 : a ? Oe(e, r) : e, n = t.length - 1, i; n >= 0; n--)
- (i = t[n]) && (o = (a ? i(e, r, o) : i(o)) || o);
- return a && o && Ve(e, r, o), o;
- };
- var w = (t, e) => (r, a) => e(r, a, t);
- var b = "{FORMULA1}";
- var C = "{FORMULA2}";
- var ye = {
- [El.BETWEEN]: "dataValidation.operators.between",
- [El.EQUAL]: "dataValidation.operators.equal",
- [El.GREATER_THAN]: "dataValidation.operators.greaterThan",
- [El.GREATER_THAN_OR_EQUAL]: "dataValidation.operators.greaterThanOrEqual",
- [El.LESS_THAN]: "dataValidation.operators.lessThan",
- [El.LESS_THAN_OR_EQUAL]: "dataValidation.operators.lessThanOrEqual",
- [El.NOT_BETWEEN]: "dataValidation.operators.notBetween",
- [El.NOT_EQUAL]: "dataValidation.operators.notEqual"
- };
- var P = class {
- // #endregion
- constructor(t, e) {
- c(this, "offsetFormulaByRange", true);
- c(this, "formulaInput");
- c(this, "canvasRender", null);
- c(this, "dropdown");
- c(this, "optionsInput");
- c(this, "skipDefaultFontRender");
- this.localeService = t, this.injector = e;
- }
- get operatorNames() {
- return this.operators.map((t) => this.localeService.t(ye[t]));
- }
- get titleStr() {
- return this.localeService.t(this.title);
- }
- generateRuleName(t) {
- var r, a;
- if (!t.operator)
- return this.titleStr;
- const e = this.localeService.t(Me[t.operator]).replace(b, (r = t.formula1) != null ? r : "").replace(C, (a = t.formula2) != null ? a : "");
- return `${this.titleStr} ${e}`;
- }
- generateRuleErrorMessage(t, e) {
- var a, o;
- return t.operator ? `${this.localeService.t(Re[t.operator]).replace(b, (a = t.formula1) != null ? a : "").replace(C, (o = t.formula2) != null ? o : "")}` : this.titleStr;
- }
- getExtraStyle(t, e, r, a, o) {
- }
- getRuleFinalError(t, e) {
- return t.showErrorMessage && t.error ? t.error : this.generateRuleErrorMessage(t, e);
- }
- isEmptyCellValue(t) {
- return t === "" || t === void 0 || t === null;
- }
- normalizeFormula(t, e, r) {
- return {
- formula1: t.formula1,
- formula2: t.formula2
- };
- }
- async isValidType(t, e, r) {
- return true;
- }
- transform(t, e, r) {
- return t;
- }
- async validatorIsEqual(t, e, r) {
- const { formula1: a } = e, { value: o } = t;
- return Number.isNaN(a) ? true : o === a;
- }
- async validatorIsNotEqual(t, e, r) {
- const { formula1: a } = e;
- return Number.isNaN(a) ? true : t.value !== a;
- }
- async validatorIsBetween(t, e, r) {
- const { formula1: a, formula2: o } = e;
- if (Number.isNaN(a) || Number.isNaN(o))
- return true;
- const n = Math.min(a, o), i = Math.max(a, o);
- return t.value >= n && t.value <= i;
- }
- async validatorIsNotBetween(t, e, r) {
- const { formula1: a, formula2: o } = e;
- if (Number.isNaN(a) || Number.isNaN(o))
- return true;
- const n = Math.min(a, o), i = Math.max(a, o);
- return t.value < n || t.value > i;
- }
- async validatorIsGreaterThan(t, e, r) {
- const { formula1: a } = e;
- return Number.isNaN(a) ? true : t.value > a;
- }
- async validatorIsGreaterThanOrEqual(t, e, r) {
- const { formula1: a } = e;
- return Number.isNaN(a) ? true : t.value >= a;
- }
- async validatorIsLessThan(t, e, r) {
- const { formula1: a } = e;
- return Number.isNaN(a) ? true : t.value < a;
- }
- async validatorIsLessThanOrEqual(t, e, r) {
- const { formula1: a } = e;
- return Number.isNaN(a) ? true : t.value <= a;
- }
- async validator(t, e) {
- const { value: r, unitId: a, subUnitId: o } = t, n = this.isEmptyCellValue(r), { allowBlank: i = true, operator: l } = e;
- if (n)
- return i;
- const d = await this.parseFormula(e, a, o, t.row, t.column);
- if (!d.isFormulaValid || !await this.isValidType(t, d, e))
- return false;
- if (!re.isDefine(l))
- return true;
- const u = this.transform(t, d, e);
- switch (l) {
- case El.BETWEEN:
- return this.validatorIsBetween(u, d, e);
- case El.EQUAL:
- return this.validatorIsEqual(u, d, e);
- case El.GREATER_THAN:
- return this.validatorIsGreaterThan(u, d, e);
- case El.GREATER_THAN_OR_EQUAL:
- return this.validatorIsGreaterThanOrEqual(u, d, e);
- case El.LESS_THAN:
- return this.validatorIsLessThan(u, d, e);
- case El.LESS_THAN_OR_EQUAL:
- return this.validatorIsLessThanOrEqual(u, d, e);
- case El.NOT_BETWEEN:
- return this.validatorIsNotBetween(u, d, e);
- case El.NOT_EQUAL:
- return this.validatorIsNotEqual(u, d, e);
- default:
- throw new Error("Unknown operator.");
- }
- }
- };
- P = Ie([
- w(0, ot(Vr)),
- w(1, ot(Ot))
- ], P);
- export {
- q,
- H,
- h,
- m,
- I,
- me,
- j,
- S,
- v,
- f,
- D,
- we,
- be,
- P
- };
- //# sourceMappingURL=chunk-757T4GCY.js.map
|