@omegagrid/tree 0.11.16 → 0.11.18

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":"filterModel.d.ts","sourceRoot":"","sources":["../../src/model/filterModel.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,aAAqE,CAAC;AAqD7G,qBAAa,WAAW;IASJ,KAAK,EAAE,SAAS;IAPnC,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,SAAS,CAA4B;IAE7C,IAAI,IAAI,WAAwB;IAEhC,IAAI,SAAS,YAAsD;gBAEhD,KAAK,EAAE,SAAS;IAEnC,MAAM,CAAC,IAAI,EAAE,MAAM;IA+BnB,KAAK;CAUL"}
1
+ {"version":3,"file":"filterModel.d.ts","sourceRoot":"","sources":["../../src/model/filterModel.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,aAAqE,CAAC;AAqD7G,qBAAa,WAAW;IASJ,KAAK,EAAE,SAAS;IAPnC,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,SAAS,CAA4B;IAE7C,IAAI,IAAI,WAAwB;IAEhC,IAAI,SAAS,YAAsD;gBAEhD,KAAK,EAAE,SAAS;IAEnC,MAAM,CAAC,IAAI,EAAE,MAAM;IAiCnB,KAAK;CAUL"}
@@ -63,6 +63,8 @@ export class FilterModel {
63
63
  filter(term) {
64
64
  this._term = term;
65
65
  const matcher = createMatcher(this._term, this._property, this.model.nodes);
66
+ // a match of the key selects the node, only the matches of the value are highlighted
67
+ const keyMatcher = this.model.options?.searchKeys ? createMatcher(this._term, 'key', this.model.nodes) : null;
66
68
  const hasTerm = splitTerms(term).length > 0;
67
69
  let matches;
68
70
  this.model.nodes.forEach(node => {
@@ -70,7 +72,7 @@ export class FilterModel {
70
72
  node.htmlValue = null;
71
73
  if (hasTerm) {
72
74
  matches = matcher(node);
73
- node.filterState = matches.length > 0 ? tree.FilterState.Matched : tree.FilterState.Filtered;
75
+ node.filterState = matches.length > 0 || keyMatcher?.(node).length > 0 ? tree.FilterState.Matched : tree.FilterState.Filtered;
74
76
  }
75
77
  else {
76
78
  node.filterState = tree.FilterState.Matched;
@@ -1 +1 @@
1
- {"version":3,"file":"filterModel.js","sourceRoot":"","sources":["../../src/model/filterModel.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAWvC;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAE7G,wGAAwG;AACxG,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAE,EAAE;IACzC,MA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/core';\nimport { tree } from '@omegagrid/core';\nimport { TreeModel } from './treeModel';\nimport { NodeModel } from './nodeModel';\n\nexport type FilterSettings = {\n\tterm: string;\n\tpropertyc: string;\n};\n\nexport type Matches = [number, number][];\n\n/**\n * Splits a search expression into terms - a comma separates them, the same way it separates\n * the values of a selection, so a selection text can be edited and searched again.\n */\nexport const splitTerms = (term: string) => (term ?? '').split(',').map(t => t.trim()).filter(t => t !== '');\n\n/** Sorts the matched ranges and merges the overlapping ones, the highlighting expects them in order. */\nconst mergeMatches = (matches: Matches) => {\n\tconst merged: Matches = [];\n\tmatches.sort((a, b) => a[0] - b[0] || a[1] - b[1]).forEach(match => {\n\t\tconst last = merged[merged.length - 1];\n\t\tif (last && match[0] <= last[1]) last[1] = Math.max(last[1], match[1]);\n\t\telse merged.push([match[0], match[1]]);\n\t});\n\treturn merged;\n};\n\nconst normalizeValue = (value: unknown) => utils.removeAccents((value ?? '').toString()).toLowerCase();\n\n/** Matches an item whose whole value is the term, the match covers the whole value. */\nconst createExactMatcher = <TItem>(term: string, property: keyof TItem) => {\n\tconst normalizedTerm = normalizeValue(term);\n\treturn (item: TItem) => {\n\t\tconst value = (item[property] ?? '').toString();\n\t\treturn (normalizeValue(value) === normalizedTerm ? [[0, value.length]] : []) as Matches;\n\t}\n};\n\n/** Matches an item having the term anywhere in its value, the matches are the found ranges. */\nconst createTermMatcher = <TItem>(term: string, property: keyof TItem) => {\n\tconst regex = new RegExp(`${utils.escapeRegExp(utils.removeAccents(term))}`, 'ig');\n\tlet match: RegExpExecArray;\n\treturn (item: TItem) => {\n\t\tconst matches: Matches = [];\n\t\twhile (match = regex.exec(utils.removeAccents((item[property] ?? \"\").toString()))) {\n\t\t\tmatches.push([match.index, regex.lastIndex]);\n\t\t}\n\t\treturn matches;\n\t}\n};\n\n/**\n * Matcher of a whole search expression - a match of any of its terms counts. A single term is\n * searched anywhere in the values, but in a list of terms a term equal to a value of some item\n * matches just that item, so a text of a selection can be edited and searched again.\n */\nconst createMatcher = (term: string, property: keyof NodeModel, nodes: NodeModel[]) => {\n\tconst terms = splitTerms(term);\n\tconst values = terms.length > 1 ? new Set(nodes.map(node => normalizeValue(node[property]))) : null;\n\tconst matchers = terms.map(t => values?.has(normalizeValue(t))\n\t\t? createExactMatcher<NodeModel>(t, property)\n\t\t: createTermMatcher<NodeModel>(t, property)\n\t);\n\treturn (node: NodeModel) => mergeMatches(matchers.flatMap(matcher => matcher(node)));\n};\n\n\nexport class FilterModel {\n\n\tprivate _term: string = null;\n\tprivate _property: keyof NodeModel = 'value';\n\n\tget term() { return this._term }\n\n\tget hasFilter() { return this._term !== '' && this._term !== null }\n\n\tconstructor(public model: TreeModel) { }\n\n\tfilter(term: string) {\n\t\tthis._term = term;\n\t\tconst matcher = createMatcher(this._term, this._property, this.model.nodes as NodeModel[]);\n\t\tconst hasTerm = splitTerms(term).length > 0;\n\t\tlet matches: Matches;\n\n\t\tthis.model.nodes.forEach(node => {\n\t\t\tnode.collapsed = false;\n\t\t\tnode.htmlValue = null;\n\t\t\tif (hasTerm) {\n\t\t\t\tmatches = matcher(node);\n\t\t\t\tnode.filterState = matches.length > 0 ? tree.FilterState.Matched : tree.FilterState.Filtered;\n\t\t\t} else {\n\t\t\t\tnode.filterState = tree.FilterState.Matched;\n\t\t\t\tnode.collapse();\n\t\t\t}\n\t\t\t\n\t\t\tif (node.filterState == tree.FilterState.Matched) {\n\t\t\t\tnode.walkUp(parentNode => {\n\t\t\t\t\tif (parentNode.filterState == tree.FilterState.Filtered) parentNode.filterState = tree.FilterState.ChildMatched;\n\t\t\t\t});\n\n\t\t\t\tif (hasTerm) {\n\t\t\t\t\tnode.htmlValue = html.highlightText(node.value, matches)\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.model.indexVisibleNodes();\n\t}\n\n\tclear() {\n\t\tthis._term = null;\n\t\tthis.model.nodes.forEach(node => {\n\t\t\tnode.filterState = tree.FilterState.Matched;\n\t\t\tnode.collapsed = false;\n\t\t\tnode.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AE,CAAC;gBAClD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;oBACxB,IAAI,UAAU,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ;wBAAE,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC;gBACjH,CAAC,CAAC,CAAC;gBAEH,IAAI,OAAO,EAAE,CAAC;oBACb,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;gBACzD,CAAC;YACF,CAAC;QACF,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAChC,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC/B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;YAC5C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;YACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACvB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAChC,CAAC;CAED","sourcesContent":["/* eslint \"@typescript-eslint/no-unused-vars\": \"off\" */\n\nimport { html, utils } from '@omegagrid/core';\nimport { tree } from '@omegagrid/core';\nimport { TreeModel } from './treeModel';\nimport { NodeModel } from './nodeModel';\n\nexport type FilterSettings = {\n\tterm: string;\n\tpropertyc: string;\n};\n\nexport type Matches = [number, number][];\n\n/**\n * Splits a search expression into terms - a comma separates them, the same way it separates\n * the values of a selection, so a selection text can be edited and searched again.\n */\nexport const splitTerms = (term: string) => (term ?? '').split(',').map(t => t.trim()).filter(t => t !== '');\n\n/** Sorts the matched ranges and merges the overlapping ones, the highlighting expects them in order. */\nconst mergeMatches = (matches: Matches) => {\n\tconst merged: Matches = [];\n\tmatches.sort((a, b) => a[0] - b[0] || a[1] - b[1]).forEach(match => {\n\t\tconst last = merged[merged.length - 1];\n\t\tif (last && match[0] <= last[1]) last[1] = Math.max(last[1], match[1]);\n\t\telse merged.push([match[0], match[1]]);\n\t});\n\treturn merged;\n};\n\nconst normalizeValue = (value: unknown) => utils.removeAccents((value ?? '').toString()).toLowerCase();\n\n/** Matches an item whose whole value is the term, the match covers the whole value. */\nconst createExactMatcher = <TItem>(term: string, property: keyof TItem) => {\n\tconst normalizedTerm = normalizeValue(term);\n\treturn (item: TItem) => {\n\t\tconst value = (item[property] ?? '').toString();\n\t\treturn (normalizeValue(value) === normalizedTerm ? [[0, value.length]] : []) as Matches;\n\t}\n};\n\n/** Matches an item having the term anywhere in its value, the matches are the found ranges. */\nconst createTermMatcher = <TItem>(term: string, property: keyof TItem) => {\n\tconst regex = new RegExp(`${utils.escapeRegExp(utils.removeAccents(term))}`, 'ig');\n\tlet match: RegExpExecArray;\n\treturn (item: TItem) => {\n\t\tconst matches: Matches = [];\n\t\twhile (match = regex.exec(utils.removeAccents((item[property] ?? \"\").toString()))) {\n\t\t\tmatches.push([match.index, regex.lastIndex]);\n\t\t}\n\t\treturn matches;\n\t}\n};\n\n/**\n * Matcher of a whole search expression - a match of any of its terms counts. A single term is\n * searched anywhere in the values, but in a list of terms a term equal to a value of some item\n * matches just that item, so a text of a selection can be edited and searched again.\n */\nconst createMatcher = (term: string, property: keyof NodeModel, nodes: NodeModel[]) => {\n\tconst terms = splitTerms(term);\n\tconst values = terms.length > 1 ? new Set(nodes.map(node => normalizeValue(node[property]))) : null;\n\tconst matchers = terms.map(t => values?.has(normalizeValue(t))\n\t\t? createExactMatcher<NodeModel>(t, property)\n\t\t: createTermMatcher<NodeModel>(t, property)\n\t);\n\treturn (node: NodeModel) => mergeMatches(matchers.flatMap(matcher => matcher(node)));\n};\n\n\nexport class FilterModel {\n\n\tprivate _term: string = null;\n\tprivate _property: keyof NodeModel = 'value';\n\n\tget term() { return this._term }\n\n\tget hasFilter() { return this._term !== '' && this._term !== null }\n\n\tconstructor(public model: TreeModel) { }\n\n\tfilter(term: string) {\n\t\tthis._term = term;\n\t\tconst matcher = createMatcher(this._term, this._property, this.model.nodes as NodeModel[]);\n\t\t// a match of the key selects the node, only the matches of the value are highlighted\n\t\tconst keyMatcher = this.model.options?.searchKeys ? createMatcher(this._term, 'key', this.model.nodes as NodeModel[]) : null;\n\t\tconst hasTerm = splitTerms(term).length > 0;\n\t\tlet matches: Matches;\n\n\t\tthis.model.nodes.forEach(node => {\n\t\t\tnode.collapsed = false;\n\t\t\tnode.htmlValue = null;\n\t\t\tif (hasTerm) {\n\t\t\t\tmatches = matcher(node);\n\t\t\t\tnode.filterState = matches.length > 0 || keyMatcher?.(node).length > 0 ? tree.FilterState.Matched : tree.FilterState.Filtered;\n\t\t\t} else {\n\t\t\t\tnode.filterState = tree.FilterState.Matched;\n\t\t\t\tnode.collapse();\n\t\t\t}\n\t\t\t\n\t\t\tif (node.filterState == tree.FilterState.Matched) {\n\t\t\t\tnode.walkUp(parentNode => {\n\t\t\t\t\tif (parentNode.filterState == tree.FilterState.Filtered) parentNode.filterState = tree.FilterState.ChildMatched;\n\t\t\t\t});\n\n\t\t\t\tif (hasTerm) {\n\t\t\t\t\tnode.htmlValue = html.highlightText(node.value, matches)\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.model.indexVisibleNodes();\n\t}\n\n\tclear() {\n\t\tthis._term = null;\n\t\tthis.model.nodes.forEach(node => {\n\t\t\tnode.filterState = tree.FilterState.Matched;\n\t\t\tnode.collapsed = false;\n\t\t\tnode.htmlValue = null;\n\t\t});\n\t\tthis.model.indexVisibleNodes();\n\t}\n\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"selectionModel.d.ts","sourceRoot":"","sources":["../../src/model/selectionModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,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AI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM;CAkB/C"}
@@ -74,6 +74,9 @@ export class TreeSelectionModel {
74
74
  this.items.clear();
75
75
  }
76
76
  validateChange(node, level, value) {
77
+ // a node without a checkbox (ch: false) is a group heading, it can be expanded but never picked
78
+ if (level == 0 && value && node.checkbox === false)
79
+ return false;
77
80
  if (this.options.selectMode == SelectMode.Single) {
78
81
  if (value === false && this.items.size == 1) {
79
82
  return false;
@@ -82,10 +85,12 @@ export class TreeSelectionModel {
82
85
  return true;
83
86
  }
84
87
  toggle(node, level) {
85
- let item = this.ensureItem(node.key, node.value);
86
- const currentValue = item.levels.has(level) ? item.levels.get(level) : null;
87
- if (!this.validateChange(node, level, item.levels.has(level) ? !item.levels.get(level) : true))
88
+ // validate before ensureItem, a rejected change must not leave an empty item behind
89
+ const existing = this.items.get(node.key);
90
+ const currentValue = existing?.levels.has(level) ? existing.levels.get(level) : null;
91
+ if (!this.validateChange(node, level, currentValue === null ? true : !currentValue))
88
92
  return this;
93
+ let item = this.ensureItem(node.key, node.value);
89
94
  if (currentValue) {
90
95
  item.levels.delete(level);
91
96
  }
@@ -119,9 +124,11 @@ export class TreeSelectionModel {
119
124
  return this;
120
125
  }
121
126
  select(node, level, value = true) {
122
- const item = this.ensureItem(node.key, node.value);
123
- if (!this.validateChange(node, level, value === null ? (item.levels.has(level) ? item.levels.get(level) : false) : value))
127
+ const existing = this.items.get(node.key);
128
+ const currentValue = existing?.levels.has(level) ? existing.levels.get(level) : false;
129
+ if (!this.validateChange(node, level, value === null ? currentValue : value))
124
130
  return this;
131
+ const item = this.ensureItem(node.key, node.value);
125
132
  if (value === true) {
126
133
  item.levels.set(level, true);
127
134
  }
@@ -141,7 +148,7 @@ export class TreeSelectionModel {
141
148
  * at least one of them, an unmatched filter never throws the selection away.
142
149
  */
143
150
  selectAll(replace = false) {
144
- const matched = this.model.nodes.filter(node => node.filterState == tree.FilterState.Matched);
151
+ const matched = this.model.nodes.filter(node => node.filterState == tree.FilterState.Matched && node.checkbox !== false);
145
152
  if (matched.length == 0)
146
153
  return 0;
147
154
  if (replace)
@@ -202,6 +209,9 @@ export class TreeSelectionModel {
202
209
  let value = null;
203
210
  node.walk((n) => {
204
211
  if (n.level - parentLevel == level) {
212
+ // group headings (ch: false) are never picked, they must not decide the direction either
213
+ if (n.checkbox === false)
214
+ return false;
205
215
  if (value === null) {
206
216
  value = this.getSelectionStatus(n) != NodeSelectionStatus.Checked;
207
217
  }
@@ -1 +1 @@
1
- {"version":3,"file":"selectionModel.js","sourceRoot":"","sources":["../../src/model/selectionModel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,MAAM,WAAW,GAAG,CAAe,GAAsB,EAAE,GAAS,EAAE,eAAuB,IAAI,EAAE,EAAE,CACpG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;AAE5C,MAAM,CAAN,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC9B,6DAAQ,CAAA;IACR,mEAAW,CAAA;IACX,mFAAmB,CAAA;IACnB,uEAAa,CAAA;AACd,CAAC,EALW,mBAAmB,KAAnB,mBAAmB,QAK9B;AAID,MAAM,UAAU,yBAAyB,CAAC,IAAuC;IAChF,OAAO,IAAI,CAAC,GAAG,CAAkB,IAAI,CAAC,EAAE;QACvC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACJ,CAAC;AAOD,MAAM,OAAO,kBAAkB;IAK9B,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,IA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,eAAe,CAAC;QAC5C,CAAC;QACD,OAAO,mBAAmB,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,gBAAgB,CAAC,IAAe,EAAE,KAAa;QAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC;QAC/B,IAAI,KAAK,GAAY,IAAI,CAAC;QAE1B,IAAI,CAAC,IAAI,CAAC,CAAC,CAAY,EAAE,EAAE;YAC1B,IAAI,CAAC,CAAC,KAAK,GAAG,WAAW,IAAI,KAAK,EAAE,CAAC;gBACpC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;oBACpB,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,mBAAmB,CAAC,OAAO,CAAC;gBACnE,CAAC;gBAED,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;gBACtC,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CAED","sourcesContent":["import { NodeModel, NodeSource } from \"./nodeModel\";\nimport { Options } from \"../options\";\nimport { SelectMode } from \"../types\";\nimport { TreeModel } from \".\";\nimport { tree } from \"@omegagrid/core\";\n\nconst getMapValue = <TKey, TValue>(map: Map<TKey, TValue>, key: TKey, defaultValue: TValue = null) =>\n\tmap.has(key) ? map.get(key) : defaultValue;\n\nexport enum NodeSelectionStatus {\n\tNone = 0,\n\tChecked = 1,\n\tCheckedByParent = 2,\n\tUnchecked = 3\n}\n\nexport type SerializedValue = [string, number?, (0|1)?, Partial<NodeSource>?];\n\nexport function normalizeSerializedValues(data: (string|number|SerializedValue)[]) {\n\treturn data.map<SerializedValue>(item => {\n\t\tif (Array.isArray(item)) return item;\n\t\treturn [item.toString(), 0, 1];\n\t});\n}\n\nexport type SelectedItemParams = {\n\tlevels: Map<number, boolean>,\n\tvalue?: string\n};\n\nexport class TreeSelectionModel {\n\n\titems = new Map<string, SelectedItemParams>();\n\tmodel: TreeModel;\n\n\tget count() {\n\t\treturn this.items.size;\n\t}\n\n\tconstructor(public options: Options, sourceData?: SerializedValue[]) {\n\t\tif (sourceData) {\n\t\t\tthis.populate(sourceData);\n\t\t}\n\t}\n\n\tensureItem(key: string, value?: string) {\n\t\tif (!this.items.has(key)) this.items.set(key, {levels: new Map<number, boolean>()});\n\t\tconst item = this.items.get(key);\n\t\tif (value != null) item.value = value;\n\t\treturn item;\t\n\t}\n\n\tsetItems(items: SerializedValue[]) {\n\t\tthis.populate(items ?? []);\n\t}\n\n\tpopulate(sourceData: SerializedValue[]) {\n\t\tconst oldItems = this.items;\n\t\tthis.items = new Map();\n\t\tsourceData.forEach(sourceItem => {\n\t\t\tconst value = sourceItem[3]?.v ?? sourceItem[3]?.value ?? oldItems.get(sourceItem[0])?.value;\n\t\t\tconst item = this.ensureItem(sourceItem[0], value);\n\t\t\titem.levels.set(sourceItem[1] ?? 0, (sourceItem[2] ?? 1) == 1);\n\t\t\tif (sourceItem[3]) Object.assign(item, sourceItem[3]);\n\t\t});\n\t}\n\n\tgetPropertySerializer(serializedProps?: (keyof NodeSource)[]) {\n\t\treturn (nodeKey: string, params: SelectedItemParams) => serializedProps.reduce((acc, key) => {\n\t\t\tif (key == 'v' || key == 'value') {\n\t\t\t\tacc[key] = params.value ?? this.model?.nodeMap.get(nodeKey)?.value;\n\t\t\t} else {\n\t\t\t\tacc[key] = this.model?.nodeMap.get(nodeKey)?.value;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} as Record<string, unknown>);\n\t}\n\n\tserialize(serializedProps?: (keyof NodeSource)[]) {\n\t\tconst items: SerializedValue[] = [];\n\t\tconst propertySerializer = serializedProps?.length ? this.getPropertySerializer(serializedProps) : null;\n\t\tthis.items.forEach((item, key) => {\n\t\t\tconst props = propertySerializer ? propertySerializer(key, item) : null;\n\t\t\titem.levels.forEach((value, level) => items.push(props \n\t\t\t\t? [key, level, value ? 1 : 0, props] \n\t\t\t\t: [key, level, value ? 1 : 0]\n\t\t\t));\n\t\t});\n\t\treturn items;\n\t}\n\n\tclear() {\n\t\tthis.items.clear();\n\t}\n\n\tvalidateChange(node: NodeModel, level: number, value: boolean) {\n\t\tif (this.options.selectMode == SelectMode.Single) {\n\t\t\tif (value === false && this.items.size == 1) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\ttoggle(node: NodeModel, level: number) {\n\t\tlet item = this.ensureItem(node.key, node.value);\n\t\tconst currentValue = item.levels.has(level) ? item.levels.get(level) : null;\n\t\t\n\t\tif (!this.validateChange(node, level, item.levels.has(level) ? !item.levels.get(level) : true)) return this;\n\n\t\tif (currentValue) {\n\t\t\titem.levels.delete(level);\n\t\t} else if (this.options.selectMode == SelectMode.MultipleLevels) {\n\t\t\tif (level == 0 && this.isSelectedByParent(node)) {\n\t\t\t\tif (currentValue === false) {\n\t\t\t\t\titem.levels.delete(0);\n\t\t\t\t} else {\n\t\t\t\t\titem.levels.set(0, false);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\titem.levels.set(level, true);\n\t\t\t}\n\t\t} else {\n\t\t\tif (this.options.selectMode == SelectMode.Single) {\n\t\t\t\tthis.clear();\n\t\t\t\titem = this.ensureItem(node.key, node.value);\n\t\t\t}\n\n\t\t\tif (level == 0) {\n\t\t\t\titem.levels.set(0, true);\n\t\t\t} else {\n\t\t\t\tthis.toggleChildNodes(node, level);\n\t\t\t}\n\t\t}\n\n\t\tif (item.levels.size == 0) this.clearItemSelection(node);\n\t\treturn this;\n\t}\n\t\n\tselect(node: NodeModel, level: number, value: boolean|null = true) {\n\t\tconst item = this.ensureItem(node.key, node.value);\n\n\t\tif (!this.validateChange(node, level, value === null ? (item.levels.has(level) ? item.levels.get(level) : false) : value)) return this;\n\n\t\tif (value === true) {\n\t\t\titem.levels.set(level, true);\n\t\t} else if (value === false && this.options.selectMode == SelectMode.MultipleLevels) {\n\t\t\titem.levels.set(level, false);\n\t\t} else {\n\t\t\titem.levels.delete(level);\n\t\t}\n\t\tif (item.levels.size == 0) this.clearItemSelection(node);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Selects every node matching the current filter, returns the number of them.\n\t * With replace, the matched nodes become the whole selection - but only when there is\n\t * at least one of them, an unmatched filter never throws the selection away.\n\t */\n\tselectAll(replace = false) {\n\t\tconst matched = this.model.nodes.filter(node => node.filterState == tree.FilterState.Matched);\n\t\tif (matched.length == 0) return 0;\n\t\tif (replace) this.clear();\n\t\tmatched.forEach(node => this.ensureItem(node.key, node.value).levels.set(0, true));\n\t\treturn matched.length;\n\t}\n\n\tdeselect(node: NodeModel, level: number) {\n\t\tif (!this.validateChange(node, level, false)) return this;\n\n\t\tif (this.items.has(node.key)) {\n\t\t\tthis.items.get(node.key).levels.delete(level);\n\t\t\tif (this.items.get(node.key).levels.size == 0) this.clearItemSelection(node);\n\t\t}\n\t\treturn this;\n\t}\n\t\n\tclearItemSelection(node: NodeModel) {\n\t\tthis.items.delete(node.key);\n\t}\n\n\tgetLevelSelection(node: NodeModel) {\n\t\treturn this.items.has(node.key)\n\t\t\t? this.items.get(node.key).levels\n\t\t\t: new Map<number, boolean>()\n\t}\n\n\tgetValue(node: NodeModel, level: number, defaultValue: boolean = null) {\n\t\tif (this.items.has(node.key)) {\n\t\t\treturn getMapValue(this.items.get(node.key).levels, level, defaultValue);\n\t\t}\n\t\treturn defaultValue;\n\t}\n\n\tisSelectedByParent(node: NodeModel) {\n\t\tlet parent = node.parent as NodeModel;\n\t\tlet levelSpan = 0;\n\t\twhile (parent) {\n\t\t\tif (this.getValue(parent, ++levelSpan, false)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tparent = parent.parent as NodeModel;\n\t\t}\n\t\treturn false;\n\t}\n\n\tgetSelectionStatus(node: NodeModel): NodeSelectionStatus {\n\t\tconst value = this.getValue(node, 0, null);\n\n\t\tif (value === true) {\n\t\t\treturn NodeSelectionStatus.Checked;\n\t\t} else if (value === false) {\n\t\t\treturn NodeSelectionStatus.Unchecked;\n\t\t} else if (this.options.selectMode == SelectMode.MultipleLevels && this.isSelectedByParent(node)) {\n\t\t\treturn NodeSelectionStatus.CheckedByParent;\n\t\t}\n\t\treturn NodeSelectionStatus.None;\n\t}\n\n\ttoggleChildNodes(node: NodeModel, level: number) {\n\t\tconst parentLevel = node.level;\n\t\tlet value: boolean = null;\n\n\t\tnode.walk((n: NodeModel) => {\n\t\t\tif (n.level - parentLevel == level) {\n\t\t\t\tif (value === null) {\n\t\t\t\t\tvalue = this.getSelectionStatus(n) != NodeSelectionStatus.Checked;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tthis.select(n, 0, value ? true : null)\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t}\n\n}"]}
1
+ {"version":3,"file":"selectionModel.js","sourceRoot":"","sources":["../../src/model/selectionModel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,MAAM,WAAW,GAAG,CAAe,GAAsB,EAAE,GAAS,EAAE,eAAuB,IAAI,EAAE,EAAE,CACpG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;AAE5C,MAAM,CAAN,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC9B,6DAAQ,CAAA;IACR,mEAAW,CAAA;IACX,mFAAmB,CAAA;IACnB,uEAAa,CAAA;AACd,CAAC,EALW,mBAAmB,KAAnB,mBAAmB,QAK9B;AAID,MAAM,UAAU,yBAAyB,CAAC,IAAuC;IAChF,OAAO,IAAI,CAAC,GAAG,CAAkB,IAAI,CAAC,EAAE;QACvC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QACrC,OAAO,CAAC,IAAI,C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","sourcesContent":["import { NodeModel, NodeSource } from \"./nodeModel\";\nimport { Options } from \"../options\";\nimport { SelectMode } from \"../types\";\nimport { TreeModel } from \".\";\nimport { tree } from \"@omegagrid/core\";\n\nconst getMapValue = <TKey, TValue>(map: Map<TKey, TValue>, key: TKey, defaultValue: TValue = null) =>\n\tmap.has(key) ? map.get(key) : defaultValue;\n\nexport enum NodeSelectionStatus {\n\tNone = 0,\n\tChecked = 1,\n\tCheckedByParent = 2,\n\tUnchecked = 3\n}\n\nexport type SerializedValue = [string, number?, (0|1)?, Partial<NodeSource>?];\n\nexport function normalizeSerializedValues(data: (string|number|SerializedValue)[]) {\n\treturn data.map<SerializedValue>(item => {\n\t\tif (Array.isArray(item)) return item;\n\t\treturn [item.toString(), 0, 1];\n\t});\n}\n\nexport type SelectedItemParams = {\n\tlevels: Map<number, boolean>,\n\tvalue?: string\n};\n\nexport class TreeSelectionModel {\n\n\titems = new Map<string, SelectedItemParams>();\n\tmodel: TreeModel;\n\n\tget count() {\n\t\treturn this.items.size;\n\t}\n\n\tconstructor(public options: Options, sourceData?: SerializedValue[]) {\n\t\tif (sourceData) {\n\t\t\tthis.populate(sourceData);\n\t\t}\n\t}\n\n\tensureItem(key: string, value?: string) {\n\t\tif (!this.items.has(key)) this.items.set(key, {levels: new Map<number, boolean>()});\n\t\tconst item = this.items.get(key);\n\t\tif (value != null) item.value = value;\n\t\treturn item;\t\n\t}\n\n\tsetItems(items: SerializedValue[]) {\n\t\tthis.populate(items ?? []);\n\t}\n\n\tpopulate(sourceData: SerializedValue[]) {\n\t\tconst oldItems = this.items;\n\t\tthis.items = new Map();\n\t\tsourceData.forEach(sourceItem => {\n\t\t\tconst value = sourceItem[3]?.v ?? sourceItem[3]?.value ?? oldItems.get(sourceItem[0])?.value;\n\t\t\tconst item = this.ensureItem(sourceItem[0], value);\n\t\t\titem.levels.set(sourceItem[1] ?? 0, (sourceItem[2] ?? 1) == 1);\n\t\t\tif (sourceItem[3]) Object.assign(item, sourceItem[3]);\n\t\t});\n\t}\n\n\tgetPropertySerializer(serializedProps?: (keyof NodeSource)[]) {\n\t\treturn (nodeKey: string, params: SelectedItemParams) => serializedProps.reduce((acc, key) => {\n\t\t\tif (key == 'v' || key == 'value') {\n\t\t\t\tacc[key] = params.value ?? this.model?.nodeMap.get(nodeKey)?.value;\n\t\t\t} else {\n\t\t\t\tacc[key] = this.model?.nodeMap.get(nodeKey)?.value;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} as Record<string, unknown>);\n\t}\n\n\tserialize(serializedProps?: (keyof NodeSource)[]) {\n\t\tconst items: SerializedValue[] = [];\n\t\tconst propertySerializer = serializedProps?.length ? this.getPropertySerializer(serializedProps) : null;\n\t\tthis.items.forEach((item, key) => {\n\t\t\tconst props = propertySerializer ? propertySerializer(key, item) : null;\n\t\t\titem.levels.forEach((value, level) => items.push(props \n\t\t\t\t? [key, level, value ? 1 : 0, props] \n\t\t\t\t: [key, level, value ? 1 : 0]\n\t\t\t));\n\t\t});\n\t\treturn items;\n\t}\n\n\tclear() {\n\t\tthis.items.clear();\n\t}\n\n\tvalidateChange(node: NodeModel, level: number, value: boolean) {\n\t\t// a node without a checkbox (ch: false) is a group heading, it can be expanded but never picked\n\t\tif (level == 0 && value && node.checkbox === false) return false;\n\t\tif (this.options.selectMode == SelectMode.Single) {\n\t\t\tif (value === false && this.items.size == 1) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\ttoggle(node: NodeModel, level: number) {\n\t\t// validate before ensureItem, a rejected change must not leave an empty item behind\n\t\tconst existing = this.items.get(node.key);\n\t\tconst currentValue = existing?.levels.has(level) ? existing.levels.get(level) : null;\n\n\t\tif (!this.validateChange(node, level, currentValue === null ? true : !currentValue)) return this;\n\n\t\tlet item = this.ensureItem(node.key, node.value);\n\t\tif (currentValue) {\n\t\t\titem.levels.delete(level);\n\t\t} else if (this.options.selectMode == SelectMode.MultipleLevels) {\n\t\t\tif (level == 0 && this.isSelectedByParent(node)) {\n\t\t\t\tif (currentValue === false) {\n\t\t\t\t\titem.levels.delete(0);\n\t\t\t\t} else {\n\t\t\t\t\titem.levels.set(0, false);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\titem.levels.set(level, true);\n\t\t\t}\n\t\t} else {\n\t\t\tif (this.options.selectMode == SelectMode.Single) {\n\t\t\t\tthis.clear();\n\t\t\t\titem = this.ensureItem(node.key, node.value);\n\t\t\t}\n\n\t\t\tif (level == 0) {\n\t\t\t\titem.levels.set(0, true);\n\t\t\t} else {\n\t\t\t\tthis.toggleChildNodes(node, level);\n\t\t\t}\n\t\t}\n\n\t\tif (item.levels.size == 0) this.clearItemSelection(node);\n\t\treturn this;\n\t}\n\t\n\tselect(node: NodeModel, level: number, value: boolean|null = true) {\n\t\tconst existing = this.items.get(node.key);\n\t\tconst currentValue = existing?.levels.has(level) ? existing.levels.get(level) : false;\n\n\t\tif (!this.validateChange(node, level, value === null ? currentValue : value)) return this;\n\n\t\tconst item = this.ensureItem(node.key, node.value);\n\t\tif (value === true) {\n\t\t\titem.levels.set(level, true);\n\t\t} else if (value === false && this.options.selectMode == SelectMode.MultipleLevels) {\n\t\t\titem.levels.set(level, false);\n\t\t} else {\n\t\t\titem.levels.delete(level);\n\t\t}\n\t\tif (item.levels.size == 0) this.clearItemSelection(node);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Selects every node matching the current filter, returns the number of them.\n\t * With replace, the matched nodes become the whole selection - but only when there is\n\t * at least one of them, an unmatched filter never throws the selection away.\n\t */\n\tselectAll(replace = false) {\n\t\tconst matched = this.model.nodes.filter(node => node.filterState == tree.FilterState.Matched && node.checkbox !== false);\n\t\tif (matched.length == 0) return 0;\n\t\tif (replace) this.clear();\n\t\tmatched.forEach(node => this.ensureItem(node.key, node.value).levels.set(0, true));\n\t\treturn matched.length;\n\t}\n\n\tdeselect(node: NodeModel, level: number) {\n\t\tif (!this.validateChange(node, level, false)) return this;\n\n\t\tif (this.items.has(node.key)) {\n\t\t\tthis.items.get(node.key).levels.delete(level);\n\t\t\tif (this.items.get(node.key).levels.size == 0) this.clearItemSelection(node);\n\t\t}\n\t\treturn this;\n\t}\n\t\n\tclearItemSelection(node: NodeModel) {\n\t\tthis.items.delete(node.key);\n\t}\n\n\tgetLevelSelection(node: NodeModel) {\n\t\treturn this.items.has(node.key)\n\t\t\t? this.items.get(node.key).levels\n\t\t\t: new Map<number, boolean>()\n\t}\n\n\tgetValue(node: NodeModel, level: number, defaultValue: boolean = null) {\n\t\tif (this.items.has(node.key)) {\n\t\t\treturn getMapValue(this.items.get(node.key).levels, level, defaultValue);\n\t\t}\n\t\treturn defaultValue;\n\t}\n\n\tisSelectedByParent(node: NodeModel) {\n\t\tlet parent = node.parent as NodeModel;\n\t\tlet levelSpan = 0;\n\t\twhile (parent) {\n\t\t\tif (this.getValue(parent, ++levelSpan, false)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tparent = parent.parent as NodeModel;\n\t\t}\n\t\treturn false;\n\t}\n\n\tgetSelectionStatus(node: NodeModel): NodeSelectionStatus {\n\t\tconst value = this.getValue(node, 0, null);\n\n\t\tif (value === true) {\n\t\t\treturn NodeSelectionStatus.Checked;\n\t\t} else if (value === false) {\n\t\t\treturn NodeSelectionStatus.Unchecked;\n\t\t} else if (this.options.selectMode == SelectMode.MultipleLevels && this.isSelectedByParent(node)) {\n\t\t\treturn NodeSelectionStatus.CheckedByParent;\n\t\t}\n\t\treturn NodeSelectionStatus.None;\n\t}\n\n\ttoggleChildNodes(node: NodeModel, level: number) {\n\t\tconst parentLevel = node.level;\n\t\tlet value: boolean = null;\n\n\t\tnode.walk((n: NodeModel) => {\n\t\t\tif (n.level - parentLevel == level) {\n\t\t\t\t// group headings (ch: false) are never picked, they must not decide the direction either\n\t\t\t\tif (n.checkbox === false) return false;\n\t\t\t\tif (value === null) {\n\t\t\t\t\tvalue = this.getSelectionStatus(n) != NodeSelectionStatus.Checked;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tthis.select(n, 0, value ? true : null)\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t}\n\n}"]}
package/dist/options.d.ts CHANGED
@@ -19,6 +19,8 @@ export type Options = {
19
19
  allowEmpty?: boolean;
20
20
  autoClose?: boolean;
21
21
  search?: boolean;
22
+ /** the search matches the keys of the nodes too, not just their values */
23
+ searchKeys?: boolean;
22
24
  fileDrop?: boolean;
23
25
  pageSize?: number;
24
26
  customSearch?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,OAAO,GAAG;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,UAAU,CAAC,EAAE,UAAU,GAAC,MAAM,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAC,UAAU,GAAC,QAAQ,GAAC,KAAK,CAAC;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB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QACN,GAAG,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC;QAC1C,GAAG,eAAe;QAClB,GAAG,WAAW;QACd,GAAG,OAAO;KACV,CAAC;AACH,CAAC","sourcesContent":["import constants from \"./constants\";\nimport { initCommonOptions, CommonOptions } from \"@omegagrid/core\";\nimport { NodeModel } from \"./model/nodeModel\";\nimport { FolderOptions, ItemProperty, ItemTypeOptions, SelectMode } from \"./types\";\nimport { TemplateResult } from \"lit-html\";\nimport { CSSResultOrNative } from \"lit\";\nimport { SelectedItemParams } from \"./model\";\n\nexport type Options = {\n\talwaysRefresh?: boolean,\n\tnodeHeight?: number,\n\trenderingNodeTreshold?: number,\n\tselectMode?: SelectMode|string,\n\tselectAllMode?: 'none'|'filtered'|'always'|false,\n\tlevelIndent?: number,\n\tmaxLevel?: number,\n\tglobalLevels?: boolean,\n\tlevelsAlwaysVisible?: boolean,\n\tcheckboxes?: boolean,\n\texpanders?: boolean,\n\tallowEmpty?: boolean,\n\tautoClose?: boolean,\n\tsearch?: boolean,\n\tfileDrop?: boolean,\n\tpageSize?: number,\n\tcustomSearch?: boolean,\n\tfolderOptions?: FolderOptions,\n\titemProperties?: ItemProperty[],\n\titemTypeOptions?: Record<string, ItemTypeOptions>,\n\tcustomStyle?: CSSResultOrNative|string|(CSSResultOrNative|string)[],\n\tnodeRenderer?: (div: HTMLDivElement, node: NodeModel) => string|TemplateResult<1>|void,\n\tafterRenderer?: (div: HTMLDivElement, node: NodeModel) => void\n} & CommonOptions;\n\nexport type TreeDropdownOptions = Options & {\n\ttextRenderer?: (selectedItems: Map<string, SelectedItemParams>) => string|TemplateResult<1>\n}\n\nconst DEFAULT_OPTIONS: Partial<Options> = {\n\tnodeHeight: constants.DEFAULT_NODE_HEIGHT,\n\trenderingNodeTreshold: constants.RENDERING_NODE_TRESHOLD,\n\tselectMode: SelectMode.MultipleLevels,\n\tlevelIndent: 10,\n\tmaxLevel: null,\n\tglobalLevels: true,\n\tlevelsAlwaysVisible: true,\n\tallowEmpty: true,\n\titemProperties: [],\n\titemTypeOptions: {},\n\texpanders: true,\n\tsearch: false,\n\tcheckboxes: true,\n\tautoClose: false,\n\tfolderOptions: null,\n\talwaysRefresh: false,\n\tselectAllMode: false\n};\n\nexport function initOptions(options?: Partial<Options>, origOptions: Options = null): Options {\n\treturn {\n\t\t...initCommonOptions(options, origOptions),\n\t\t...DEFAULT_OPTIONS,\n\t\t...origOptions,\n\t\t...options,\n\t};\n}"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAgD,UAAU,EAAE,MAAM,SAAS,CAAC;AAqCnF,MAAM,eAAe,GAAqB;IACzC,UAAU,EAAE,SAAS,CAAC,mBAAmB;IACzC,qBAAqB,EAAE,SAAS,CAAC,uBAAuB;IACxD,UAAU,EAAE,UAAU,CAAC,cAAc;IACrC,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,IAAI;IAClB,mBAAmB,EAAE,IAAI;IACzB,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,EAAE;IAClB,eAAe,EAAE,EAAE;IACnB,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,KAAK;IAChB,aAAa,EAAE,IAAI;IACnB,aAAa,EAAE,KAAK;IACpB,aAAa,EAAE,KAAK;CACpB,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,OAA0B,EAAE,cAAuB,IAAI;IAClF,OAAO;QACN,GAAG,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC;QAC1C,GAAG,eAAe;QAClB,GAAG,WAAW;QACd,GAAG,OAAO;KACV,CAAC;AACH,CAAC","sourcesContent":["import constants from \"./constants\";\nimport { initCommonOptions, CommonOptions } from \"@omegagrid/core\";\nimport { NodeModel } from \"./model/nodeModel\";\nimport { FolderOptions, ItemProperty, ItemTypeOptions, SelectMode } from \"./types\";\nimport { TemplateResult } from \"lit-html\";\nimport { CSSResultOrNative } from \"lit\";\nimport { SelectedItemParams } from \"./model\";\n\nexport type Options = {\n\talwaysRefresh?: boolean,\n\tnodeHeight?: number,\n\trenderingNodeTreshold?: number,\n\tselectMode?: SelectMode|string,\n\tselectAllMode?: 'none'|'filtered'|'always'|false,\n\tlevelIndent?: number,\n\tmaxLevel?: number,\n\tglobalLevels?: boolean,\n\tlevelsAlwaysVisible?: boolean,\n\tcheckboxes?: boolean,\n\texpanders?: boolean,\n\tallowEmpty?: boolean,\n\tautoClose?: boolean,\n\tsearch?: boolean,\n\t/** the search matches the keys of the nodes too, not just their values */\n\tsearchKeys?: boolean,\n\tfileDrop?: boolean,\n\tpageSize?: number,\n\tcustomSearch?: boolean,\n\tfolderOptions?: FolderOptions,\n\titemProperties?: ItemProperty[],\n\titemTypeOptions?: Record<string, ItemTypeOptions>,\n\tcustomStyle?: CSSResultOrNative|string|(CSSResultOrNative|string)[],\n\tnodeRenderer?: (div: HTMLDivElement, node: NodeModel) => string|TemplateResult<1>|void,\n\tafterRenderer?: (div: HTMLDivElement, node: NodeModel) => void\n} & CommonOptions;\n\nexport type TreeDropdownOptions = Options & {\n\ttextRenderer?: (selectedItems: Map<string, SelectedItemParams>) => string|TemplateResult<1>\n}\n\nconst DEFAULT_OPTIONS: Partial<Options> = {\n\tnodeHeight: constants.DEFAULT_NODE_HEIGHT,\n\trenderingNodeTreshold: constants.RENDERING_NODE_TRESHOLD,\n\tselectMode: SelectMode.MultipleLevels,\n\tlevelIndent: 10,\n\tmaxLevel: null,\n\tglobalLevels: true,\n\tlevelsAlwaysVisible: true,\n\tallowEmpty: true,\n\titemProperties: [],\n\titemTypeOptions: {},\n\texpanders: true,\n\tsearch: false,\n\tcheckboxes: true,\n\tautoClose: false,\n\tfolderOptions: null,\n\talwaysRefresh: false,\n\tselectAllMode: false\n};\n\nexport function initOptions(options?: Partial<Options>, origOptions: Options = null): Options {\n\treturn {\n\t\t...initCommonOptions(options, origOptions),\n\t\t...DEFAULT_OPTIONS,\n\t\t...origOptions,\n\t\t...options,\n\t};\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/tree",
3
- "version": "0.11.16",
3
+ "version": "0.11.18",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Universal treeview component",
6
6
  "main": "./dist/index.js",
@@ -27,8 +27,8 @@
27
27
  "_prepublish": "yarn test && yarn lint"
28
28
  },
29
29
  "dependencies": {
30
- "@omegagrid/core": "^0.11.16",
31
- "@omegagrid/localize": "^0.11.16",
30
+ "@omegagrid/core": "^0.11.18",
31
+ "@omegagrid/localize": "^0.11.18",
32
32
  "date-fns": "^3.2.0",
33
33
  "lit": "^3.1.1",
34
34
  "lit-html": "^3.1.1",