@omegagrid/grid-core 0.11.32 → 0.11.33

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.
Files changed (36) hide show
  1. package/dist/calculations/context.d.ts.map +1 -1
  2. package/dist/calculations/context.js +6 -5
  3. package/dist/calculations/context.js.map +1 -1
  4. package/dist/calculations/functions/dates.d.ts.map +1 -1
  5. package/dist/calculations/functions/dates.js +4 -4
  6. package/dist/calculations/functions/dates.js.map +1 -1
  7. package/dist/calculations/functions/lookup.d.ts.map +1 -1
  8. package/dist/calculations/functions/lookup.js +2 -1
  9. package/dist/calculations/functions/lookup.js.map +1 -1
  10. package/dist/calculations/index.d.ts +1 -0
  11. package/dist/calculations/index.d.ts.map +1 -1
  12. package/dist/calculations/index.js +1 -0
  13. package/dist/calculations/index.js.map +1 -1
  14. package/dist/calculations/values.d.ts +6 -0
  15. package/dist/calculations/values.d.ts.map +1 -0
  16. package/dist/calculations/values.js +14 -0
  17. package/dist/calculations/values.js.map +1 -0
  18. package/dist/model/cellModel.d.ts +9 -0
  19. package/dist/model/cellModel.d.ts.map +1 -1
  20. package/dist/model/cellModel.js +81 -17
  21. package/dist/model/cellModel.js.map +1 -1
  22. package/dist/model/filterModel.d.ts.map +1 -1
  23. package/dist/model/filterModel.js +30 -13
  24. package/dist/model/filterModel.js.map +1 -1
  25. package/dist/model/options.d.ts +15 -0
  26. package/dist/model/options.d.ts.map +1 -1
  27. package/dist/model/options.js +18 -0
  28. package/dist/model/options.js.map +1 -1
  29. package/dist/model/rowModel.d.ts.map +1 -1
  30. package/dist/model/rowModel.js +4 -3
  31. package/dist/model/rowModel.js.map +1 -1
  32. package/dist/model/validations.d.ts +3 -0
  33. package/dist/model/validations.d.ts.map +1 -1
  34. package/dist/model/validations.js +10 -5
  35. package/dist/model/validations.js.map +1 -1
  36. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"rowModel.js","sourceRoot":"","sources":["../../src/model/rowModel.ts"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,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3E,CAAC;IAED,qBAAqB;QACpB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAClF,CAAC;CAED","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { CellRange, encodeRow } from \"../common/range\";\nimport { CellModel, CellSource } from \"./cellModel\";\nimport { GridModel } from \"./gridModel\";\nimport { tree, utils } from \"@omegagrid/core\";\nimport { ElementModel, ElementSource } from \"./elementModel\";\n\n// /** Source object type for row header item */\n// export type RowHeaderModel = {\n// \tlabel?: string;\n// \tcolspan?: number;\n// \trowspan?: number;\n// \twidth?: number;\n// };\n\n/** Source object type for grid row */\nexport type RowSource = {\n\th?: number|'auto', // height\n\tdata?: Record<string|number, any>,\n\t/** if row priority is higher then column priority, row properties has precedence over column properties */\n\tpriority?: number,\n} & tree.TreeNodeSource & ElementSource\n\nexport class RowModel extends tree.TreeNodeMixin(ElementModel) {\n\n\torigIndex: number;\n\t\n\tprivate _singleCell: CellModel;\n\n\tprivate _cells: CellModel[];\n\tget cells() { return this._cells }\n\t\n\tprivate _data: Record<string|number, any>;\n\tget data() { return this._data }\n\tset data(v : Record<string|number, any>) { this._data = v }\n\t\n\tprivate _height: number;\n\tget height() { return this._height ?? this.model.options.rowHeight }\n\tset height(value: number) { this._height = value }\n\t\n\tprivate _priority: number;\n\tget priority() { return this._priority }\n\tset priority(value: number) { this._priority = value }\n\n\tget address() { return encodeRow(this.index) }\n\tget range() { return new CellRange(null, this.index, null, this.index) }\n\n\tget hasFormula() { return !!this._formula }\n\tget formula() { return this._formula }\n\tset formula(v: string) {\n\t\tsuper.formula = v;\n\t\tthis.model.columns.forEach(col => this.cell(col.index).refreshFormula());\n\t}\n\n\tget values() { return this.model.columns.map(col => this.cell(col.index).value) }\n\n\tisCellInitialized = (c: number) => !!this.cells[c];\n\t\n\tcell(c: number, source?: CellSource) : CellModel {\n\t\tif (this.model.options.singleCellModel) {\n\t\t\tif (!this._singleCell) this._singleCell = new CellModel(this.model, {c: c, r: this.index});\n\t\t\tthis._singleCell.row = this;\n\t\t\tthis._singleCell.column = this.model.columns[c];\n\t\t\treturn this._singleCell;\n\t\t}\n\n\t\tlet cell = this._cells[c];\n\t\tif ((source || !cell) && this.model.columns[c]) {\n\t\t\tcell = new CellModel(this.model, source ?? {c: c, r: this.index});\n\t\t\tif (this._data) {\n\t\t\t\tconst dataField = this.model.columns[c].data;\n\t\t\t\tif (dataField != null) {\n\t\t\t\t\tconst d = this._data[dataField];\n\t\t\t\t\tif (utils.isObject(d)) {\n\t\t\t\t\t\tif ((d as CellSource).comment) {\n\t\t\t\t\t\t\tthis.model.comments.set(cell.address, [(d as CellSource).comment]);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (d.cs > 1 || d.rs > 1) {\n\t\t\t\t\t\t\tthis.model.merges.add({r: this.index, c: c, cs: d.cs || 1, rs: d.rs || 1});\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tcell.populate(d);\n\t\t\t\t\t} else if (!cell.hasValue) {\n\t\t\t\t\t\t// keep display value from cell source - value assignment resets it\n\t\t\t\t\t\tconst dv = cell.displayValue;\n\t\t\t\t\t\tcell.value = d;\n\t\t\t\t\t\tif (dv != null) cell.displayValue = dv;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (cell.name) this.model.names.set(cell.name, cell.range);\n\t\t\tthis._cells[c] = cell;\n\t\t}\n\t\treturn cell;\n\t}\n\n\tconstructor(model: GridModel, source?: RowSource) {\n\t\tsuper(model, source);\n\t\tthis._cells = [];\n\t\tif (this._priority == null) this._priority = model.options.rowPriority;\n\t}\n\n\tpopulate(source: RowSource) {\n\t\tsuper.populate(source);\n\t\tthis._height = source.h == null || source.h == 'auto' ? this.model.options.rowHeight : source.h;\n\n\t\tif (source.data) {\n\t\t\tif (Array.isArray(source.data)) this._data = [...source.data];\n\t\t\telse this._data = {...source.data};\n\t\t}\n\n\t\tif (source.priority != null) this._priority = source.priority;\n\t}\n\n\tgetSourceData() {\n\t\tconst data = super.getSourceData() as RowSource;\n\t\t//if (this._data != null) data.data = this._data;\n\t\tif (this._height != null && this._height != this.model.options.rowHeight) data.h = this._height;\n\t\treturn data;\n\t}\n\n\texpand(unhide?: boolean) {\n\t\tsuper.expand(unhide);\n\t\tthis.model.indexVisibleRows();\n\t}\n\n\tcollapse() {\n\t\tsuper.collapse();\n\t\tthis.model.indexVisibleRows();\n\t}\n\n\tget prev() { return this.model.rows[this.index - 1] }\n\tget next() { return this.model.rows[this.index + 1] }\n\n\tget prevVisible() : RowModel {\n\t\tlet prev = this.prev;\n\t\twhile (prev && !prev.visible) prev = prev.prev;\n\t\treturn prev;\n\t}\n\n\tget nextVisible() : RowModel {\n\t\tlet next = this.next;\n\t\twhile (next && !next.visible) next = next.next;\n\t\treturn next;\n\t}\n\n\t/**\n\t * Checks if cell has formula, even for uninitialized cells\n\t * @param c number\n\t * @returns boolean\n\t */\n\thasCellFormula(c: number) {\n\t\treturn (this.cells[c] && this.cells[c].hasFormula)\n\t\t\t|| (this._data && this._data[this.model.columns[c].data] && this._data[this.model.columns[c].data].f);\n\t}\n\n\thasCellName(c: number) {\n\t\treturn (this.cells[c] && this.cells[c].name != null)\n\t\t\t|| (this._data && this._data[this.model.columns[c].data] && this._data[this.model.columns[c].data].name != null);\n\t}\n\n\tinsertColumns(index: number, count: number, shiftFormulas = false) {\n\t\tlet cell: CellModel;\n\t\tconst columns = this.model.columns.length;\n\t\tconst calculations = this.model.calculations;\n\n\t\tif (shiftFormulas) {\n\t\t\tfor (let c = 0; c < columns; c++) {\n\t\t\t\tif (this.hasCellFormula(c)) {\n\t\t\t\t\tcell = this.cell(c);\n\t\t\t\t\tcell.formula = calculations.getFormula(cell).shift({\n\t\t\t\t\t\tindex: index, \n\t\t\t\t\t\toffset: count, \n\t\t\t\t\t\tdirection: 'right'\n\t\t\t\t\t}).createFormulaString(false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (index < this.cells.length) this.cells.splice(index, 0, ...Array(count).fill(null));\n\t}\n\n\tdeleteColumns(index: number, count: number, shiftFormulas = false) {\n\t\tlet cell: CellModel;\n\t\tconst columns = this.model.columns.length;\n\t\tconst calculations = this.model.calculations;\n\n\t\tif (shiftFormulas) {\n\t\t\tfor (let c = 0; c < columns; c++) {\n\t\t\t\tif (this.hasCellFormula(c)) {\n\t\t\t\t\tcell = this.cell(c);\n\t\t\t\t\tcell.formula = calculations.getFormula(cell).shift({\n\t\t\t\t\t\tindex: index, \n\t\t\t\t\t\toffset: count,\n\t\t\t\t\t\tdirection: 'left'\n\t\t\t\t\t}).createFormulaString(false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn index < this.cells.length ? this.cells.splice(index, count) : null;\n\t}\n\n\tclearCalculatedValues() {\n\t\tthis.cells.forEach(cell => cell && this.model.calculations.refreshFormula(cell));\n\t}\n\n}"]}
