@omegagrid/grid-core 0.7.8 → 0.7.10

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.
@@ -70,7 +70,7 @@ export class ElementModel {
70
70
  this._clickable = source.clickable;
71
71
  this._validation = source.validation ? normalizeCellValidation(source.validation) : null;
72
72
  this._properties = source.props;
73
- this._style = source.s == null ? null : this.model.styles.add(source.s).id;
73
+ this._style = source.s == null ? null : this.model.styles.add(source.s)?.id;
74
74
  }
75
75
  update(source) {
76
76
  const updatedProps = {};
@@ -1 +1 @@
1
- {"version":3,"file":"elementModel.js","sourceRoot":"","sources":["../../src/model/elementModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+D,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACrG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAuCxD,MAAM,OAAO,YAAY;IAExB,IAAI,OAAO,KAAa,OAAO,IAAI,CAAA,CAAC,CAAC;IAGrC,IAAI,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAA,CAAC,CAAC;IACxC,IAAI,QAAQ,CAAC,QAAkB,IAAI,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA,CAAC,CAAC;IAG9D,IAAI,aAAa,KAAK,OAAO,IAAI,CAAC,cAAc,CAAA,CAAC,CAAC;IAClD,IAAI,aAAa,CAAC,aAAuB,IAAI,IAAI,CAAC,cAAc,GAAG,aAAa,CAAA,CAAC,CAAC;IAGlF,IAAI,eAAe,KAAK,OAAO,IAAI,CAAC,gBAAgB,CAAA,CAAC,CAAC;IACtD,IAAI,eAAe,CAAC,eAAgC,IAAI,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAA,CAAC,CAAC;IAGjG,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAA,CAAC,CAAC;IAChC,IAAI,IAAI,CAAC,CAAW,I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C,MAAM,IAAI,IAAI;YAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9C,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QAC/C,OAAO,IAAI,CAAC;IACb,CAAC;IAED,kBAAkB,CAAC,KAAwC,EAAE,oBAAoB,GAAG,KAAK;QACxF,IAAI,oBAAoB,EAAE,CAAC;YAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QAC1D,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QAChE,CAAC;IACF,CAAC;IAED,qBAAqB,CAAC,KAAe;QACpC,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI;YAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,aAAa;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;CAED","sourcesContent":["import { ComponentAdapter, numbers, ValueFormatter, CustomProperties, utils } from \"@omegagrid/core\";\nimport { prefixFormula } from \"../calculations\";\nimport { CellType, CellValidation, CellValidationSource, CommentRenderer, Renderer, StyleSource } from \"../types\";\nimport { CSSStyle } from \"./cssStyle\";\nimport { GridModel } from \"./gridModel\";\nimport { Style, StylePropertyKey } from \"./style\";\nimport { normalizeCellValidation } from \"./validations\";\n\n/** \n * Source object type for grid element.\n * Common ancestor for ColumnSource, RowSource and CellSource.\n */\nexport type ElementSource = {\n\t/** cell type */\n\tt?: CellType,\n\t/** style */\n\ts?: StyleSource,\n\t/** enable cell editing */\n\te?: boolean,\n\t/** number format */\n\tz?: numbers.NumberFormatString,\n\t/** formula */\n\tf?: string,\n\t/** range name */\n\tname?: string,\n\t/** custom properties */\n\tprops?: CustomProperties,\n\t/** cell editor content */\n\tcontent?: unknown,\n\t/** cell editor adapter */\n\tadapter?: ComponentAdapter,\n\t/** enable cell commenting */\n\tcommentable?: boolean,\n\t/** enable cell clicking */\n\tclickable?: boolean,\n\t/** cell renderer */\n\trenderer?: Renderer,\n\t/** cell renderer applied after initial renderer */\n\tafterRenderer?: Renderer,\n\t/** comment content renderer */\n\tcommentRenderer?: CommentRenderer,\n\t/** cell value validation options */\n\tvalidation?: CellValidationSource\n}\n\nexport class ElementModel {\n\n\tget address(): string { return null }\n\t\n\tprotected _renderer: Renderer;\n\tget renderer() { return this._renderer }\n\tset renderer(renderer: Renderer) { this._renderer = renderer }\n\n\tprotected _afterRenderer: Renderer;\n\tget afterRenderer() { return this._afterRenderer }\n\tset afterRenderer(afterRenderer: Renderer) { this._afterRenderer = afterRenderer }\n\n\tprotected _commentRenderer: CommentRenderer;\n\tget commentRenderer() { return this._commentRenderer }\n\tset commentRenderer(commentRenderer: CommentRenderer) { this._commentRenderer = commentRenderer }\n\t\n\tprotected _type: CellType = null;\n\tget type() { return this._type }\n\tset type(v: CellType) { this._type = v }\n\n\tprotected _name: string;\n\tget name() { return this._name }\n\tset name(v: string) { this._name = v }\n\n\tprotected _style: number;\n\tget style() { return this._style }\n\tset style(v: number) { this._style = v }\n\n\tprotected _commentable: boolean;\n\tget commentable() { return this._commentable }\n\tset commentable(v: boolean) { this._commentable = v }\n\n\tprotected _clickable = false;\n\tget clickable() { return this._clickable }\n\tset clickable(v: boolean) { this._clickable = v }\n\n\tprotected _editable: boolean;\n\tget editable() { return this._editable }\n\tset editable(v: boolean) { this._editable = v }\n\n\tprotected _validation: CellValidation;\n\tget validation() { return this._validation }\n\tset validation(v: CellValidation) { this._validation = v }\n\n\tprotected _formula: string;\n\tget hasFormula() { return !!this._formula }\n\tget formula() { return this._formula }\n\tset formula(v: string) { this._formula = v ? v.replace(/^=/, '') : null }\n\n\tget value2(): string|unknown { return this.hasFormula ? prefixFormula(this.formula) : null }\n\n\tprotected _editorContent: unknown;\n\tget editorContent() { return this._editorContent }\n\tset editorContent(v: unknown) { this._editorContent = v }\n\n\tprotected _adapter: ComponentAdapter;\n\tget adapter() { return this._adapter }\n\tset adapter(v: ComponentAdapter) { this._adapter = v }\n\n\tprotected _properties: CustomProperties;\n\tget properties() { return this._properties }\n\tset properties(v: CustomProperties) { this._properties = v }\n\n\tgetProperty(key: string) { return this._properties?.[key] }\n\tsetProperty(key: string, value: unknown) {\n\t\tif (!this._properties) this._properties = {};\n\t\tthis._properties[key] = value;\n\t}\n\n\tprotected _valueFormatter: ValueFormatter;\n\tprotected _format: numbers.NumberFormatString;\n\tget format() { return this._format }\n\tset format(v: numbers.NumberFormatString) {\n\t\tthis._format = v;\n\t\tthis._valueFormatter = null;\n\t}\n\n\t///TODO: implement date formatter\n\tget valueFormatter(): ValueFormatter {\n\t\treturn this._valueFormatter;\n\t}\n\n\tconstructor(public readonly model: GridModel, source?: ElementSource) {\n\t\tif (source) this.populate(source);\n\t}\n\n\tpopulate(source: ElementSource) {\n\t\tthis._renderer = source.renderer;\n\t\tthis._afterRenderer = source.afterRenderer;\n\t\tthis._commentRenderer = source.commentRenderer;\n\t\tthis._name = source.name;\n\t\tthis._type = source.t;\n\t\tthis._editorContent = source.content;\n\t\tthis._adapter = source.adapter;\n\t\tthis._format = source.z;\n\t\tthis._formula = source.f;\n\t\tthis._editable = source.e;\n\t\tthis._commentable = source.commentable;\n\t\tthis._clickable = source.clickable;\n\t\tthis._validation = source.validation ? normalizeCellValidation(source.validation) : null;\n\t\tthis._properties = source.props;\n\t\tthis._style = source.s == null ? null : this.model.styles.add(source.s as string|Style|CSSStyle).id;\n\t}\n\n\tupdate(source: ElementSource) {\n\t\tconst updatedProps = {} as ElementSource;\n\t\tif ('renderer' in source) { updatedProps.renderer = this._renderer; this._renderer = source.renderer; }\n\t\tif ('afterRenderer' in source) { this._afterRenderer = source.afterRenderer; }\n\t\tif ('commentRenderer' in source) { this._commentRenderer = source.commentRenderer; }\n\t\tif ('name' in source) { updatedProps.name = this._name; this._name = source.name; }\n\t\tif ('t' in source) { updatedProps.t = this._type; this._type = source.t; }\n\t\tif ('content' in source) { updatedProps.content = this._editorContent; this._editorContent = source.content; }\n\t\tif ('adapter' in source) { updatedProps.adapter = this._adapter; this._adapter = source.adapter; }\n\t\tif ('z' in source) { updatedProps.z = this._format; this._format = source.z; }\n\t\tif ('f' in source) { updatedProps.f = this._formula; this._formula = source.f; }\n\t\tif ('e' in source) { updatedProps.e = this._editable; this._editable = source.e; }\n\t\tif ('commentable' in source) { updatedProps.commentable = this._commentable; this._commentable = source.commentable; }\n\t\tif ('clickable' in source) { updatedProps.clickable = this._clickable; this._clickable = source.clickable; }\n\t\tif ('validation' in source) { updatedProps.validation = this._validation; this._validation = normalizeCellValidation(source.validation); }\n\t\tif ('props' in source) { updatedProps.props = this._properties; this._properties = source.props; }\n\t\tif ('s' in source) {\n\t\t\tconst styleId = this.model.styles.add(source.s as string|Style|CSSStyle).id;\n\t\t\tif (this._style !== styleId) { updatedProps.s = this._style; this._style = styleId; }\n\t\t}\n\t\treturn updatedProps;\n\t}\n\n\tgetSourceData() {\n\t\tconst data = {} as ElementSource;\n\t\tif (this._type != null) data.t = this._type;\n\t\tif (this._format != null) data.z = this._format;\n\t\tif (this._formula != null) data.f = this._formula;\n\t\tif (this._editable != null) data.e = this._editable;\n\t\tif (this._commentable != null) data.commentable = this._commentable;\n\t\tif (this._clickable != null) data.clickable = this._clickable;\n\t\tif (this._properties) data.props = utils.cloneDeep(this._properties);\n\t\tif (this._editorContent != null) data.content = utils.isObject(this._editorContent) \n\t\t\t? utils.cloneDeep(this._editorContent) : this._editorContent;\n\t\tif (this._style != null) data.s = this._style;\n\t\tif (this._name != null) data.name = this._name;\n\t\treturn data;\n\t}\n\t\t\n\tsetStyleProperties(props: Record<StylePropertyKey, unknown>, updateEixistingStyle = false) {\n\t\tif (updateEixistingStyle) {\n\t\t\tthis.style = this.model.styles.set(this.style, props).id;\n\t\t} else {\n\t\t\tthis.style = this.model.styles.duplicate(this.style, props).id;\n\t\t}\n\t}\n\n\tremoveStyleProperties(props: string[]) {\n\t\tif (this.style !== null) this.model.styles.unset(this.style, props);\n\t}\n\n\tget composedStyle() : Style {\n\t\treturn this.model.styles.get(this.style);\n\t}\n\n}"]}
1
+ {"version":3,"file":"elementModel.js","sourceRoot":"","sources":["../../src/model/elementModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+D,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACrG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAuCxD,MAAM,OAAO,YAAY;IAExB,IAAI,OAAO,KAAa,OAAO,IAAI,CAAA,CAAC,CAAC;IAGrC,IAAI,QAAQ,KAAK,OAAO,IAAI,CAAC,SAAS,CAAA,CAAC,CAAC;IACxC,IAAI,QAAQ,CAAC,QAAkB,IAAI,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA,CAAC,CAAC;IAG9D,IAAI,aAAa,KAAK,OAAO,IAAI,CAAC,cAAc,CAAA,CAAC,CAAC;IAClD,IAAI,aAAa,CAAC,aAAuB,IAAI,IAAI,CAAC,cAAc,GAAG,aAAa,CAAA,CAAC,CAAC;IAGlF,IAAI,eAAe,KAAK,OAAO,IAAI,CAAC,gBAAgB,CAAA,CAAC,CAAC;IACtD,IAAI,eAAe,CAAC,eAAgC,IAAI,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAA,CAAC,CAAC;IAGjG,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAA,CAAC,CAAC;IAChC,IAAI,IAAI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AAI,IAAI,CAAC,MAAM,IAAI,IAAI;YAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9C,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QAC/C,OAAO,IAAI,CAAC;IACb,CAAC;IAED,kBAAkB,CAAC,KAAwC,EAAE,oBAAoB,GAAG,KAAK;QACxF,IAAI,oBAAoB,EAAE,CAAC;YAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QAC1D,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QAChE,CAAC;IACF,CAAC;IAED,qBAAqB,CAAC,KAAe;QACpC,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI;YAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,aAAa;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;CAED","sourcesContent":["import { ComponentAdapter, numbers, ValueFormatter, CustomProperties, utils } from \"@omegagrid/core\";\nimport { prefixFormula } from \"../calculations\";\nimport { CellType, CellValidation, CellValidationSource, CommentRenderer, Renderer, StyleSource } from \"../types\";\nimport { CSSStyle } from \"./cssStyle\";\nimport { GridModel } from \"./gridModel\";\nimport { Style, StylePropertyKey } from \"./style\";\nimport { normalizeCellValidation } from \"./validations\";\n\n/** \n * Source object type for grid element.\n * Common ancestor for ColumnSource, RowSource and CellSource.\n */\nexport type ElementSource = {\n\t/** cell type */\n\tt?: CellType,\n\t/** style */\n\ts?: StyleSource,\n\t/** enable cell editing */\n\te?: boolean,\n\t/** number format */\n\tz?: numbers.NumberFormatString,\n\t/** formula */\n\tf?: string,\n\t/** range name */\n\tname?: string,\n\t/** custom properties */\n\tprops?: CustomProperties,\n\t/** cell editor content */\n\tcontent?: unknown,\n\t/** cell editor adapter */\n\tadapter?: ComponentAdapter,\n\t/** enable cell commenting */\n\tcommentable?: boolean,\n\t/** enable cell clicking */\n\tclickable?: boolean,\n\t/** cell renderer */\n\trenderer?: Renderer,\n\t/** cell renderer applied after initial renderer */\n\tafterRenderer?: Renderer,\n\t/** comment content renderer */\n\tcommentRenderer?: CommentRenderer,\n\t/** cell value validation options */\n\tvalidation?: CellValidationSource\n}\n\nexport class ElementModel {\n\n\tget address(): string { return null }\n\t\n\tprotected _renderer: Renderer;\n\tget renderer() { return this._renderer }\n\tset renderer(renderer: Renderer) { this._renderer = renderer }\n\n\tprotected _afterRenderer: Renderer;\n\tget afterRenderer() { return this._afterRenderer }\n\tset afterRenderer(afterRenderer: Renderer) { this._afterRenderer = afterRenderer }\n\n\tprotected _commentRenderer: CommentRenderer;\n\tget commentRenderer() { return this._commentRenderer }\n\tset commentRenderer(commentRenderer: CommentRenderer) { this._commentRenderer = commentRenderer }\n\t\n\tprotected _type: CellType = null;\n\tget type() { return this._type }\n\tset type(v: CellType) { this._type = v }\n\n\tprotected _name: string;\n\tget name() { return this._name }\n\tset name(v: string) { this._name = v }\n\n\tprotected _style: number;\n\tget style() { return this._style }\n\tset style(v: number) { this._style = v }\n\n\tprotected _commentable: boolean;\n\tget commentable() { return this._commentable }\n\tset commentable(v: boolean) { this._commentable = v }\n\n\tprotected _clickable = false;\n\tget clickable() { return this._clickable }\n\tset clickable(v: boolean) { this._clickable = v }\n\n\tprotected _editable: boolean;\n\tget editable() { return this._editable }\n\tset editable(v: boolean) { this._editable = v }\n\n\tprotected _validation: CellValidation;\n\tget validation() { return this._validation }\n\tset validation(v: CellValidation) { this._validation = v }\n\n\tprotected _formula: string;\n\tget hasFormula() { return !!this._formula }\n\tget formula() { return this._formula }\n\tset formula(v: string) { this._formula = v ? v.replace(/^=/, '') : null }\n\n\tget value2(): string|unknown { return this.hasFormula ? prefixFormula(this.formula) : null }\n\n\tprotected _editorContent: unknown;\n\tget editorContent() { return this._editorContent }\n\tset editorContent(v: unknown) { this._editorContent = v }\n\n\tprotected _adapter: ComponentAdapter;\n\tget adapter() { return this._adapter }\n\tset adapter(v: ComponentAdapter) { this._adapter = v }\n\n\tprotected _properties: CustomProperties;\n\tget properties() { return this._properties }\n\tset properties(v: CustomProperties) { this._properties = v }\n\n\tgetProperty(key: string) { return this._properties?.[key] }\n\tsetProperty(key: string, value: unknown) {\n\t\tif (!this._properties) this._properties = {};\n\t\tthis._properties[key] = value;\n\t}\n\n\tprotected _valueFormatter: ValueFormatter;\n\tprotected _format: numbers.NumberFormatString;\n\tget format() { return this._format }\n\tset format(v: numbers.NumberFormatString) {\n\t\tthis._format = v;\n\t\tthis._valueFormatter = null;\n\t}\n\n\t///TODO: implement date formatter\n\tget valueFormatter(): ValueFormatter {\n\t\treturn this._valueFormatter;\n\t}\n\n\tconstructor(public readonly model: GridModel, source?: ElementSource) {\n\t\tif (source) this.populate(source);\n\t}\n\n\tpopulate(source: ElementSource) {\n\t\tthis._renderer = source.renderer;\n\t\tthis._afterRenderer = source.afterRenderer;\n\t\tthis._commentRenderer = source.commentRenderer;\n\t\tthis._name = source.name;\n\t\tthis._type = source.t;\n\t\tthis._editorContent = source.content;\n\t\tthis._adapter = source.adapter;\n\t\tthis._format = source.z;\n\t\tthis._formula = source.f;\n\t\tthis._editable = source.e;\n\t\tthis._commentable = source.commentable;\n\t\tthis._clickable = source.clickable;\n\t\tthis._validation = source.validation ? normalizeCellValidation(source.validation) : null;\n\t\tthis._properties = source.props;\n\t\tthis._style = source.s == null ? null : this.model.styles.add(source.s)?.id;\n\t}\n\n\tupdate(source: ElementSource) {\n\t\tconst updatedProps = {} as ElementSource;\n\t\tif ('renderer' in source) { updatedProps.renderer = this._renderer; this._renderer = source.renderer; }\n\t\tif ('afterRenderer' in source) { this._afterRenderer = source.afterRenderer; }\n\t\tif ('commentRenderer' in source) { this._commentRenderer = source.commentRenderer; }\n\t\tif ('name' in source) { updatedProps.name = this._name; this._name = source.name; }\n\t\tif ('t' in source) { updatedProps.t = this._type; this._type = source.t; }\n\t\tif ('content' in source) { updatedProps.content = this._editorContent; this._editorContent = source.content; }\n\t\tif ('adapter' in source) { updatedProps.adapter = this._adapter; this._adapter = source.adapter; }\n\t\tif ('z' in source) { updatedProps.z = this._format; this._format = source.z; }\n\t\tif ('f' in source) { updatedProps.f = this._formula; this._formula = source.f; }\n\t\tif ('e' in source) { updatedProps.e = this._editable; this._editable = source.e; }\n\t\tif ('commentable' in source) { updatedProps.commentable = this._commentable; this._commentable = source.commentable; }\n\t\tif ('clickable' in source) { updatedProps.clickable = this._clickable; this._clickable = source.clickable; }\n\t\tif ('validation' in source) { updatedProps.validation = this._validation; this._validation = normalizeCellValidation(source.validation); }\n\t\tif ('props' in source) { updatedProps.props = this._properties; this._properties = source.props; }\n\t\tif ('s' in source) {\n\t\t\tconst styleId = this.model.styles.add(source.s as string|Style|CSSStyle).id;\n\t\t\tif (this._style !== styleId) { updatedProps.s = this._style; this._style = styleId; }\n\t\t}\n\t\treturn updatedProps;\n\t}\n\n\tgetSourceData() {\n\t\tconst data = {} as ElementSource;\n\t\tif (this._type != null) data.t = this._type;\n\t\tif (this._format != null) data.z = this._format;\n\t\tif (this._formula != null) data.f = this._formula;\n\t\tif (this._editable != null) data.e = this._editable;\n\t\tif (this._commentable != null) data.commentable = this._commentable;\n\t\tif (this._clickable != null) data.clickable = this._clickable;\n\t\tif (this._properties) data.props = utils.cloneDeep(this._properties);\n\t\tif (this._editorContent != null) data.content = utils.isObject(this._editorContent) \n\t\t\t? utils.cloneDeep(this._editorContent) : this._editorContent;\n\t\tif (this._style != null) data.s = this._style;\n\t\tif (this._name != null) data.name = this._name;\n\t\treturn data;\n\t}\n\t\t\n\tsetStyleProperties(props: Record<StylePropertyKey, unknown>, updateEixistingStyle = false) {\n\t\tif (updateEixistingStyle) {\n\t\t\tthis.style = this.model.styles.set(this.style, props).id;\n\t\t} else {\n\t\t\tthis.style = this.model.styles.duplicate(this.style, props).id;\n\t\t}\n\t}\n\n\tremoveStyleProperties(props: string[]) {\n\t\tif (this.style !== null) this.model.styles.unset(this.style, props);\n\t}\n\n\tget composedStyle() : Style {\n\t\treturn this.model.styles.get(this.style);\n\t}\n\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/grid-core",
3
- "version": "0.7.8",
3
+ "version": "0.7.10",
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.7.8",
32
- "@omegagrid/localize": "^0.7.8",
31
+ "@omegagrid/core": "^0.7.10",
32
+ "@omegagrid/localize": "^0.7.10",
33
33
  "@stdlib/stats": "^0.0.13",
34
34
  "color": "^4.2.3",
35
35
  "date-fns": "^3.2.0",