@omegagrid/grid-core 0.10.96 → 0.10.98

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.
@@ -60,7 +60,8 @@ export type TableTheme = {
60
60
  /**
61
61
  * Name matcher: a RegExp is used as is, a '/'-delimited string is a regular
62
62
  * expression as written, any other string matches the whole node name with
63
- * '*' as a wildcard (the rest escaped).
63
+ * '*' as a wildcard (the rest escaped). String forms match CASE-INSENSITIVELY,
64
+ * so the theme patterns stay simple; pass a RegExp instance for exact casing.
64
65
  */
65
66
  export declare function nameToRegExp(name: string | RegExp): RegExp;
66
67
  export declare function applyCellTheme(theme: TableTheme, model: GridModel, range?: CellRange): void;
@@ -1 +1 @@
1
- {"version":3,"file":"tableTheme.d.ts","sourceRoot":"","sources":["../../src/model/tableTheme.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,gCAAgC;AAChC,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,EAAE,MAAM,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAC,MAAM,GAAC,OAAO,GAAC,MAAM,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG;IACvB,0GAA0G;IAC1G,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,UAAU,GAAC,UAAU,EAAE,CAAC;CAC/B,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,IA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a regular
5
5
  * expression as written, any other string matches the whole node name with
6
- * '*' as a wildcard (the rest escaped).
6
+ * '*' as a wildcard (the rest escaped). String forms match CASE-INSENSITIVELY,
7
+ * so the theme patterns stay simple; pass a RegExp instance for exact casing.
7
8
  */
8
9
  export function nameToRegExp(name) {
9
10
  if (name instanceof RegExp)
@@ -11,13 +12,13 @@ export function nameToRegExp(name) {
11
12
  const value = String(name);
12
13
  if (value.length > 2 && value.startsWith('/') && value.endsWith('/')) {
13
14
  try {
14
- return new RegExp(value.slice(1, -1));
15
+ return new RegExp(value.slice(1, -1), 'i');
15
16
  }
16
17
  catch {
17
18
  // fall through to the wildcard form
18
19
  }
19
20
  }
20
- return new RegExp(`^${value.split('*').map(part => utils.escapeRegExp(part)).join('.*')}$`);
21
+ return new RegExp(`^${value.split('*').map(part => utils.escapeRegExp(part)).join('.*')}$`, 'i');
21
22
  }
22
23
  /**
23
24
  * Shared evaluator of the theme matchers (axis item matches and cell conditions):
@@ -1 +1 @@
1
- {"version":3,"file":"tableTheme.js","sourceRoot":"","sources":["../../src/model/tableTheme.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAQ,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAqE9C;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAmB;IAC/C,IAAI,IAAI,YAAY,MAAM;QAAE,OAAO,IAAI,CAAC;IACxC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACtE,IAAI,CAAC;YACJ,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;QAAC,MAAM,CAAC;YACR,oCAAoC;QACrC,CAAC;IACF,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AM,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;gBACpC,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI;oBAAE,SAAS;gBACnC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YAChD,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAiB,EAAE,KAAgB,EAAE,OAAuB;IAC5F,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAiB,EAAE,KAAgB,EAAE,IAAiB;IACnF,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAiB,EAAE,KAAgB;IAC7D,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC7B,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC/B,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { tree, utils } from \"@omegagrid/core\";\nimport { GridModel } from \"./gridModel\";\nimport { RowModel } from \"./rowModel\";\nimport { ColumnModel } from \"./columnModel\";\nimport { ConditionalFormatItemSource } from \"./conditionalFormats\";\nimport { CellModel } from \"./cellModel\";\nimport { CellRange } from \"../common\";\n\n/** @deprecated use MatchItem */\nexport type ThemeItemCondtion = {\n\tproperty?: keyof CellModel;\n\tvalue?: unknown;\n}\n\nexport type MatchValue = string|number|boolean|RegExp;\n\nexport type MatchItem = {\n\t/** matched model property (rows/columns: e.g. 'name', 'level', 'index'; cells: any CellModel property) */\n\tproperty: string;\n\t/**\n\t * Expected value(s); an array matches when ANY of the values matches (OR).\n\t * String/RegExp values of the 'name' property use the nameToRegExp conventions.\n\t */\n\tvalue: MatchValue|MatchValue[];\n}\n\nexport type ThemeItem = Omit<ConditionalFormatItemSource, 'ranges'> & {\n\t/** @deprecated use matches */\n\tconditions?: ThemeItemCondtion[];\n\t/**\n\t * Model matchers (rows/columns match node properties, cells match cell\n\t * properties): all items of an array must match (AND); the OR lives in\n\t * each item's value array.\n\t */\n\tmatches?: MatchItem|MatchItem[];\n};\n\nexport type ThemeAxisItem = ThemeItem & {\n\t/** @deprecated use matches - style will apply on cells with specific row/column index */\n\tindex?: number;\n\t/** @deprecated use matches - style will apply on cells with specific row/column level */\n\tlevel?: number;\n\t/** @deprecated use matches - style will apply on cells their names are matching regular expression */\n\tname?: string|RegExp;\n\t/** axis property priority */\n\tpriority?: number;\n}\n\nexport type ThemeRowItem = ThemeAxisItem & {\n\t/** row height */\n\theight?: number;\n}\n\nexport type ThemeColumnItem = ThemeAxisItem & {\n\t/** column width */\n\twidth?: number;\n}\n\nexport type TableTheme = {\n\t/** theme name */\n\tname: string;\n\t/** styles for cells */\n\tcells?: ThemeItem[],\n\t/** styles for columns */\n\tcolumns?: ThemeColumnItem[],\n\t/** styles for rows */\n\trows?: ThemeRowItem[],\n}\n\n/**\n * Name matcher: a RegExp is used as is, a '/'-delimited string is a regular\n * expression as written, any other string matches the whole node name with\n * '*' as a wildcard (the rest escaped).\n */\nexport function nameToRegExp(name: string|RegExp): RegExp {\n\tif (name instanceof RegExp) return name;\n\tconst value = String(name);\n\tif (value.length > 2 && value.startsWith('/') && value.endsWith('/')) {\n\t\ttry {\n\t\t\treturn new RegExp(value.slice(1, -1));\n\t\t} catch {\n\t\t\t// fall through to the wildcard form\n\t\t}\n\t}\n\treturn new RegExp(`^${value.split('*').map(part => utils.escapeRegExp(part)).join('.*')}$`);\n}\n\n/**\n * Shared evaluator of the theme matchers (axis item matches and cell conditions):\n * the target's property must equal one of the expected values; string/RegExp values\n * of the 'name' property are matched through the nameToRegExp conventions.\n */\nfunction matchProperty(target: any, match: {property?: string, value?: unknown}): boolean {\n\tif (!match.property) return match.value == null;\n\tconst actual = target[match.property];\n\tconst values = Array.isArray(match.value) ? match.value : [match.value];\n\treturn values.some(value => match.property == 'name' && (typeof value === 'string' || value instanceof RegExp)\n\t\t? nameToRegExp(value).test(String(actual ?? ''))\n\t\t: actual == value);\n}\n\nfunction getLevelMap<T extends tree.TreeNodeType>(nodes: T[]) {\n\tconst map = new Map<number, T[]>();\n\tfor (const node of nodes) {\n\t\tif (!map.has(node.level)) map.set(node.level, []);\n\t\tmap.get(node.level).push(node);\n\t}\n\treturn map;\n}\n\nfunction applyAxisTheme(theme: TableTheme, model: GridModel, type: 'rows'|'columns', tableElements?: (RowModel|ColumnModel)[]) {\n\tconst nodes = tableElements ?? (type == 'rows' ? model.rows : model.columns);\n\tconst levelMap = getLevelMap<RowModel|ColumnModel>(nodes);\n\tconst themeItems = theme[type] ?? [];\n\n\tfor (const item of themeItems) {\n\t\tlet effectiveNodes: (RowModel|ColumnModel)[];\n\t\tif (item.matches) {\n\t\t\tconst matchItems = Array.isArray(item.matches) ? item.matches : [item.matches];\n\t\t\teffectiveNodes = nodes.filter(node => matchItems.every(match => matchProperty(node, match)));\n\t\t} else {\n\t\t\tif (item.index > -1) {\n\t\t\t\teffectiveNodes = [nodes[item.index]];\n\t\t\t} else if (item.level > -1) {\n\t\t\t\teffectiveNodes = levelMap.get(item.level);\n\t\t\t} else {\n\t\t\t\teffectiveNodes = nodes;\n\t\t\t}\n\n\t\t\tif (item.name) {\n\t\t\t\tconst nameRegExp = nameToRegExp(item.name);\n\t\t\t\teffectiveNodes = effectiveNodes.filter(node => nameRegExp.test(node.name));\n\t\t\t}\n\t\t}\n\n\t\teffectiveNodes?.forEach(node => {\n\t\t\tif (item.priority != null) node.priority = item.priority;\n\n\t\t\tif (item.type) { // conditional format\n\t\t\t\tmodel.conditionalFormats.add(Object.assign({\n\t\t\t\t\tranges: `${node.address}:${node.address}`\n\t\t\t\t}, item));\n\t\t\t} else { // static format\n\t\t\t\tnode.style = model.styles.add(item.style).id;\n\n\t\t\t\tif (type == 'rows' && (item as ThemeRowItem).height != null) {\n\t\t\t\t\t(node as RowModel).height = (item as ThemeRowItem).height;\n\t\t\t\t} else if (type == 'columns' && (item as ThemeColumnItem).width != null) {\n\t\t\t\t\t(node as ColumnModel).width = (item as ThemeColumnItem).width;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/** matchers of a theme item - matches takes precedence over the deprecated conditions */\nfunction getMatchItems(item: ThemeItem): {property?: string, value?: unknown}[]|undefined {\n\tif (item.matches) return Array.isArray(item.matches) ? item.matches : [item.matches];\n\treturn item.conditions;\n}\n\nexport function applyCellTheme(theme: TableTheme, model: GridModel, range?: CellRange) {\n\tconst themeItems = theme.cells ?? [];\n\n\tfor (const item of themeItems) {\n\t\tconst matchItems = getMatchItems(item);\n\t\tif (matchItems?.length) {\n\t\t\tconst iterator = model.getRangeIterator(range ?? model.gridRange);\n\t\t\tfor (const cell of iterator) {\n\t\t\t\tif (matchItems.every(match => matchProperty(cell, match))) {\n\t\t\t\t\tcell.style = model.styles.add(item.style).id;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (item.type) { // conditional format\n\t\t\tmodel.conditionalFormats.add(Object.assign({\n\t\t\t\tranges: 'A:' + model.columns[model.columns.length - 1].address\n\t\t\t}, item));\n\t\t} else { // static format\n\t\t\tfor (const column of model.columns) {\n\t\t\t\tif (column.style != null) continue;\n\t\t\t\tcolumn.style = model.styles.add(item.style).id;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function applyColumnTheme(theme: TableTheme, model: GridModel, columns?: ColumnModel[]) {\n\tapplyAxisTheme(theme, model, 'columns', columns);\n}\n\nexport function applyRowTheme(theme: TableTheme, model: GridModel, rows?: RowModel[]) {\n\tapplyAxisTheme(theme, model, 'rows', rows);\n}\n\nexport function applyTheme(theme: TableTheme, model: GridModel) {\n\tapplyCellTheme(theme, model);\n\tapplyCol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AC5C,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAiB,EAAE,KAAgB;IAC7D,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC7B,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC/B,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { tree, utils } from \"@omegagrid/core\";\nimport { GridModel } from \"./gridModel\";\nimport { RowModel } from \"./rowModel\";\nimport { ColumnModel } from \"./columnModel\";\nimport { ConditionalFormatItemSource } from \"./conditionalFormats\";\nimport { CellModel } from \"./cellModel\";\nimport { CellRange } from \"../common\";\n\n/** @deprecated use MatchItem */\nexport type ThemeItemCondtion = {\n\tproperty?: keyof CellModel;\n\tvalue?: unknown;\n}\n\nexport type MatchValue = string|number|boolean|RegExp;\n\nexport type MatchItem = {\n\t/** matched model property (rows/columns: e.g. 'name', 'level', 'index'; cells: any CellModel property) */\n\tproperty: string;\n\t/**\n\t * Expected value(s); an array matches when ANY of the values matches (OR).\n\t * String/RegExp values of the 'name' property use the nameToRegExp conventions.\n\t */\n\tvalue: MatchValue|MatchValue[];\n}\n\nexport type ThemeItem = Omit<ConditionalFormatItemSource, 'ranges'> & {\n\t/** @deprecated use matches */\n\tconditions?: ThemeItemCondtion[];\n\t/**\n\t * Model matchers (rows/columns match node properties, cells match cell\n\t * properties): all items of an array must match (AND); the OR lives in\n\t * each item's value array.\n\t */\n\tmatches?: MatchItem|MatchItem[];\n};\n\nexport type ThemeAxisItem = ThemeItem & {\n\t/** @deprecated use matches - style will apply on cells with specific row/column index */\n\tindex?: number;\n\t/** @deprecated use matches - style will apply on cells with specific row/column level */\n\tlevel?: number;\n\t/** @deprecated use matches - style will apply on cells their names are matching regular expression */\n\tname?: string|RegExp;\n\t/** axis property priority */\n\tpriority?: number;\n}\n\nexport type ThemeRowItem = ThemeAxisItem & {\n\t/** row height */\n\theight?: number;\n}\n\nexport type ThemeColumnItem = ThemeAxisItem & {\n\t/** column width */\n\twidth?: number;\n}\n\nexport type TableTheme = {\n\t/** theme name */\n\tname: string;\n\t/** styles for cells */\n\tcells?: ThemeItem[],\n\t/** styles for columns */\n\tcolumns?: ThemeColumnItem[],\n\t/** styles for rows */\n\trows?: ThemeRowItem[],\n}\n\n/**\n * Name matcher: a RegExp is used as is, a '/'-delimited string is a regular\n * expression as written, any other string matches the whole node name with\n * '*' as a wildcard (the rest escaped). String forms match CASE-INSENSITIVELY,\n * so the theme patterns stay simple; pass a RegExp instance for exact casing.\n */\nexport function nameToRegExp(name: string|RegExp): RegExp {\n\tif (name instanceof RegExp) return name;\n\tconst value = String(name);\n\tif (value.length > 2 && value.startsWith('/') && value.endsWith('/')) {\n\t\ttry {\n\t\t\treturn new RegExp(value.slice(1, -1), 'i');\n\t\t} catch {\n\t\t\t// fall through to the wildcard form\n\t\t}\n\t}\n\treturn new RegExp(`^${value.split('*').map(part => utils.escapeRegExp(part)).join('.*')}$`, 'i');\n}\n\n/**\n * Shared evaluator of the theme matchers (axis item matches and cell conditions):\n * the target's property must equal one of the expected values; string/RegExp values\n * of the 'name' property are matched through the nameToRegExp conventions.\n */\nfunction matchProperty(target: any, match: {property?: string, value?: unknown}): boolean {\n\tif (!match.property) return match.value == null;\n\tconst actual = target[match.property];\n\tconst values = Array.isArray(match.value) ? match.value : [match.value];\n\treturn values.some(value => match.property == 'name' && (typeof value === 'string' || value instanceof RegExp)\n\t\t? nameToRegExp(value).test(String(actual ?? ''))\n\t\t: actual == value);\n}\n\nfunction getLevelMap<T extends tree.TreeNodeType>(nodes: T[]) {\n\tconst map = new Map<number, T[]>();\n\tfor (const node of nodes) {\n\t\tif (!map.has(node.level)) map.set(node.level, []);\n\t\tmap.get(node.level).push(node);\n\t}\n\treturn map;\n}\n\nfunction applyAxisTheme(theme: TableTheme, model: GridModel, type: 'rows'|'columns', tableElements?: (RowModel|ColumnModel)[]) {\n\tconst nodes = tableElements ?? (type == 'rows' ? model.rows : model.columns);\n\tconst levelMap = getLevelMap<RowModel|ColumnModel>(nodes);\n\tconst themeItems = theme[type] ?? [];\n\n\tfor (const item of themeItems) {\n\t\tlet effectiveNodes: (RowModel|ColumnModel)[];\n\t\tif (item.matches) {\n\t\t\tconst matchItems = Array.isArray(item.matches) ? item.matches : [item.matches];\n\t\t\teffectiveNodes = nodes.filter(node => matchItems.every(match => matchProperty(node, match)));\n\t\t} else {\n\t\t\tif (item.index > -1) {\n\t\t\t\teffectiveNodes = [nodes[item.index]];\n\t\t\t} else if (item.level > -1) {\n\t\t\t\teffectiveNodes = levelMap.get(item.level);\n\t\t\t} else {\n\t\t\t\teffectiveNodes = nodes;\n\t\t\t}\n\n\t\t\tif (item.name) {\n\t\t\t\tconst nameRegExp = nameToRegExp(item.name);\n\t\t\t\teffectiveNodes = effectiveNodes.filter(node => nameRegExp.test(node.name));\n\t\t\t}\n\t\t}\n\n\t\teffectiveNodes?.forEach(node => {\n\t\t\tif (item.priority != null) node.priority = item.priority;\n\n\t\t\tif (item.type) { // conditional format\n\t\t\t\tmodel.conditionalFormats.add(Object.assign({\n\t\t\t\t\tranges: `${node.address}:${node.address}`\n\t\t\t\t}, item));\n\t\t\t} else { // static format\n\t\t\t\tnode.style = model.styles.add(item.style).id;\n\n\t\t\t\tif (type == 'rows' && (item as ThemeRowItem).height != null) {\n\t\t\t\t\t(node as RowModel).height = (item as ThemeRowItem).height;\n\t\t\t\t} else if (type == 'columns' && (item as ThemeColumnItem).width != null) {\n\t\t\t\t\t(node as ColumnModel).width = (item as ThemeColumnItem).width;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/** matchers of a theme item - matches takes precedence over the deprecated conditions */\nfunction getMatchItems(item: ThemeItem): {property?: string, value?: unknown}[]|undefined {\n\tif (item.matches) return Array.isArray(item.matches) ? item.matches : [item.matches];\n\treturn item.conditions;\n}\n\nexport function applyCellTheme(theme: TableTheme, model: GridModel, range?: CellRange) {\n\tconst themeItems = theme.cells ?? [];\n\n\tfor (const item of themeItems) {\n\t\tconst matchItems = getMatchItems(item);\n\t\tif (matchItems?.length) {\n\t\t\tconst iterator = model.getRangeIterator(range ?? model.gridRange);\n\t\t\tfor (const cell of iterator) {\n\t\t\t\tif (matchItems.every(match => matchProperty(cell, match))) {\n\t\t\t\t\tcell.style = model.styles.add(item.style).id;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (item.type) { // conditional format\n\t\t\tmodel.conditionalFormats.add(Object.assign({\n\t\t\t\tranges: 'A:' + model.columns[model.columns.length - 1].address\n\t\t\t}, item));\n\t\t} else { // static format\n\t\t\tfor (const column of model.columns) {\n\t\t\t\tif (column.style != null) continue;\n\t\t\t\tcolumn.style = model.styles.add(item.style).id;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function applyColumnTheme(theme: TableTheme, model: GridModel, columns?: ColumnModel[]) {\n\tapplyAxisTheme(theme, model, 'columns', columns);\n}\n\nexport function applyRowTheme(theme: TableTheme, model: GridModel, rows?: RowModel[]) {\n\tapplyAxisTheme(theme, model, 'rows', rows);\n}\n\nexport function applyTheme(theme: TableTheme, model: GridModel) {\n\tapplyCellTheme(theme, model);\n\tapplyColumnTheme(theme, model);\n\tapplyRowTheme(theme, model);\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/grid-core",
3
- "version": "0.10.96",
3
+ "version": "0.10.98",
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.10.96",
32
- "@omegagrid/localize": "^0.10.96",
31
+ "@omegagrid/core": "^0.10.98",
32
+ "@omegagrid/localize": "^0.10.98",
33
33
  "@stdlib/stats": "^0.0.13",
34
34
  "color": "^4.2.3",
35
35
  "date-fns": "^3.2.0",