1
+ {"version":3,"file":"rowModel.js","sourceRoot":"","sources":["../../src/model/rowModel.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAc,YAAY,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAiB,MAAM,gBAAgB,CAAC;AAkB7D,MAAM,OAAO,QAAS,SAAQ,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC;IAO7D,IAAI,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IAGlC,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,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AAa,CAAC,KAAa,EAAE,KAAa,EAAE,aAAa,GAAG,KAAK;QAChE,IAAI,IAAe,CAAC;QACpB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAC1C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;QAE7C,IAAI,aAAa,EAAE,CAAC;YACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;gBAClC,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC5B,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBACpB,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;wBAClD,KAAK,EAAE,KAAK;wBACZ,MAAM,EAAE,KAAK;wBACb,SAAS,EAAE,MAAM;qBACjB,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;gBAC/B,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3E,CAAC;IAED,qBAAqB;QACpB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAClF,CAAC;CAED","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { CellRange, encodeRow } from \"../common/range\";\nimport { CellModel, CellSource, isCellSource } from \"./cellModel\";\nimport { GridModel } from \"./gridModel\";\nimport { tree } from \"@omegagrid/core\";\nimport { ElementModel, ElementSource } from \"./elementModel\";\n\n// /** Source object type for row header item */\n// export type RowHeaderModel = {\n// \tlabel?: string;\n// \tcolspan?: number;\n// \trowspan?: number;\n// \twidth?: number;\n// };\n\n/** Source object type for grid row */\nexport type RowSource = {\n\th?: number|'auto', // height\n\tdata?: Record<string|number, any>,\n\t/** if row priority is higher then column priority, row properties has precedence over column properties */\n\tpriority?: number,\n} & tree.TreeNodeSource & ElementSource\n\nexport class RowModel extends tree.TreeNodeMixin(ElementModel) {\n\n\torigIndex: number;\n\t\n\tprivate _singleCell: CellModel;\n\n\tprivate _cells: CellModel[];\n\tget cells() { return this._cells }\n\t\n\tprivate _data: Record<string|number, any>;\n\tget data() { return this._data }\n\tset data(v : Record<string|number, any>) { this._data = v }\n\t\n\tprivate _height: number;\n\tget height() { return this._height ?? this.model.options.rowHeight }\n\tset height(value: number) { this._height = value }\n\t\n\tprivate _priority: number;\n\tget priority() { return this._priority }\n\tset priority(value: number) { this._priority = value }\n\n\tget address() { return encodeRow(this.index) }\n\tget range() { return new CellRange(null, this.index, null, this.index) }\n\n\tget hasFormula() { return !!this._formula }\n\tget formula() { return this._formula }\n\tset formula(v: string) {\n\t\tsuper.formula = v;\n\t\tthis.model.columns.forEach(col => this.cell(col.index).refreshFormula());\n\t}\n\n\tget values() { return this.model.columns.map(col => this.cell(col.index).value) }\n\n\tisCellInitialized = (c: number) => !!this.cells[c];\n\t\n\tcell(c: number, source?: CellSource) : CellModel {\n\t\tif (this.model.options.singleCellModel) {\n\t\t\tif (!this._singleCell) this._singleCell = new CellModel(this.model, {c: c, r: this.index});\n\t\t\tthis._singleCell.row = this;\n\t\t\tthis._singleCell.column = this.model.columns[c];\n\t\t\treturn this._singleCell;\n\t\t}\n\n\t\tlet cell = this._cells[c];\n\t\tif ((source || !cell) && this.model.columns[c]) {\n\t\t\tcell = new CellModel(this.model, source ?? {c: c, r: this.index});\n\t\t\tif (this._data) {\n\t\t\t\tconst dataField = this.model.columns[c].data;\n\t\t\t\tif (dataField != null) {\n\t\t\t\t\tconst d = this._data[dataField];\n\t\t\t\t\t// an object is a cell source, except a Date: the value of a date and time cell\n\t\t\t\t\tif (isCellSource(d)) {\n\t\t\t\t\t\tif ((d as CellSource).comment) {\n\t\t\t\t\t\t\tthis.model.comments.set(cell.address, [(d as CellSource).comment]);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (d.cs > 1 || d.rs > 1) {\n\t\t\t\t\t\t\tthis.model.merges.add({r: this.index, c: c, cs: d.cs || 1, rs: d.rs || 1});\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tcell.populate(d);\n\t\t\t\t\t} else if (!cell.hasValue) {\n\t\t\t\t\t\t// keep display value from cell source - value assignment resets it\n\t\t\t\t\t\tconst dv = cell.displayValue;\n\t\t\t\t\t\tcell.value = d;\n\t\t\t\t\t\tif (dv != null) cell.displayValue = dv;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (cell.name) this.model.names.set(cell.name, cell.range);\n\t\t\tthis._cells[c] = cell;\n\t\t}\n\t\treturn cell;\n\t}\n\n\tconstructor(model: GridModel, source?: RowSource) {\n\t\tsuper(model, source);\n\t\tthis._cells = [];\n\t\tif (this._priority == null) this._priority = model.options.rowPriority;\n\t}\n\n\tpopulate(source: RowSource) {\n\t\tsuper.populate(source);\n\t\tthis._height = source.h == null || source.h == 'auto' ? this.model.options.rowHeight : source.h;\n\n\t\tif (source.data) {\n\t\t\tif (Array.isArray(source.data)) this._data = [...source.data];\n\t\t\telse this._data = {...source.data};\n\t\t}\n\n\t\tif (source.priority != null) this._priority = source.priority;\n\t}\n\n\tgetSourceData() {\n\t\tconst data = super.getSourceData() as RowSource;\n\t\t//if (this._data != null) data.data = this._data;\n\t\tif (this._height != null && this._height != this.model.options.rowHeight) data.h = this._height;\n\t\treturn data;\n\t}\n\n\texpand(unhide?: boolean) {\n\t\tsuper.expand(unhide);\n\t\tthis.model.indexVisibleRows();\n\t}\n\n\tcollapse() {\n\t\tsuper.collapse();\n\t\tthis.model.indexVisibleRows();\n\t}\n\n\tget prev() { return this.model.rows[this.index - 1] }\n\tget next() { return this.model.rows[this.index + 1] }\n\n\tget prevVisible() : RowModel {\n\t\tlet prev = this.prev;\n\t\twhile (prev && !prev.visible) prev = prev.prev;\n\t\treturn prev;\n\t}\n\n\tget nextVisible() : RowModel {\n\t\tlet next = this.next;\n\t\twhile (next && !next.visible) next = next.next;\n\t\treturn next;\n\t}\n\n\t/**\n\t * Checks if cell has formula, even for uninitialized cells\n\t * @param c number\n\t * @returns boolean\n\t */\n\thasCellFormula(c: number) {\n\t\treturn (this.cells[c] && this.cells[c].hasFormula)\n\t\t\t|| (this._data && this._data[this.model.columns[c].data] && this._data[this.model.columns[c].data].f);\n\t}\n\n\thasCellName(c: number) {\n\t\treturn (this.cells[c] && this.cells[c].name != null)\n\t\t\t|| (this._data && this._data[this.model.columns[c].data] && this._data[this.model.columns[c].data].name != null);\n\t}\n\n\tinsertColumns(index: number, count: number, shiftFormulas = false) {\n\t\tlet cell: CellModel;\n\t\tconst columns = this.model.columns.length;\n\t\tconst calculations = this.model.calculations;\n\n\t\tif (shiftFormulas) {\n\t\t\tfor (let c = 0; c < columns; c++) {\n\t\t\t\tif (this.hasCellFormula(c)) {\n\t\t\t\t\tcell = this.cell(c);\n\t\t\t\t\tcell.formula = calculations.getFormula(cell).shift({\n\t\t\t\t\t\tindex: index, \n\t\t\t\t\t\toffset: count, \n\t\t\t\t\t\tdirection: 'right'\n\t\t\t\t\t}).createFormulaString(false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (index < this.cells.length) this.cells.splice(index, 0, ...Array(count).fill(null));\n\t}\n\n\tdeleteColumns(index: number, count: number, shiftFormulas = false) {\n\t\tlet cell: CellModel;\n\t\tconst columns = this.model.columns.length;\n\t\tconst calculations = this.model.calculations;\n\n\t\tif (shiftFormulas) {\n\t\t\tfor (let c = 0; c < columns; c++) {\n\t\t\t\tif (this.hasCellFormula(c)) {\n\t\t\t\t\tcell = this.cell(c);\n\t\t\t\t\tcell.formula = calculations.getFormula(cell).shift({\n\t\t\t\t\t\tindex: index, \n\t\t\t\t\t\toffset: count,\n\t\t\t\t\t\tdirection: 'left'\n\t\t\t\t\t}).createFormulaString(false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn index < this.cells.length ? this.cells.splice(index, count) : null;\n\t}\n\n\tclearCalculatedValues() {\n\t\tthis.cells.forEach(cell => cell && this.model.calculations.refreshFormula(cell));\n\t}\n\n}"]}
@@ -1,5 +1,8 @@
1
1
  import { CellValidation, CellValidationSource } from "../types";
