@omegagrid/grid-core 0.10.62 → 0.10.63

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,7 +1,7 @@
1
1
  import { KeyValue } from "@omegagrid/core";
2
2
  import { CellModel } from "./cellModel";
3
3
  import { GridModel } from "./gridModel";
4
- import { CellType, FilterRange, FilterValue } from "../types";
4
+ import { CellType, FilterRange, FilterValue, NumericFilterGroups } from "../types";
5
5
  export type FilterMatcher = (cell: CellModel) => boolean;
6
6
  export type FilterSettings = {
7
7
  c: number;
@@ -14,6 +14,30 @@ export declare const createMultiMultiMatcher: <TItem>(_term: KeyValue[], _proper
14
14
  export declare const isFilterRange: (term: FilterValue) => term is FilterRange;
15
15
  export declare const isFilterRangeEmpty: (term: FilterRange) => boolean;
16
16
  export declare const createRangeMatcher: <TItem>(term: FilterRange, property: keyof TItem, type: CellType) => (item: TItem) => boolean;
17
+ /** True when the whole (trimmed) input is a single bare number, e.g. `42`, `-3.5`, `1,5`. */
18
+ export declare const isSingleNumber: (input: string) => boolean;
19
+ /**
20
+ * Parse a numeric filter expression into a disjunction of conjunctions
21
+ * (OR groups, each an AND-combined list of clauses).
22
+ *
23
+ * Supported syntax:
24
+ * - operators `>`, `>=`, `<`, `<=`, `=`/`==`, `!=`/`<>` followed by a number (e.g. `> 100`, `=42`, `!=5`)
25
+ * - a bare number, treated as an exact match `= n` (e.g. `42`)
26
+ * - a range `a..b`, expanded to `>= a` and `<= b` (e.g. `10..20`)
27
+ * - `and` / `or` connectors (case-insensitive), e.g. `<10 or >20`, `>10 and <20`.
28
+ *
29
+ * Combining rules: an explicit `or` starts a new OR group, an explicit `and` keeps
30
+ * clauses in the same AND group. When no connector is given between two clauses the
31
+ * implicit connector is OR if both are exact (`=`) clauses — a value list such as
32
+ * `1 2 3` — and AND otherwise (comparisons narrow, e.g. `>10 <20`).
33
+ *
34
+ * Note: a lone bare number is parsed here as `= n`; callers that want the
35
+ * "contains" text-search behaviour for a single number must check {@link isSingleNumber}.
36
+ *
37
+ * Decimal separator may be `.` or `,`. Tokens that cannot be parsed are ignored.
38
+ */
39
+ export declare const parseNumericExpression: (input: string) => NumericFilterGroups;
40
+ export declare const createNumericMatcher: <TItem>(groups: NumericFilterGroups, property: keyof TItem) => (item: TItem) => boolean;
17
41
  export declare const createCellMatcher: (type: CellType, term: FilterValue, property: keyof CellModel) => (item: CellModel) => boolean;
18
42
  export declare class FilterEvent extends Event {
19
43
  constructor();
@@ -1 +1 @@
1
- {"version":3,"file":"filterModel.d.ts","sourceRoot":"","sources":["../../src/model/filterModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE9D,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,WAAW,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,KAAK,EAAE,MAAM,MAAM,EAAE,UAAU,MAAM,KAAK,MAEnE,MAAM,KAAK,YAInB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,KAAK,EAAE,MAAM,OAAO,EAAE,UAAU,MAAM,KAAK,MACpE,MAAM,KAAK,YACnB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,KAAK,EAAE,MAAM,QAAQ,EAAE,EAAE,UAAU,MAAM,KAAK,MAExE,MAAM,KAAK,YAGnB,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,KAAK,EAAE,OAAO,QAAQ,EAAE,EAAE,WAAW,MAAM,KAAK,MAC/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,eAAO,MAAM,iBAAiB,GAAI,MAAM,QAAQ,EAAE,MAAM,WAAW,EAAE,UAAU,MAAM,SAAS,iCAmB7F,CAAA;AAED,qBAAa,WAAY,SAAQ,KAAK;;CAIrC;AAED,qBAAa,WAAY,SAAQ,WAAW;aAkB1B,KAAK,EAAE,SAAS;IAhB1B,MAAM,UAAS;IAEtB,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,SAAS,CAAwB;IACzC,IAAI,QAAQ,IACI,cAAc,EAAE,GAAC,IAAI,CADG;IACxC,IAAI,QAAQ,CAAC,CAAC,EAAE,cAAc,EAAE,GAAC,IAAI,EAQpC;gBAGgB,KAAK,EAAE,SAAS,EAChC,QAAQ,GAAE,cAAc,EAAE,GAAC,IAAW;IAMvC;;;OAGG;IACH,GAAG,CAAC,CAAC,EAAE,MAAM;IAIb,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,aAAa,UAAO;IA8BnD,WAAW,CAAC,aAAa,UAAO;IAoDhC,WAAW,CAAC,aAAa,UAAO;CAQhC"}
@@ -50,10 +50,117 @@ export const createRangeMatcher = (term, property, type) => {
50
50
  return true;
51
51
  };
52
52
  };
53
+ // number token: optional sign, digits, optional decimal part using '.' or ',' as separator
54
+ const NUM_TOKEN = '[-+]?\\d+(?:[.,]\\d+)?';
55
+ const toClauseNumber = (t) => Number(t.replace(',', '.'));
56
+ /** True when the whole (trimmed) input is a single bare number, e.g. `42`, `-3.5`, `1,5`. */
57
+ export const isSingleNumber = (input) => new RegExp(`^${NUM_TOKEN}$`).test(input.trim());
58
+ /**
59
+ * Parse a numeric filter expression into a disjunction of conjunctions
60
+ * (OR groups, each an AND-combined list of clauses).
61
+ *
62
+ * Supported syntax:
63
+ * - operators `>`, `>=`, `<`, `<=`, `=`/`==`, `!=`/`<>` followed by a number (e.g. `> 100`, `=42`, `!=5`)
64
+ * - a bare number, treated as an exact match `= n` (e.g. `42`)
65
+ * - a range `a..b`, expanded to `>= a` and `<= b` (e.g. `10..20`)
66
+ * - `and` / `or` connectors (case-insensitive), e.g. `<10 or >20`, `>10 and <20`.
67
+ *
68
+ * Combining rules: an explicit `or` starts a new OR group, an explicit `and` keeps
69
+ * clauses in the same AND group. When no connector is given between two clauses the
70
+ * implicit connector is OR if both are exact (`=`) clauses — a value list such as
71
+ * `1 2 3` — and AND otherwise (comparisons narrow, e.g. `>10 <20`).
72
+ *
73
+ * Note: a lone bare number is parsed here as `= n`; callers that want the
74
+ * "contains" text-search behaviour for a single number must check {@link isSingleNumber}.
75
+ *
76
+ * Decimal separator may be `.` or `,`. Tokens that cannot be parsed are ignored.
77
+ */
78
+ export const parseNumericExpression = (input) => {
79
+ const groups = [];
80
+ if (!input)
81
+ return groups;
82
+ let current = [];
83
+ let pending = null; // explicit connector awaiting the next clause
84
+ let lastOp = null;
85
+ const flush = () => { if (current.length > 0) {
86
+ groups.push(current);
87
+ current = [];
88
+ } };
89
+ // add one AND-unit (a single clause, or the two bounds of a range), honouring the
90
+ // pending explicit connector or the implicit default (OR between two `=`, else AND)
91
+ const addUnit = (clauses) => {
92
+ const first = groups.length === 0 && current.length === 0;
93
+ if (!first) {
94
+ const connector = pending ?? ((lastOp === '=' && clauses[0].op === '=') ? 'or' : 'and');
95
+ if (connector === 'or')
96
+ flush();
97
+ }
98
+ current.push(...clauses);
99
+ pending = null;
100
+ lastOp = clauses[clauses.length - 1].op;
101
+ };
102
+ const tokenRe = new RegExp(`(${NUM_TOKEN})\\s*\\.\\.\\s*(${NUM_TOKEN})` + // 1,2 range a..b
103
+ `|(>=|<=|<>|!=|==|=|>|<)\\s*(${NUM_TOKEN})` + // 3,4 comparison clause
104
+ `|\\b(and|or)\\b` + // 5 connector
105
+ `|(${NUM_TOKEN})`, // 6 bare number (exact match)
106
+ 'gi');
107
+ let m;
108
+ while ((m = tokenRe.exec(input)) !== null) {
109
+ if (m[1] != null) {
110
+ addUnit([{ op: '>=', value: toClauseNumber(m[1]) }, { op: '<=', value: toClauseNumber(m[2]) }]);
111
+ }
112
+ else if (m[3] != null) {
113
+ const op = m[3] === '==' ? '=' : m[3] === '<>' ? '!=' : m[3];
114
+ addUnit([{ op, value: toClauseNumber(m[4]) }]);
115
+ }
116
+ else if (m[5] != null) {
117
+ pending = m[5].toLowerCase() === 'or' ? 'or' : 'and';
118
+ }
119
+ else if (m[6] != null) {
120
+ addUnit([{ op: '=', value: toClauseNumber(m[6]) }]);
121
+ }
122
+ }
123
+ flush();
124
+ return groups;
125
+ };
126
+ export const createNumericMatcher = (groups, property) => {
127
+ const test = (v, c) => {
128
+ switch (c.op) {
129
+ case '>': return v > c.value;
130
+ case '>=': return v >= c.value;
131
+ case '<': return v < c.value;
132
+ case '<=': return v <= c.value;
133
+ case '=': return v === c.value;
134
+ case '!=': return v !== c.value;
135
+ }
136
+ };
137
+ return (item) => {
138
+ if (groups.length === 0)
139
+ return true;
140
+ const raw = item[property];
141
+ if (raw == null || raw === '')
142
+ return false;
143
+ const v = typeof raw === 'number' ? raw : Number(raw);
144
+ if (Number.isNaN(v))
145
+ return false;
146
+ // value matches if it satisfies every clause of at least one OR group
147
+ return groups.some(group => group.every(c => test(v, c)));
148
+ };
149
+ };
53
150
  export const createCellMatcher = (type, term, property) => {
54
151
  property = property ?? 'value';
55
152
  if (isFilterRange(term))
56
153
  return createRangeMatcher(term, property, type);
154
+ if (type === 'n') {
155
+ const str = (term?.toString()) ?? '';
156
+ // a lone bare number -> plain "contains" text search; anything else -> numeric expression
157
+ if (isSingleNumber(str))
158
+ return createTextMatcher(str.trim(), 'formattedValue');
159
+ const groups = parseNumericExpression(str);
160
+ if (groups.length > 0)
161
+ return createNumericMatcher(groups, property);
162
+ return createTextMatcher(str, 'formattedValue');
163
+ }
57
164
  if (type === 'b')
58
165
  return createBoolMatcher(term, property);
59
166
  else if (type === 's' && Array.isArray(term))
@@ -1 +1 @@
1
- {"version":3,"file":"filterModel.js","sourceRoot":"","sources":["../../src/model/filterModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,GAAG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AI;QAC/B,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC3E,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QACvB,IAAI,aAAa;YAAE,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA;IACzD,CAAC;CAED","sourcesContent":["import { KeyValue, log, tree, utils } from \"@omegagrid/core\";\nimport { CellModel } from \"./cellModel\";\nimport { GridModel } from \"./gridModel\";\nimport { RowModel } from \"./rowModel\";\nimport { FilterOptions } from \"./options\";\nimport { CellType, FilterRange, FilterValue } from \"../types\";\n\nexport type FilterMatcher = (cell: CellModel) => boolean;\n\nexport type FilterSettings = {\n\tc: number;\n\tterm: FilterValue;\n};\n\nexport const createTextMatcher = <TItem>(term: string, property: keyof TItem) => {\n\tconst regex = new RegExp(`${utils.escapeRegExp(utils.removeAccents(term))}`, 'ig');\n\treturn (item: TItem) => {\n\t\tregex.lastIndex = 0;\n\t\treturn regex.test(utils.removeAccents((item[property] ?? \"\").toString()));\n\t}\n};\n\nexport const createBoolMatcher = <TItem>(term: boolean, property: keyof TItem) => {\n\treturn (item: TItem) => !!item[property] === term;\n};\n\nexport const createMultiMatcher = <TItem>(term: KeyValue[], property: keyof TItem) => {\n\tconst keys = term.map(t => t.key?.toString());\n\treturn (item: TItem) => {\n\t\treturn item[property] == null ? false : keys.includes(item[property].toString());\n\t};\n};\n\nexport const createMultiMultiMatcher = <TItem>(_term: KeyValue[], _property: keyof TItem) => {\n\treturn (_item: TItem) => false;\n};\n\nexport const isFilterRange = (term: FilterValue): term is FilterRange =>\n\t!!term && typeof term === 'object' && !Array.isArray(term) && (term as FilterRange).kind === 'range';\n\nexport const isFilterRangeEmpty = (term: FilterRange) =>\n\t(term.from == null || term.from === '') && (term.to == null || term.to === '');\n\nexport const createRangeMatcher = <TItem>(term: FilterRange, property: keyof TItem, type: CellType) => {\n\tconst toNum = (v: unknown): number | null => {\n\t\tif (v == null || v === '') return null;\n\t\tif (v instanceof Date) return v.getTime();\n\t\tif (type === 'd' || type === 'dt' || type === 'tm') {\n\t\t\tconst t = new Date(v as string).getTime();\n\t\t\treturn Number.isNaN(t) ? null : t;\n\t\t}\n\t\tconst n = typeof v === 'number' ? v : Number(v);\n\t\treturn Number.isNaN(n) ? null : n;\n\t};\n\n\tconst from = toNum(term.from);\n\tlet to = toNum(term.to);\n\t// move to the end of the day for date types\n\t// TODO: remove dt, when time picker is implemented\n\tif (to !== null && (type === 'd' || type === 'dt')) to += 24 * 60 * 60 * 1000 - 1;\n\n\treturn (item: TItem) => {\n\t\tconst v = toNum(item[property]);\n\t\tif (v === null) return false;\n\t\tif (from !== null && v < from) return false;\n\t\tif (to !== null && v > to) return false;\n\t\treturn true;\n\t};\n};\n\nexport const createCellMatcher = (type: CellType, term: FilterValue, property: keyof CellModel) => {\n\tproperty = property ?? 'value';\n\tif (isFilterRange(term)) return createRangeMatcher<CellModel>(term, property, type);\n\tif (type === 'b') return createBoolMatcher<CellModel>(term as boolean, property);\n\telse if (type === 's' && Array.isArray(term)) return createMultiMatcher<CellModel>((term as KeyValue[]), 'value');\n\telse if (type === 's') return createTextMatcher<CellModel>((term?.toString()), 'formattedValue');\n\telse if (type === 'm' && Array.isArray(term)) return createMultiMultiMatcher<CellModel>((term as KeyValue[]), property);\n\telse if (type === 'd') return createTextMatcher<CellModel>((term?.toString()) as string, 'formattedValue');\n\telse if (type === 'dt') return createTextMatcher<CellModel>((term?.toString()) as string, 'formattedValue');\n\telse if (type === 'tm') return createTextMatcher<CellModel>((term?.toString()) as string, 'formattedValue');\n\treturn createTextMatcher<CellModel>((term?.toString()) as string, property);\n}\n\nexport class FilterEvent extends Event {\n\tconstructor() {\n\t\tsuper('filter', {bubbles: false, cancelable: true, composed: true});\n\t}\n}\n\nexport class FilterModel extends EventTarget {\n\t\n\tpublic custom = false;\n\n\tprivate colMap = new Map<number, number>();\n\tprivate _settings: FilterSettings[] = [];\n\tget settings() { return this._settings }\n\tset settings(v: FilterSettings[]|null) {\n\t\tthis._settings = v || [];\n\t\tthis.colMap.clear();\n\t\tif (this.settings.length > 0) {\n\t\t\tthis.settings.forEach((s, i) => this.colMap.set(s.c, i));\n\t\t\tthis.applyFilter();\n\t\t\tlog.getLogger().info(`filtering applied: ${JSON.stringify(this.settings)}`);\n\t\t}\n\t}\n\n\tconstructor(\n\t\tpublic readonly model: GridModel,\n\t\tsettings: FilterSettings[]|null = null\n\t) {\n\t\tsuper();\n\t\tthis.settings = settings;\n\t}\n\n\t/**\n\t * Get filtering settings for specified column\n\t * @param c column index\n\t */\n\tget(c: number) {\n\t\treturn this.colMap.has(c) ? this.settings[this.colMap.get(c)] : null;\n\t}\n\n\tfilter(filter: FilterSettings, dispatchEvent = true) {\n\t\tconst filterSetting = this.get(filter.c);\n\t\tconst empty = filter.term === null || filter.term === ''\n\t\t\t|| (isFilterRange(filter.term) && isFilterRangeEmpty(filter.term));\n\n\t\tif (filterSetting && empty) {\n\t\t\t// remove; splice shifts the following slots, so the map must be rebuilt\n\t\t\tthis.settings.splice(this.colMap.get(filter.c), 1);\n\t\t\tthis.colMap.clear();\n\t\t\tthis.settings.forEach((s, i) => this.colMap.set(s.c, i));\n\t\t} else if (filterSetting) {\n\t\t\t// update\n\t\t\tfilterSetting.term = filter.term;\n\t\t} else if (!empty) {\n\t\t\t// add\n\t\t\tthis.colMap.set(filter.c, this.settings.length);\n\t\t\tthis.settings.push(filter);\n\t\t}\n\n\t\tif (!this.custom) {\n\t\t\tif (this.settings.length > 0) {\n\t\t\t\tthis.applyFilter(false);\n\t\t\t} else {\n\t\t\t\tthis.resetFilter(false);\n\t\t\t}\n\t\t}\n\n\t\tif (dispatchEvent) this.dispatchEvent(new FilterEvent())\n\t}\n\n\tapplyFilter(dispatchEvent = true) {\n\t\tconst cellMatchers: {c: number, matcher: FilterMatcher}[] = [];\n\t\tthis.settings.forEach((s) => {\n\t\t\tconst column = this.model.columns[s.c];\n\t\t\tcellMatchers.push({c: s.c, matcher: createCellMatcher(column.type, s.term, column.filter?.property)});\n\t\t});\n\n\t\tconst count = cellMatchers.length;\n\t\tconst rowMatcher = (row: RowModel) => {\n\t\t\tif (!row.filterable) return true;\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\tif (!cellMatchers[i].matcher(row.cell(cellMatchers[i].c))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\tconst includeParents = (this.model.options.filters as FilterOptions)?.includeParents ?? true;\n\t\tconst includeChildren = (this.model.options.filters as FilterOptions)?.includeChildren ?? true;\n\n\t\tconst visitedRows = new Set<number>();\n\t\tthis.model.rows.forEach(row => {\n\t\t\tconst visited = visitedRows.has(row.index);\n\n\t\t\tif (rowMatcher(row)) {\n\t\t\t\trow.filterState = tree.FilterState.Matched;\n\t\t\t\tif (includeParents) {\n\t\t\t\t\trow.walkUp((parent: RowModel) => {\n\t\t\t\t\t\tif (visitedRows.has(parent.index) && parent.filterState > 0) return false;\n\t\t\t\t\t\tparent.filterState = tree.FilterState.ChildMatched;\n\t\t\t\t\t\tvisitedRows.add(parent.index);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (includeChildren) {\n\t\t\t\t\trow.walk((child: RowModel) => {\n\t\t\t\t\t\tif (visitedRows.has(child.index) && child.filterState > 0) return false;\n\t\t\t\t\t\tchild.filterState = tree.FilterState.ParentMatched;\n\t\t\t\t\t\tvisitedRows.add(child.index);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else if (!visited) {\n\t\t\t\trow.filterState = tree.FilterState.Filtered;\n\t\t\t}\n\n\t\t\tvisitedRows.add(row.index);\n\t\t});\n\n\t\tthis.model.indexRows();\n\t\tif (dispatchEvent) this.dispatchEvent(new FilterEvent())\n\t}\n\n\tresetFilter(dispatchEvent = true) {\n\t\tthis.settings = [];\n\t\tthis.colMap.clear();\n\t\tthis.model.rows.forEach(row => row.filterState = tree.FilterState.Matched);\n\t\tthis.model.indexRows();\n\t\tif (dispatchEvent) this.dispatchEvent(new FilterEvent())\n\t}\n\n}"]}
1
+ {"version":3,"file":"filterModel.js","sourceRoot":"","sources":["../../src/model/filterModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAc7D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAQ,IAAY,EAAE,QAAqB,EAAE,EAAE;IAC/E,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACnF,OAAO,CAAC,IAAW,EAAE,EAAE;QACtB,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;QACpB,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAA;AACF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAQ,IAAa,EAAE,QAAqB,EAAE,EAAE;IAChF,OAAO,CAAC,IAAW,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAQ,IAAgB,EAAE,QAAqB,EAAE,EAAE;IACpF,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG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AAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QACvB,IAAI,aAAa;YAAE,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA;IACzD,CAAC;IAED,WAAW,CAAC,aAAa,GAAG,IAAI;QAC/B,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC3E,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QACvB,IAAI,aAAa;YAAE,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA;IACzD,CAAC;CAED","sourcesContent":["import { KeyValue, log, tree, utils } from \"@omegagrid/core\";\nimport { CellModel } from \"./cellModel\";\nimport { GridModel } from \"./gridModel\";\nimport { RowModel } from \"./rowModel\";\nimport { FilterOptions } from \"./options\";\nimport { CellType, FilterRange, FilterValue, NumericFilterClause, NumericFilterGroups, NumericFilterOperator } from \"../types\";\n\nexport type FilterMatcher = (cell: CellModel) => boolean;\n\nexport type FilterSettings = {\n\tc: number;\n\tterm: FilterValue;\n};\n\nexport const createTextMatcher = <TItem>(term: string, property: keyof TItem) => {\n\tconst regex = new RegExp(`${utils.escapeRegExp(utils.removeAccents(term))}`, 'ig');\n\treturn (item: TItem) => {\n\t\tregex.lastIndex = 0;\n\t\treturn regex.test(utils.removeAccents((item[property] ?? \"\").toString()));\n\t}\n};\n\nexport const createBoolMatcher = <TItem>(term: boolean, property: keyof TItem) => {\n\treturn (item: TItem) => !!item[property] === term;\n};\n\nexport const createMultiMatcher = <TItem>(term: KeyValue[], property: keyof TItem) => {\n\tconst keys = term.map(t => t.key?.toString());\n\treturn (item: TItem) => {\n\t\treturn item[property] == null ? false : keys.includes(item[property].toString());\n\t};\n};\n\nexport const createMultiMultiMatcher = <TItem>(_term: KeyValue[], _property: keyof TItem) => {\n\treturn (_item: TItem) => false;\n};\n\nexport const isFilterRange = (term: FilterValue): term is FilterRange =>\n\t!!term && typeof term === 'object' && !Array.isArray(term) && (term as FilterRange).kind === 'range';\n\nexport const isFilterRangeEmpty = (term: FilterRange) =>\n\t(term.from == null || term.from === '') && (term.to == null || term.to === '');\n\nexport const createRangeMatcher = <TItem>(term: FilterRange, property: keyof TItem, type: CellType) => {\n\tconst toNum = (v: unknown): number | null => {\n\t\tif (v == null || v === '') return null;\n\t\tif (v instanceof Date) return v.getTime();\n\t\tif (type === 'd' || type === 'dt' || type === 'tm') {\n\t\t\tconst t = new Date(v as string).getTime();\n\t\t\treturn Number.isNaN(t) ? null : t;\n\t\t}\n\t\tconst n = typeof v === 'number' ? v : Number(v);\n\t\treturn Number.isNaN(n) ? null : n;\n\t};\n\n\tconst from = toNum(term.from);\n\tlet to = toNum(term.to);\n\t// move to the end of the day for date types\n\t// TODO: remove dt, when time picker is implemented\n\tif (to !== null && (type === 'd' || type === 'dt')) to += 24 * 60 * 60 * 1000 - 1;\n\n\treturn (item: TItem) => {\n\t\tconst v = toNum(item[property]);\n\t\tif (v === null) return false;\n\t\tif (from !== null && v < from) return false;\n\t\tif (to !== null && v > to) return false;\n\t\treturn true;\n\t};\n};\n\n// number token: optional sign, digits, optional decimal part using '.' or ',' as separator\nconst NUM_TOKEN = '[-+]?\\\\d+(?:[.,]\\\\d+)?';\nconst toClauseNumber = (t: string) => Number(t.replace(',', '.'));\n\n/** True when the whole (trimmed) input is a single bare number, e.g. `42`, `-3.5`, `1,5`. */\nexport const isSingleNumber = (input: string) => new RegExp(`^${NUM_TOKEN}$`).test(input.trim());\n\n/**\n * Parse a numeric filter expression into a disjunction of conjunctions\n * (OR groups, each an AND-combined list of clauses).\n *\n * Supported syntax:\n * - operators `>`, `>=`, `<`, `<=`, `=`/`==`, `!=`/`<>` followed by a number (e.g. `> 100`, `=42`, `!=5`)\n * - a bare number, treated as an exact match `= n` (e.g. `42`)\n * - a range `a..b`, expanded to `>= a` and `<= b` (e.g. `10..20`)\n * - `and` / `or` connectors (case-insensitive), e.g. `<10 or >20`, `>10 and <20`.\n *\n * Combining rules: an explicit `or` starts a new OR group, an explicit `and` keeps\n * clauses in the same AND group. When no connector is given between two clauses the\n * implicit connector is OR if both are exact (`=`) clauses — a value list such as\n * `1 2 3` — and AND otherwise (comparisons narrow, e.g. `>10 <20`).\n *\n * Note: a lone bare number is parsed here as `= n`; callers that want the\n * \"contains\" text-search behaviour for a single number must check {@link isSingleNumber}.\n *\n * Decimal separator may be `.` or `,`. Tokens that cannot be parsed are ignored.\n */\nexport const parseNumericExpression = (input: string): NumericFilterGroups => {\n\tconst groups: NumericFilterClause[][] = [];\n\tif (!input) return groups;\n\n\tlet current: NumericFilterClause[] = [];\n\tlet pending: 'and' | 'or' | null = null; // explicit connector awaiting the next clause\n\tlet lastOp: NumericFilterOperator | null = null;\n\n\tconst flush = () => { if (current.length > 0) { groups.push(current); current = []; } };\n\n\t// add one AND-unit (a single clause, or the two bounds of a range), honouring the\n\t// pending explicit connector or the implicit default (OR between two `=`, else AND)\n\tconst addUnit = (clauses: NumericFilterClause[]) => {\n\t\tconst first = groups.length === 0 && current.length === 0;\n\t\tif (!first) {\n\t\t\tconst connector = pending ?? ((lastOp === '=' && clauses[0].op === '=') ? 'or' : 'and');\n\t\t\tif (connector === 'or') flush();\n\t\t}\n\t\tcurrent.push(...clauses);\n\t\tpending = null;\n\t\tlastOp = clauses[clauses.length - 1].op;\n\t};\n\n\tconst tokenRe = new RegExp(\n\t\t`(${NUM_TOKEN})\\\\s*\\\\.\\\\.\\\\s*(${NUM_TOKEN})` + // 1,2 range a..b\n\t\t`|(>=|<=|<>|!=|==|=|>|<)\\\\s*(${NUM_TOKEN})` + // 3,4 comparison clause\n\t\t`|\\\\b(and|or)\\\\b` + // 5 connector\n\t\t`|(${NUM_TOKEN})`, // 6 bare number (exact match)\n\t\t'gi'\n\t);\n\n\tlet m: RegExpExecArray | null;\n\twhile ((m = tokenRe.exec(input)) !== null) {\n\t\tif (m[1] != null) {\n\t\t\taddUnit([{ op: '>=', value: toClauseNumber(m[1]) }, { op: '<=', value: toClauseNumber(m[2]) }]);\n\t\t} else if (m[3] != null) {\n\t\t\tconst op: NumericFilterOperator = m[3] === '==' ? '=' : m[3] === '<>' ? '!=' : m[3] as NumericFilterOperator;\n\t\t\taddUnit([{ op, value: toClauseNumber(m[4]) }]);\n\t\t} else if (m[5] != null) {\n\t\t\tpending = m[5].toLowerCase() === 'or' ? 'or' : 'and';\n\t\t} else if (m[6] != null) {\n\t\t\taddUnit([{ op: '=', value: toClauseNumber(m[6]) }]);\n\t\t}\n\t}\n\tflush();\n\treturn groups;\n};\n\nexport const createNumericMatcher = <TItem>(groups: NumericFilterGroups, property: keyof TItem) => {\n\tconst test = (v: number, c: NumericFilterClause) => {\n\t\tswitch (c.op) {\n\t\t\tcase '>': return v > c.value;\n\t\t\tcase '>=': return v >= c.value;\n\t\t\tcase '<': return v < c.value;\n\t\t\tcase '<=': return v <= c.value;\n\t\t\tcase '=': return v === c.value;\n\t\t\tcase '!=': return v !== c.value;\n\t\t}\n\t};\n\treturn (item: TItem) => {\n\t\tif (groups.length === 0) return true;\n\t\tconst raw = item[property];\n\t\tif (raw == null || raw === '') return false;\n\t\tconst v = typeof raw === 'number' ? raw : Number(raw);\n\t\tif (Number.isNaN(v)) return false;\n\t\t// value matches if it satisfies every clause of at least one OR group\n\t\treturn groups.some(group => group.every(c => test(v, c)));\n\t};\n};\n\nexport const createCellMatcher = (type: CellType, term: FilterValue, property: keyof CellModel) => {\n\tproperty = property ?? 'value';\n\tif (isFilterRange(term)) return createRangeMatcher<CellModel>(term, property, type);\n\tif (type === 'n') {\n\t\tconst str = (term?.toString()) ?? '';\n\t\t// a lone bare number -> plain \"contains\" text search; anything else -> numeric expression\n\t\tif (isSingleNumber(str)) return createTextMatcher<CellModel>(str.trim(), 'formattedValue');\n\t\tconst groups = parseNumericExpression(str);\n\t\tif (groups.length > 0) return createNumericMatcher<CellModel>(groups, property);\n\t\treturn createTextMatcher<CellModel>(str, 'formattedValue');\n\t}\n\tif (type === 'b') return createBoolMatcher<CellModel>(term as boolean, property);\n\telse if (type === 's' && Array.isArray(term)) return createMultiMatcher<CellModel>((term as KeyValue[]), 'value');\n\telse if (type === 's') return createTextMatcher<CellModel>((term?.toString()), 'formattedValue');\n\telse if (type === 'm' && Array.isArray(term)) return createMultiMultiMatcher<CellModel>((term as KeyValue[]), property);\n\telse if (type === 'd') return createTextMatcher<CellModel>((term?.toString()) as string, 'formattedValue');\n\telse if (type === 'dt') return createTextMatcher<CellModel>((term?.toString()) as string, 'formattedValue');\n\telse if (type === 'tm') return createTextMatcher<CellModel>((term?.toString()) as string, 'formattedValue');\n\treturn createTextMatcher<CellModel>((term?.toString()) as string, property);\n}\n\nexport class FilterEvent extends Event {\n\tconstructor() {\n\t\tsuper('filter', {bubbles: false, cancelable: true, composed: true});\n\t}\n}\n\nexport class FilterModel extends EventTarget {\n\t\n\tpublic custom = false;\n\n\tprivate colMap = new Map<number, number>();\n\tprivate _settings: FilterSettings[] = [];\n\tget settings() { return this._settings }\n\tset settings(v: FilterSettings[]|null) {\n\t\tthis._settings = v || [];\n\t\tthis.colMap.clear();\n\t\tif (this.settings.length > 0) {\n\t\t\tthis.settings.forEach((s, i) => this.colMap.set(s.c, i));\n\t\t\tthis.applyFilter();\n\t\t\tlog.getLogger().info(`filtering applied: ${JSON.stringify(this.settings)}`);\n\t\t}\n\t}\n\n\tconstructor(\n\t\tpublic readonly model: GridModel,\n\t\tsettings: FilterSettings[]|null = null\n\t) {\n\t\tsuper();\n\t\tthis.settings = settings;\n\t}\n\n\t/**\n\t * Get filtering settings for specified column\n\t * @param c column index\n\t */\n\tget(c: number) {\n\t\treturn this.colMap.has(c) ? this.settings[this.colMap.get(c)] : null;\n\t}\n\n\tfilter(filter: FilterSettings, dispatchEvent = true) {\n\t\tconst filterSetting = this.get(filter.c);\n\t\tconst empty = filter.term === null || filter.term === ''\n\t\t\t|| (isFilterRange(filter.term) && isFilterRangeEmpty(filter.term));\n\n\t\tif (filterSetting && empty) {\n\t\t\t// remove; splice shifts the following slots, so the map must be rebuilt\n\t\t\tthis.settings.splice(this.colMap.get(filter.c), 1);\n\t\t\tthis.colMap.clear();\n\t\t\tthis.settings.forEach((s, i) => this.colMap.set(s.c, i));\n\t\t} else if (filterSetting) {\n\t\t\t// update\n\t\t\tfilterSetting.term = filter.term;\n\t\t} else if (!empty) {\n\t\t\t// add\n\t\t\tthis.colMap.set(filter.c, this.settings.length);\n\t\t\tthis.settings.push(filter);\n\t\t}\n\n\t\tif (!this.custom) {\n\t\t\tif (this.settings.length > 0) {\n\t\t\t\tthis.applyFilter(false);\n\t\t\t} else {\n\t\t\t\tthis.resetFilter(false);\n\t\t\t}\n\t\t}\n\n\t\tif (dispatchEvent) this.dispatchEvent(new FilterEvent())\n\t}\n\n\tapplyFilter(dispatchEvent = true) {\n\t\tconst cellMatchers: {c: number, matcher: FilterMatcher}[] = [];\n\t\tthis.settings.forEach((s) => {\n\t\t\tconst column = this.model.columns[s.c];\n\t\t\tcellMatchers.push({c: s.c, matcher: createCellMatcher(column.type, s.term, column.filter?.property)});\n\t\t});\n\n\t\tconst count = cellMatchers.length;\n\t\tconst rowMatcher = (row: RowModel) => {\n\t\t\tif (!row.filterable) return true;\n\t\t\tfor (let i = 0; i < count; i++) {\n\t\t\t\tif (!cellMatchers[i].matcher(row.cell(cellMatchers[i].c))) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\tconst includeParents = (this.model.options.filters as FilterOptions)?.includeParents ?? true;\n\t\tconst includeChildren = (this.model.options.filters as FilterOptions)?.includeChildren ?? true;\n\n\t\tconst visitedRows = new Set<number>();\n\t\tthis.model.rows.forEach(row => {\n\t\t\tconst visited = visitedRows.has(row.index);\n\n\t\t\tif (rowMatcher(row)) {\n\t\t\t\trow.filterState = tree.FilterState.Matched;\n\t\t\t\tif (includeParents) {\n\t\t\t\t\trow.walkUp((parent: RowModel) => {\n\t\t\t\t\t\tif (visitedRows.has(parent.index) && parent.filterState > 0) return false;\n\t\t\t\t\t\tparent.filterState = tree.FilterState.ChildMatched;\n\t\t\t\t\t\tvisitedRows.add(parent.index);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (includeChildren) {\n\t\t\t\t\trow.walk((child: RowModel) => {\n\t\t\t\t\t\tif (visitedRows.has(child.index) && child.filterState > 0) return false;\n\t\t\t\t\t\tchild.filterState = tree.FilterState.ParentMatched;\n\t\t\t\t\t\tvisitedRows.add(child.index);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else if (!visited) {\n\t\t\t\trow.filterState = tree.FilterState.Filtered;\n\t\t\t}\n\n\t\t\tvisitedRows.add(row.index);\n\t\t});\n\n\t\tthis.model.indexRows();\n\t\tif (dispatchEvent) this.dispatchEvent(new FilterEvent())\n\t}\n\n\tresetFilter(dispatchEvent = true) {\n\t\tthis.settings = [];\n\t\tthis.colMap.clear();\n\t\tthis.model.rows.forEach(row => row.filterState = tree.FilterState.Matched);\n\t\tthis.model.indexRows();\n\t\tif (dispatchEvent) this.dispatchEvent(new FilterEvent())\n\t}\n\n}"]}
package/dist/types.d.ts CHANGED
@@ -17,6 +17,18 @@ export type FilterRange = {
17
17
  to?: number | string | Date | null;
18
18
  };
19
19
  export type FilterValue = string | number | boolean | KeyValue[] | FilterRange;
20
+ /** Comparison operators usable in a numeric text filter expression (e.g. `> 100`). */
21
+ export type NumericFilterOperator = '=' | '!=' | '<' | '<=' | '>' | '>=';
22
+ export type NumericFilterClause = {
23
+ op: NumericFilterOperator;
24
+ value: number;
25
+ };
26
+ /**
27
+ * Parsed numeric expression as a disjunction of conjunctions: the outer array holds
28
+ * OR groups, each inner array holds clauses combined with AND. A value matches if it
29
+ * satisfies every clause of at least one group.
30
+ */
31
+ export type NumericFilterGroups = NumericFilterClause[][];
20
32
  /**
21
33
  * Actions = 'a',
22
34
  * Html = 'h'
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACjH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,KAAK,cAAc,CAAC;AAChF,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,KAAK,cAAc,CAAC;AAE7G,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,KAAK,MAAM,CAAC;AAE9D,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAE9D,MAAM,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,UAAU,EAAE,CAAA;CAErB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAC,OAAO,GAAC,YAAY,GAAC,eAAe,GAAC,YAAY,GAAC,eAAe,GAAC,UAAU,GAAC,aAAa,GAAC,UAAU,CAAC;AACrI,MAAM,MAAM,aAAa,GAAG,O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C;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;CACf,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,sBAAsB,EAAE,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,KAAK,EAAE,SAAS,CAAC;CACjB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACtC,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ColorTypes, Direction, Size, Location, UIValueType, Matrix, KeyValue, MenuItem } from \"@omegagrid/core\";\nimport { CSSStyle, CellModel, GridSource, Style, CommentItem, TableTheme } from \"./model\";\nimport { CellRange } from \"./common\";\n\nexport type Renderer = (div: HTMLDivElement, cell: CellModel) => HTMLDivElement;\nexport type CommentRenderer = (div: HTMLDivElement, comment: CommentItem, cell: CellModel) => HTMLDivElement;\n\nexport type Comparer = (a: CellModel, b: CellModel) => number;\n\nexport type FormulaFunction = (...args: unknown[]) => unknown;\n\nexport type BaseGroupModelSource = {\n\tmodels: GridSource[],\n\tthemes?: TableTheme[]\n\t//layout: TabSplitContainerModel\n}\n\nexport type EditType = 'value'|'style'|'insert_row'|'insert_column'|'delete_row'|'delete_column'|'move_row'|'move_column'|'autofill';\nexport type CellValueType = unknown; //number|string|boolean|object|null;\nexport type FilterRange = {\n\tkind: 'range',\n\tfrom?: number|string|Date|null,\n\tto?: number|string|Date|null,\n};\nexport type FilterValue = string|number|boolean|KeyValue[]|FilterRange;\n\n/**\n * Actions = 'a',\n * Html = 'h'\n */\nexport type AditionalUIValueType = 'a'|'h';\n\nexport type CellType = UIValueType | AditionalUIValueType;\n\nexport type StyleSource = number|string|Style|CSSStyle;\n\nexport type CellAction = {\n\taction: string,\n\ticon?: string,\n\ttext?: string,\n\ttitle?: string,\n\tcolor?: ColorTypes,\n\ttype?: 'button'|'menu',\n\titems?: MenuItem[]\n}\n\nexport type CellValidationSource = {\n\t/** Allow invalid cell values */\n\tallowInvalid?: boolean,\n\n\t/** Validation pattern */\n\tpattern?: string|RegExp,\n\n\t/** Validation function */\n\tvalidate?: (cell: CellModel, value: unknown) => boolean,\n}\n\nexport type CellValidation = Omit<CellValidationSource, 'pattern'> & {\n\t/** Validation pattern */\n\tpattern?: RegExp,\n}\n\nexport type ShiftOptions = {\n\t/** Index of the first shifted row/column */\n\tindex: number;\n\t/** Number of rows/columns to shift */\n\toffset: number;\n\t/** Shift direction up/down for rows, left/right for columns */\n\tdirection: Direction;\n\t/** Name of the sheet where the shift occured */\n\tsheet?: string;\n\t/** Force shift on all references */\n\tallSheets?: boolean;\n\t/** Maximum affected index */\n\tmaxIndex?: number;\n\t/** Shift anchored coords */\n\tignoreAnchors?: boolean;\n}\n\nexport type FormulaFuncParamDescription = {\n\tname: string,\n\ttype: string,\n\tdescription: string,\n\toptional: boolean,\n\tdefault?: string\n}\n\nexport type FormulaFuncDescription = {\n\tname: string,\n\tparams: FormulaFuncParamDescription[],\n\treturns: string,\n\tdescription: string,\n\tlinks: string[]\n}\n\nexport type FormulaFuncGroupDescription = {\n\tname: string,\n\tfunctions: FormulaFuncDescription[]\n}\n\nexport type TabOptions = {\n\tcolor?: string,\n\thidden?: boolean,\n}\n\nexport type ObjectModel = {\n\tlocation: Location;\n\tsize: Size;\n\tzIndex?: number;\n}\n\nexport type SpillOptions = {\n\tcell: CellModel; \n\tvalues: Matrix;\n\tpropertyCell?: CellModel;\n\tdisplayValues?: Matrix<string>;\n}\n\nexport type SpillResult = {\n\tcells: CellModel[];\n\toldValues: CellValueType[];\n\trange: CellRange;\n}\n\nexport type AutofitOptions = {\n\tvisibleOnly?: boolean;\n}\n\nexport type CellSerializationOptions = {\n\tdisplayValue?: boolean;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ColorTypes, Direction, Size, Location, UIValueType, Matrix, KeyValue, MenuItem } from \"@omegagrid/core\";\nimport { CSSStyle, CellModel, GridSource, Style, CommentItem, TableTheme } from \"./model\";\nimport { CellRange } from \"./common\";\n\nexport type Renderer = (div: HTMLDivElement, cell: CellModel) => HTMLDivElement;\nexport type CommentRenderer = (div: HTMLDivElement, comment: CommentItem, cell: CellModel) => HTMLDivElement;\n\nexport type Comparer = (a: CellModel, b: CellModel) => number;\n\nexport type FormulaFunction = (...args: unknown[]) => unknown;\n\nexport type BaseGroupModelSource = {\n\tmodels: GridSource[],\n\tthemes?: TableTheme[]\n\t//layout: TabSplitContainerModel\n}\n\nexport type EditType = 'value'|'style'|'insert_row'|'insert_column'|'delete_row'|'delete_column'|'move_row'|'move_column'|'autofill';\nexport type CellValueType = unknown; //number|string|boolean|object|null;\nexport type FilterRange = {\n\tkind: 'range',\n\tfrom?: number|string|Date|null,\n\tto?: number|string|Date|null,\n};\nexport type FilterValue = string|number|boolean|KeyValue[]|FilterRange;\n\n/** Comparison operators usable in a numeric text filter expression (e.g. `> 100`). */\nexport type NumericFilterOperator = '=' | '!=' | '<' | '<=' | '>' | '>=';\nexport type NumericFilterClause = { op: NumericFilterOperator, value: number };\n/**\n * Parsed numeric expression as a disjunction of conjunctions: the outer array holds\n * OR groups, each inner array holds clauses combined with AND. A value matches if it\n * satisfies every clause of at least one group.\n */\nexport type NumericFilterGroups = NumericFilterClause[][];\n\n/**\n * Actions = 'a',\n * Html = 'h'\n */\nexport type AditionalUIValueType = 'a'|'h';\n\nexport type CellType = UIValueType | AditionalUIValueType;\n\nexport type StyleSource = number|string|Style|CSSStyle;\n\nexport type CellAction = {\n\taction: string,\n\ticon?: string,\n\ttext?: string,\n\ttitle?: string,\n\tcolor?: ColorTypes,\n\ttype?: 'button'|'menu',\n\titems?: MenuItem[]\n}\n\nexport type CellValidationSource = {\n\t/** Allow invalid cell values */\n\tallowInvalid?: boolean,\n\n\t/** Validation pattern */\n\tpattern?: string|RegExp,\n\n\t/** Validation function */\n\tvalidate?: (cell: CellModel, value: unknown) => boolean,\n}\n\nexport type CellValidation = Omit<CellValidationSource, 'pattern'> & {\n\t/** Validation pattern */\n\tpattern?: RegExp,\n}\n\nexport type ShiftOptions = {\n\t/** Index of the first shifted row/column */\n\tindex: number;\n\t/** Number of rows/columns to shift */\n\toffset: number;\n\t/** Shift direction up/down for rows, left/right for columns */\n\tdirection: Direction;\n\t/** Name of the sheet where the shift occured */\n\tsheet?: string;\n\t/** Force shift on all references */\n\tallSheets?: boolean;\n\t/** Maximum affected index */\n\tmaxIndex?: number;\n\t/** Shift anchored coords */\n\tignoreAnchors?: boolean;\n}\n\nexport type FormulaFuncParamDescription = {\n\tname: string,\n\ttype: string,\n\tdescription: string,\n\toptional: boolean,\n\tdefault?: string\n}\n\nexport type FormulaFuncDescription = {\n\tname: string,\n\tparams: FormulaFuncParamDescription[],\n\treturns: string,\n\tdescription: string,\n\tlinks: string[]\n}\n\nexport type FormulaFuncGroupDescription = {\n\tname: string,\n\tfunctions: FormulaFuncDescription[]\n}\n\nexport type TabOptions = {\n\tcolor?: string,\n\thidden?: boolean,\n}\n\nexport type ObjectModel = {\n\tlocation: Location;\n\tsize: Size;\n\tzIndex?: number;\n}\n\nexport type SpillOptions = {\n\tcell: CellModel; \n\tvalues: Matrix;\n\tpropertyCell?: CellModel;\n\tdisplayValues?: Matrix<string>;\n}\n\nexport type SpillResult = {\n\tcells: CellModel[];\n\toldValues: CellValueType[];\n\trange: CellRange;\n}\n\nexport type AutofitOptions = {\n\tvisibleOnly?: boolean;\n}\n\nexport type CellSerializationOptions = {\n\tdisplayValue?: boolean;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/grid-core",
3
- "version": "0.10.62",
3
+ "version": "0.10.63",
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.62",
32
- "@omegagrid/localize": "^0.10.62",
31
+ "@omegagrid/core": "^0.10.63",
32
+ "@omegagrid/localize": "^0.10.63",
33
33
  "@stdlib/stats": "^0.0.13",
34
34
  "color": "^4.2.3",
35
35
  "date-fns": "^3.2.0",