@omegagrid/grid 0.10.76 → 0.10.78

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.
@@ -1 +1 @@
1
- {"version":3,"file":"baseEditor.d.ts","sourceRoot":"","sources":["../../src/editors/baseEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgC,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAO,MAAM,KAAK,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,qBAAa,WAAY,SAAQ,KAAK;CAAI;AAE1C,8BAAsB,UAAW,SAAQ,UAAU;IAElD,MAAM,CAAC,UAAU,0BAef;IAEF,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC;IACrB,SAAS,CAAC,MAAM,UAAS;IACzB,SAAS,CAAC,UAAU,EAAE,oBAAoB,CAAC;IAC3C,SAAS,CAAC,eAAe,EAAE,SAAS,CAAC;IACrC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC;IAEhC,SAAS,CAAC,KAAK,UAAS;IACxB,IAAI,MAAM,YAAwB;IAElC,SAAS,CAAC,MAAM,UAAQ;IACxB,IAAI,OAAO,YAAyB;IAEpC,QAAQ;;IAaR,QAAQ,CAAC,QAAQ,IAAK,OAAO;IAE7B,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAI,IAAI;IAExC,eAAe,IAAK,MAAM;IAI1B,IAAI;IAaJ,iBAAiB;IAKjB,aAAa;IAOb,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,GAAE,OAAc,EAAE,cAAc,UAAO;IAiBpE,MAAM;IAWN,KAAK;IAaL,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAI,IAAI;IAKhC,UAAU,IAAK,IAAI;CAInB"}
1
+ {"version":3,"file":"baseEditor.d.ts","sourceRoot":"","sources":["../../src/editors/baseEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgC,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAO,MAAM,KAAK,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,qBAAa,WAAY,SAAQ,KAAK;CAAI;AAE1C,8BAAsB,UAAW,SAAQ,UAAU;IAElD,MAAM,CAAC,UAAU,0BAef;IAEF,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC;IACrB,SAAS,CAAC,MAAM,UAAS;IACzB,SAAS,CAAC,UAAU,EAAE,oBAAoB,CAAC;IAC3C,SAAS,CAAC,eAAe,EAAE,SAAS,CAAC;IACrC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC;IAEhC,SAAS,CAAC,KAAK,UAAS;IACxB,IAAI,MAAM,YAAwB;IAElC,SAAS,CAAC,MAAM,UAAQ;IACxB,IAAI,OAAO,YAAyB;IAEpC,QAAQ;;IAaR,QAAQ,CAAC,QAAQ,IAAK,OAAO;IAE7B,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAI,IAAI;IAExC,eAAe,IAAK,MAAM;IAI1B,IAAI;IAaJ,iBAAiB;IAKjB,aAAa;IAOb,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,GAAE,OAAc,EAAE,cAAc,UAAO;IAiBpE,MAAM;IAWN,KAAK;IAeL,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAI,IAAI;IAKhC,UAAU,IAAK,IAAI;CAInB"}
@@ -79,7 +79,9 @@ export class BaseEditor extends LitElement {
79
79
  dom.hideElement(this);
80
80
  this.grid.table.renderBodyCell(this.activeCellModel);
81
81
  this.grid.selecting.showSelector();
82
- this.grid.focus();
82
+ // preventScroll: focus would otherwise natively scroll overflow:hidden
83
+ // ancestors (e.g. og-container) that manage scrolling themselves
84
+ this.grid.focus({ preventScroll: true });
83
85
  this._open = false;
84
86
  this.grid.editing.endEdit();
85
87
  }
@@ -1 +1 @@
1
- {"version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AC,KAAK,EAAE,CAAC;YAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,QAAQ,CAAC,IAAe;QACvB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,UAAU;QACT,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IACnD,CAAC;;AA3HM,qBAAU,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;EAetB,AAfgB,CAef","sourcesContent":["import { CellModel, CellValueType, validateValue } from \"@omegagrid/grid-core\";\nimport { LitElement, css } from 'lit';\nimport { dom } from \"@omegagrid/core\";\nimport { Grid } from \"../ui/grid\";\n\nexport class EditorEvent extends Event { }\n\nexport abstract class BaseEditor extends LitElement {\n\n\tstatic baseStyles = css`\n\t\t* { box-sizing: border-box }\n\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tbackground: var(--og-cell-background);\n\t\t\tz-index: 200;\n\t\t}\n\n\t\t:host(.invalid) input {\n\t\t\tcolor: #ff0000;\n\t\t\tborder: 1px solid #ff0000;\n\t\t}\n\t`;\n\n\tprotected grid: Grid;\n\tprotected cancel = false;\n\tprotected activeCell: HTMLTableCellElement;\n\tprotected activeCellModel: CellModel;\n\tprotected initialValue: unknown;\n\t\n\tprotected _open = false;\n\tget isOpen() { return this._open }\n\n\tprotected _valid = true;\n\tget isValid() { return this._valid }\n\n\tvalidate() {\n\t\tthis._valid = true;\n\t\tif (this.activeCell) this._valid = validateValue(this.activeCellModel, this.getValue());\n\t\tthis.classList.toggle('invalid', !this._valid);\n\t\treturn this._valid;\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.init();\n\t}\n\n\t\n\tabstract getValue() : unknown;\n\n\tabstract setValue(value: unknown) : void;\n\t\n\tgetDisplayValue() : string {\n\t\treturn null;\n\t}\n\n\tinit() {\n\t\tthis.addEventListener('keydown', e => {\n\t\t\tif (e.key == 'Enter') {\n\t\t\t\tthis.close();\n\t\t\t} else if (e.key == 'Escape') {\n\t\t\t\tthis.cancel = true;\n\t\t\t\tthis.close();\n\t\t\t} else {\n\t\t\t\te.stopPropagation();\n\t\t\t}\n\t\t});\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.performUpdate();\n\t}\n\n\talignWithCell() {\n\t\tif (!this.activeCell) return;\n\t\tconst offset = dom.getElementOffset(this.activeCell, this.grid);\n\t\tdom.setPosition(this, {t: offset.top * this.grid.zoom, l: offset.left * this.grid.zoom});\n\t\tdom.setSize(this, {w: this.activeCell.offsetWidth, h: this.activeCell.offsetHeight});\n\t}\n\n\topen(grid: Grid, initialValue: unknown = null, updatePosition = true) {\n\t\tthis._valid = true;\n\t\tthis.initialValue = initialValue;\n\t\tthis._open = true;\n\t\tthis.grid = grid;\n\t\tconst cellModel = grid.selecting.activeCell;\n\t\tthis.activeCellModel = cellModel;\n\t\tthis.activeCell = this.grid.table.getCellByModelIndex(cellModel.c, cellModel.r);\n\t\tthis.grid.selector.hide();\n\t\tdom.showElement(this);\n\t\tif (updatePosition) this.alignWithCell();\n\t\tthis.activate(cellModel);\n\t\tif (initialValue !== null) this.setValue(initialValue);\n\t\tdom.zoomElement(this, this.grid.zoom);\n\t\treturn this;\n\t}\n\n\tcommit() {\n\t\tif (this._open && !this.cancel && this.activeCellModel) {\n\t\t\tthis.grid.editing.updateCell(\n\t\t\t\tthis.activeCellModel, \n\t\t\t\t{v: this.getValue() as CellValueType, dv: this.getDisplayValue()}\n\t\t\t);\n\t\t\tthis.grid.rendering.updateCell(this.activeCellModel, true);\n\t\t}\n\t\tthis.cancel = false;\n\t}\n\n\tclose() {\n\t\tif (this._open) {\n\t\t\tthis.deactivate();\n\t\t\tdom.hideElement(this);\n\t\t\tthis.grid.table.renderBodyCell(this.activeCellModel);\n\t\t\tthis.grid.selecting.showSelector();\n\t\t\tthis.grid.focus();\n\t\t\tthis._open = false;\n\t\t\tthis.grid.editing.endEdit();\n\t\t}\n\t\tthis.cancel = false;\n\t}\n\n\tactivate(cell: CellModel) : void {\n\t\tthis.activeCellModel = cell;\n\t\tthis.dispatchEvent(new EditorEvent('activate'));\n\t}\n\t\n\tdeactivate() : void {\n\t\tthis.dispatchEvent(new EditorEvent('deactivate'));\n\t}\n\n}"]}
1
+ {"version":3,"file":"baseEditor.js","sourceRoot":"","sources":["../../src/editors/baseEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAGtC,MAAM,OAAO,WAAY,SAAQ,KAAK;CAAI;AAE1C,MAAM,OAAgB,UAAW,SAAQ,UAAU;IA0BlD,IAAI,MAAM,KAAK,OAAO,IAAI,CAAC,KAAK,CAAA,CAAC,CAAC;IAGlC,IAAI,OAAO,KAAK,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IAEpC,QAAQ;QACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,IAAI,CAAC,UAAU;YAAE,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxF,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;QACC,KAAK,EAAE,CAAC;QAnBC,W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IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK;QACJ,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACrD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;YACnC,uEAAuE;YACvE,iEAAiE;YACjE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAC,aAAa,EAAE,IAAI,EAAC,CAAC,CAAC;YACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,QAAQ,CAAC,IAAe;QACvB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,UAAU;QACT,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IACnD,CAAC;;AA7HM,qBAAU,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;EAetB,AAfgB,CAef","sourcesContent":["import { CellModel, CellValueType, validateValue } from \"@omegagrid/grid-core\";\nimport { LitElement, css } from 'lit';\nimport { dom } from \"@omegagrid/core\";\nimport { Grid } from \"../ui/grid\";\n\nexport class EditorEvent extends Event { }\n\nexport abstract class BaseEditor extends LitElement {\n\n\tstatic baseStyles = css`\n\t\t* { box-sizing: border-box }\n\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tbackground: var(--og-cell-background);\n\t\t\tz-index: 200;\n\t\t}\n\n\t\t:host(.invalid) input {\n\t\t\tcolor: #ff0000;\n\t\t\tborder: 1px solid #ff0000;\n\t\t}\n\t`;\n\n\tprotected grid: Grid;\n\tprotected cancel = false;\n\tprotected activeCell: HTMLTableCellElement;\n\tprotected activeCellModel: CellModel;\n\tprotected initialValue: unknown;\n\t\n\tprotected _open = false;\n\tget isOpen() { return this._open }\n\n\tprotected _valid = true;\n\tget isValid() { return this._valid }\n\n\tvalidate() {\n\t\tthis._valid = true;\n\t\tif (this.activeCell) this._valid = validateValue(this.activeCellModel, this.getValue());\n\t\tthis.classList.toggle('invalid', !this._valid);\n\t\treturn this._valid;\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.init();\n\t}\n\n\t\n\tabstract getValue() : unknown;\n\n\tabstract setValue(value: unknown) : void;\n\t\n\tgetDisplayValue() : string {\n\t\treturn null;\n\t}\n\n\tinit() {\n\t\tthis.addEventListener('keydown', e => {\n\t\t\tif (e.key == 'Enter') {\n\t\t\t\tthis.close();\n\t\t\t} else if (e.key == 'Escape') {\n\t\t\t\tthis.cancel = true;\n\t\t\t\tthis.close();\n\t\t\t} else {\n\t\t\t\te.stopPropagation();\n\t\t\t}\n\t\t});\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.performUpdate();\n\t}\n\n\talignWithCell() {\n\t\tif (!this.activeCell) return;\n\t\tconst offset = dom.getElementOffset(this.activeCell, this.grid);\n\t\tdom.setPosition(this, {t: offset.top * this.grid.zoom, l: offset.left * this.grid.zoom});\n\t\tdom.setSize(this, {w: this.activeCell.offsetWidth, h: this.activeCell.offsetHeight});\n\t}\n\n\topen(grid: Grid, initialValue: unknown = null, updatePosition = true) {\n\t\tthis._valid = true;\n\t\tthis.initialValue = initialValue;\n\t\tthis._open = true;\n\t\tthis.grid = grid;\n\t\tconst cellModel = grid.selecting.activeCell;\n\t\tthis.activeCellModel = cellModel;\n\t\tthis.activeCell = this.grid.table.getCellByModelIndex(cellModel.c, cellModel.r);\n\t\tthis.grid.selector.hide();\n\t\tdom.showElement(this);\n\t\tif (updatePosition) this.alignWithCell();\n\t\tthis.activate(cellModel);\n\t\tif (initialValue !== null) this.setValue(initialValue);\n\t\tdom.zoomElement(this, this.grid.zoom);\n\t\treturn this;\n\t}\n\n\tcommit() {\n\t\tif (this._open && !this.cancel && this.activeCellModel) {\n\t\t\tthis.grid.editing.updateCell(\n\t\t\t\tthis.activeCellModel, \n\t\t\t\t{v: this.getValue() as CellValueType, dv: this.getDisplayValue()}\n\t\t\t);\n\t\t\tthis.grid.rendering.updateCell(this.activeCellModel, true);\n\t\t}\n\t\tthis.cancel = false;\n\t}\n\n\tclose() {\n\t\tif (this._open) {\n\t\t\tthis.deactivate();\n\t\t\tdom.hideElement(this);\n\t\t\tthis.grid.table.renderBodyCell(this.activeCellModel);\n\t\t\tthis.grid.selecting.showSelector();\n\t\t\t// preventScroll: focus would otherwise natively scroll overflow:hidden\n\t\t\t// ancestors (e.g. og-container) that manage scrolling themselves\n\t\t\tthis.grid.focus({preventScroll: true});\n\t\t\tthis._open = false;\n\t\t\tthis.grid.editing.endEdit();\n\t\t}\n\t\tthis.cancel = false;\n\t}\n\n\tactivate(cell: CellModel) : void {\n\t\tthis.activeCellModel = cell;\n\t\tthis.dispatchEvent(new EditorEvent('activate'));\n\t}\n\t\n\tdeactivate() : void {\n\t\tthis.dispatchEvent(new EditorEvent('deactivate'));\n\t}\n\n}"]}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * as renderers from './renderers';
2
+ export * as editors from './editors';
2
3
  export * from './commands';
3
4
  export * from './ui';
4
5
  export * from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * as renderers from './renderers';
2
+ export * as editors from './editors';
2
3
  export * from './commands';
3
4
  export * from './ui';
4
5
  export * from './types';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC","sourcesContent":["export * as renderers from './renderers';\nimport * as editors from './editors';\nexport * from './commands';\nexport * from './ui';\nexport * from './types';\nexport * from './gridAdapter';\nexport * from '@omegagrid/grid-core';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC","sourcesContent":["export * as renderers from './renderers';\nexport * as editors from './editors';\nexport * from './commands';\nexport * from './ui';\nexport * from './types';\nexport * from './gridAdapter';\nexport * from '@omegagrid/grid-core';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/grid",
3
- "version": "0.10.76",
3
+ "version": "0.10.78",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Universal datagrid component",
6
6
  "main": "./dist/index.js",
@@ -35,12 +35,12 @@
35
35
  "_prepublish": "yarn test && yarn lint"
36
36
  },
37
37
  "dependencies": {
38
- "@omegagrid/commands": "^0.10.76",
39
- "@omegagrid/core": "^0.10.76",
40
- "@omegagrid/grid-core": "^0.10.76",
41
- "@omegagrid/localize": "^0.10.76",
42
- "@omegagrid/tabs": "^0.10.76",
43
- "@omegagrid/tree": "^0.10.76",
38
+ "@omegagrid/commands": "^0.10.78",
39
+ "@omegagrid/core": "^0.10.78",
40
+ "@omegagrid/grid-core": "^0.10.78",
41
+ "@omegagrid/localize": "^0.10.78",
42
+ "@omegagrid/tabs": "^0.10.78",
43
+ "@omegagrid/tree": "^0.10.78",
44
44
  "@stdlib/stats": "^0.0.13",
45
45
  "date-fns": "^3.2.0",
46
46
  "lit": "^3.1.1",