2
2
  import { CellModel } from "./cellModel";
3
3
  export declare function normalizeCellValidation(cellValidation: CellValidationSource): CellValidation;
4
+ /** Whether the value passes the validation of the cell (its pattern and validate function), allowInvalid aside */
5
+ export declare function isValidValue(cell: CellModel, value: unknown): boolean;
6
+ /** Whether the cell takes the value: a valid one, any with allowInvalid */
4
7
  export declare function validateValue(cell: CellModel, newValue: unknown): boolean;
5
8
  //# sourceMappingURL=validations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../src/model/validations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,oBAAoB,GAAG,cAAc,CAK5F;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAczE"}
1
+ {"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../src/model/validations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,oBAAoB,GAAG,cAAc,CAK5F;AAED,kHAAkH;AAClH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAarE;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAGzE"}
@@ -4,21 +4,26 @@ export function normalizeCellValidation(cellValidation) {
4
4
  }
5
5
  return cellValidation;
6
6
  }
7
- export function validateValue(cell, newValue) {
7
+ /** Whether the value passes the validation of the cell (its pattern and validate function), allowInvalid aside */
8
+ export function isValidValue(cell, value) {
8
9
  const validation = cell.validation;
9
10
  if (!validation)
10
11
  return true;
11
- if (validation.allowInvalid)
12
- return true;
13
12
  let valid = true;
14
13
  if (validation.pattern) {
15
- if (!validation.pattern.test((newValue ?? '').toString()))
14
+ if (!validation.pattern.test((value ?? '').toString()))
16
15
  valid = false;
17
16
  }
18
17
  if (validation.validate) {
19
- if (!validation.validate(cell, newValue))
18
+ if (!validation.validate(cell, value))
20
19
  valid = false;
21
20
  }
22
21
  return valid;
23
22
  }
23
+ /** Whether the cell takes the value: a valid one, any with allowInvalid */
24
+ export function validateValue(cell, newValue) {
25
+ if (cell.validation?.allowInvalid)
26
+ return true;
27
+ return isValidValue(cell, newValue);
28
+ }
24
29
  //# sourceMappingURL=validations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validations.js","sourceRoot":"","sources":["../../src/model/validations.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,uBAAuB,CAAC,cAAoC;IAC3E,IAAI,cAAc,CAAC,OAAO,IAAI,OAAO,cAAc,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC1E,cAAc,CAAC,OAAO,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,cAAgC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAe,EAAE,QAAiB;IAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACnC,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7B,IAAI,UAAU,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IAEzC,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAE,QAAmB,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;YAAE,KAAK,GAAG,KAAK,CAAC;IACtF,CAAC;IAED,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;YAAE,KAAK,GAAG,KAAK,CAAC;IACzD,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { CellValidation, CellValidationSource } from \"../types\";\nimport { CellModel } from \"./cellModel\";\n\nexport function normalizeCellValidation(cellValidation: CellValidationSource): CellValidation {\n\tif (cellValidation.pattern && typeof cellValidation.pattern === 'string') {\n\t\tcellValidation.pattern = new RegExp(cellValidation.pattern);\n\t}\n\treturn cellValidation as CellValidation;\n}\n\nexport function validateValue(cell: CellModel, newValue: unknown): boolean {\n\tconst validation = cell.validation;\n\tif (!validation) return true;\n\tif (validation.allowInvalid) return true;\n\n\tlet valid = true;\n\tif (validation.pattern) {\n\t\tif (!validation.pattern.test(((newValue as string) ?? '').toString())) valid = false;\n\t}\n\n\tif (validation.validate) {\n\t\tif (!validation.validate(cell, newValue)) valid = false;\n\t}\n\treturn valid;\n}\n"]}
1
+ {"version":3,"file":"validations.js","sourceRoot":"","sources":["../../src/model/validations.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,uBAAuB,CAAC,cAAoC;IAC3E,IAAI,cAAc,CAAC,OAAO,IAAI,OAAO,cAAc,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC1E,cAAc,CAAC,OAAO,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,cAAgC,CAAC;AACzC,CAAC;AAED,kHAAkH;AAClH,MAAM,UAAU,YAAY,CAAC,IAAe,EAAE,KAAc;IAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACnC,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAE7B,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAE,KAAgB,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;YAAE,KAAK,GAAG,KAAK,CAAC;IACnF,CAAC;IAED,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;YAAE,KAAK,GAAG,KAAK,CAAC;IACtD,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,aAAa,CAAC,IAAe,EAAE,QAAiB;IAC/D,IAAI,IAAI,CAAC,UAAU,EAAE,YAAY;QAAE,OAAO,IAAI,CAAC;IAC/C,OAAO,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import { CellValidation, CellValidationSource } from \"../types\";\nimport { CellModel } from \"./cellModel\";\n\nexport function normalizeCellValidation(cellValidation: CellValidationSource): CellValidation {\n\tif (cellValidation.pattern && typeof cellValidation.pattern === 'string') {\n\t\tcellValidation.pattern = new RegExp(cellValidation.pattern);\n\t}\n\treturn cellValidation as CellValidation;\n}\n\n/** Whether the value passes the validation of the cell (its pattern and validate function), allowInvalid aside */\nexport function isValidValue(cell: CellModel, value: unknown): boolean {\n\tconst validation = cell.validation;\n\tif (!validation) return true;\n\n\tlet valid = true;\n\tif (validation.pattern) {\n\t\tif (!validation.pattern.test(((value as string) ?? '').toString())) valid = false;\n\t}\n\n\tif (validation.validate) {\n\t\tif (!validation.validate(cell, value)) valid = false;\n\t}\n\treturn valid;\n}\n\n/** Whether the cell takes the value: a valid one, any with allowInvalid */\nexport function validateValue(cell: CellModel, newValue: unknown): boolean {\n\tif (cell.validation?.allowInvalid) return true;\n\treturn isValidValue(cell, newValue);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/grid-core",
3
- "version": "0.11.32",
3
+ "version": "0.11.33",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Grid model, no ui components",
6
6
  "main": "./dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "generate-functions-docs": "node ./scripts/generate-functions-docs.cjs"
29
29
  },
30
30
  "dependencies": {
31
- "@omegagrid/core": "^0.11.32",
32
- "@omegagrid/localize": "^0.11.32",
31
+ "@omegagrid/core": "^0.11.33",
32
+ "@omegagrid/localize": "^0.11.33",
33
33
  "@stdlib/stats": "^0.0.13",
34
34
  "color": "^4.2.3",
35
35
  "date-fns": "^3.2.0",