@omegagrid/tree 0.10.0 → 0.10.2

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.
Files changed (85) hide show
  1. package/package.json +3 -3
  2. package/dist/adapters/dateAdapter.d.ts +0 -35
  3. package/dist/adapters/dateAdapter.d.ts.map +0 -1
  4. package/dist/adapters/dateAdapter.js +0 -222
  5. package/dist/adapters/dateAdapter.js.map +0 -1
  6. package/dist/adapters/index.d.ts +0 -2
  7. package/dist/adapters/index.d.ts.map +0 -1
  8. package/dist/adapters/index.js +0 -2
  9. package/dist/adapters/index.js.map +0 -1
  10. package/dist/constants.d.ts +0 -53
  11. package/dist/constants.d.ts.map +0 -1
  12. package/dist/constants.js +0 -11
  13. package/dist/constants.js.map +0 -1
  14. package/dist/index.d.ts +0 -6
  15. package/dist/index.d.ts.map +0 -1
  16. package/dist/index.js +0 -5
  17. package/dist/index.js.map +0 -1
  18. package/dist/model/filterModel.d.ts +0 -17
  19. package/dist/model/filterModel.d.ts.map +0 -1
  20. package/dist/model/filterModel.js +0 -60
  21. package/dist/model/filterModel.js.map +0 -1
  22. package/dist/model/index.d.ts +0 -5
  23. package/dist/model/index.d.ts.map +0 -1
  24. package/dist/model/index.js +0 -5
  25. package/dist/model/index.js.map +0 -1
  26. package/dist/model/nodeModel.d.ts +0 -100
  27. package/dist/model/nodeModel.d.ts.map +0 -1
  28. package/dist/model/nodeModel.js +0 -59
  29. package/dist/model/nodeModel.js.map +0 -1
  30. package/dist/model/selectionModel.d.ts +0 -39
  31. package/dist/model/selectionModel.d.ts.map +0 -1
  32. package/dist/model/selectionModel.js +0 -199
  33. package/dist/model/selectionModel.js.map +0 -1
  34. package/dist/model/treeAdapter.d.ts +0 -10
  35. package/dist/model/treeAdapter.d.ts.map +0 -1
  36. package/dist/model/treeAdapter.js +0 -10
  37. package/dist/model/treeAdapter.js.map +0 -1
  38. package/dist/model/treeModel.d.ts +0 -27
  39. package/dist/model/treeModel.d.ts.map +0 -1
  40. package/dist/model/treeModel.js +0 -97
  41. package/dist/model/treeModel.js.map +0 -1
  42. package/dist/options.d.ts +0 -35
  43. package/dist/options.d.ts.map +0 -1
  44. package/dist/options.js +0 -30
  45. package/dist/options.js.map +0 -1
  46. package/dist/types.d.ts +0 -42
  47. package/dist/types.d.ts.map +0 -1
  48. package/dist/types.js +0 -15
  49. package/dist/types.js.map +0 -1
  50. package/dist/ui/dropdown.d.ts +0 -68
  51. package/dist/ui/dropdown.d.ts.map +0 -1
  52. package/dist/ui/dropdown.js +0 -383
  53. package/dist/ui/dropdown.js.map +0 -1
  54. package/dist/ui/dropdown.style.d.ts +0 -2
  55. package/dist/ui/dropdown.style.d.ts.map +0 -1
  56. package/dist/ui/dropdown.style.js +0 -68
  57. package/dist/ui/dropdown.style.js.map +0 -1
  58. package/dist/ui/index.d.ts +0 -6
  59. package/dist/ui/index.d.ts.map +0 -1
  60. package/dist/ui/index.js +0 -6
  61. package/dist/ui/index.js.map +0 -1
  62. package/dist/ui/levels.d.ts +0 -13
  63. package/dist/ui/levels.d.ts.map +0 -1
  64. package/dist/ui/levels.js +0 -64
  65. package/dist/ui/levels.js.map +0 -1
  66. package/dist/ui/menu.d.ts +0 -14
  67. package/dist/ui/menu.d.ts.map +0 -1
  68. package/dist/ui/menu.js +0 -89
  69. package/dist/ui/menu.js.map +0 -1
  70. package/dist/ui/search.d.ts +0 -18
  71. package/dist/ui/search.d.ts.map +0 -1
  72. package/dist/ui/search.js +0 -82
  73. package/dist/ui/search.js.map +0 -1
  74. package/dist/ui/tree.d.ts +0 -86
  75. package/dist/ui/tree.d.ts.map +0 -1
  76. package/dist/ui/tree.js +0 -482
  77. package/dist/ui/tree.js.map +0 -1
  78. package/dist/ui/tree.renderer.d.ts +0 -7
  79. package/dist/ui/tree.renderer.d.ts.map +0 -1
  80. package/dist/ui/tree.renderer.js +0 -114
  81. package/dist/ui/tree.renderer.js.map +0 -1
  82. package/dist/ui/tree.style.d.ts +0 -3
  83. package/dist/ui/tree.style.d.ts.map +0 -1
  84. package/dist/ui/tree.style.js +0 -147
  85. package/dist/ui/tree.style.js.map +0 -1
package/dist/options.d.ts DELETED
@@ -1,35 +0,0 @@
1
- import { CommonOptions } from "@omegagrid/core";
2
- import { NodeModel } from "./model/nodeModel";
3
- import { FolderOptions, ItemProperty, ItemTypeOptions, SelectMode } from "./types";
4
- import { TemplateResult } from "lit-html";
5
- import { CSSResultOrNative } from "lit";
6
- import { SelectedItemParams } from "./model";
7
- export type Options = {
8
- alwaysRefresh?: boolean;
9
- nodeHeight?: number;
10
- renderingNodeTreshold?: number;
11
- selectMode?: SelectMode | string;
12
- levelIndent?: number;
13
- maxLevel?: number;
14
- globalLevels?: boolean;
15
- levelsAlwaysVisible?: boolean;
16
- checkboxes?: boolean;
17
- expanders?: boolean;
18
- allowEmpty?: boolean;
19
- autoClose?: boolean;
20
- search?: boolean;
21
- fileDrop?: boolean;
22
- pageSize?: number;
23
- customSearch?: boolean;
24
- folderOptions?: FolderOptions;
25
- itemProperties?: ItemProperty[];
26
- itemTypeOptions?: Record<string, ItemTypeOptions>;
27
- customStyle?: CSSResultOrNative | string | (CSSResultOrNative | string)[];
28
- nodeRenderer?: (div: HTMLDivElement, node: NodeModel) => string | TemplateResult<1> | void;
29
- afterRenderer?: (div: HTMLDivElement, node: NodeModel) => void;
30
- } & CommonOptions;
31
- export type TreeDropdownOptions = Options & {
32
- textRenderer?: (selectedItems: Map<string, SelectedItemParams>) => string | TemplateResult<1>;
33
- };
34
- export declare function initOptions(options?: Partial<Options>, origOptions?: Options): Options;
35
- //# sourceMappingURL=options.d.ts.map
@@ -1 +0,0 @@
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,eAA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AAE,cAAc,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;CAC9D,GAAG,aAAa,CAAC;AAElB,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG;IAC3C,YAAY,CAAC,EAAE,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,KAAK,MAAM,GAAC,cAAc,CAAC,CAAC,CAAC,CAAA;CAC3F,CAAA;AAqBD,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAE,OAAc,GAAG,OAAO,CAO5F"}
package/dist/options.js DELETED
@@ -1,30 +0,0 @@
1
- import constants from "./constants";
2
- import { initCommonOptions } from "@omegagrid/core";
3
- import { SelectMode } from "./types";
4
- const DEFAULT_OPTIONS = {
5
- nodeHeight: constants.DEFAULT_NODE_HEIGHT,
6
- renderingNodeTreshold: constants.RENDERING_NODE_TRESHOLD,
7
- selectMode: SelectMode.MultipleLevels,
8
- levelIndent: 10,
9
- maxLevel: null,
10
- globalLevels: true,
11
- levelsAlwaysVisible: true,
12
- allowEmpty: true,
13
- itemProperties: [],
14
- itemTypeOptions: {},
15
- expanders: true,
16
- search: false,
17
- checkboxes: true,
18
- autoClose: false,
19
- folderOptions: null,
20
- alwaysRefresh: false
21
- };
22
- export function initOptions(options, origOptions = null) {
23
- return {
24
- ...initCommonOptions(options, origOptions),
25
- ...DEFAULT_OPTIONS,
26
- ...origOptions,
27
- ...options,
28
- };
29
- }
30
- //# sourceMappingURL=options.js.map
@@ -1 +0,0 @@
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;AAkCnF,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;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\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};\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/dist/types.d.ts DELETED
@@ -1,42 +0,0 @@
1
- import { IconSpec } from "@omegagrid/core";
2
- import { NodeModel } from "./model";
3
- import { TemplateResult } from "lit-html";
4
- export declare enum SelectMode {
5
- None = "none",
6
- Single = "single",
7
- Multiple = "multiple",
8
- MultipleLevels = "multipleLevels"
9
- }
10
- export declare enum ItemPropertyType {
11
- Numeric = "n",
12
- Text = "t",
13
- Date = "d",
14
- Boolean = "b"
15
- }
16
- export type ItemProperty = {
17
- name: string;
18
- type: ItemPropertyType;
19
- format: string;
20
- };
21
- export type ItemTypeOptions = {
22
- folderIcon?: string;
23
- openFolderIcon?: string;
24
- };
25
- export type FolderOptions = {
26
- openIcon?: IconSpec | string;
27
- closedIcon?: IconSpec | string;
28
- };
29
- export type TreeAdapterParams = {
30
- parent?: NodeModel;
31
- parentKey?: string;
32
- offset?: number;
33
- filter?: string;
34
- };
35
- export type NodePlaceholder = {
36
- placeholder: true;
37
- parent: NodeModel;
38
- loading?: boolean;
39
- element?: HTMLElement;
40
- };
41
- export type TreeNodeRenderer = (div: HTMLDivElement, node: NodeModel) => string | TemplateResult<1> | void;
42
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,oBAAY,UAAU;IACrB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,cAAc,mBAAmB;CACjC;AAED,oBAAY,gBAAgB;IAC3B,OAAO,MAAM;IACb,IAAI,MAAM;IACV,IAAI,MAAM;IACV,OAAO,MAAM;CACb;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,EAAE,MAAM,CAAA;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAA;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,EAAE,QAAQ,GAAC,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,QAAQ,GAAC,MAAM,CAAA;CAC5B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CAEhB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC7B,WAAW,EAAE,IAAI,CAAC;IAClB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,WAAW,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,KAAK,MAAM,GAAC,cAAc,CAAC,CAAC,CAAC,GAAC,IAAI,CAAC"}
package/dist/types.js DELETED
@@ -1,15 +0,0 @@
1
- export var SelectMode;
2
- (function (SelectMode) {
3
- SelectMode["None"] = "none";
4
- SelectMode["Single"] = "single";
5
- SelectMode["Multiple"] = "multiple";
6
- SelectMode["MultipleLevels"] = "multipleLevels";
7
- })(SelectMode || (SelectMode = {}));
8
- export var ItemPropertyType;
9
- (function (ItemPropertyType) {
10
- ItemPropertyType["Numeric"] = "n";
11
- ItemPropertyType["Text"] = "t";
12
- ItemPropertyType["Date"] = "d";
13
- ItemPropertyType["Boolean"] = "b";
14
- })(ItemPropertyType || (ItemPropertyType = {}));
15
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACrB,2BAAa,CAAA;IACb,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;IACrB,+CAAiC,CAAA;AAClC,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB;AAED,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,iCAAa,CAAA;IACb,8BAAU,CAAA;IACV,8BAAU,CAAA;IACV,iCAAa,CAAA;AACd,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B","sourcesContent":["import { IconSpec } from \"@omegagrid/core\";\nimport { NodeModel } from \"./model\";\nimport { TemplateResult } from \"lit-html\";\n\nexport enum SelectMode {\n\tNone = 'none',\n\tSingle = 'single',\n\tMultiple = 'multiple',\n\tMultipleLevels = 'multipleLevels'\n}\n\nexport enum ItemPropertyType {\n\tNumeric = 'n',\n\tText = 't',\n\tDate = 'd',\n\tBoolean = 'b',\n}\n\nexport type ItemProperty = {\n\tname: string,\n\ttype: ItemPropertyType,\n\tformat: string\n};\n\nexport type ItemTypeOptions = {\n\tfolderIcon?: string,\n\topenFolderIcon?: string\n};\n\nexport type FolderOptions = {\n\topenIcon?: IconSpec|string,\n\tclosedIcon?: IconSpec|string\n};\n\nexport type TreeAdapterParams = {\n\tparent?: NodeModel,\n\tparentKey?: string,\n\toffset?: number,\n\tfilter?: string,\n\t//selectedValues?: SerializedValue[]\n}\n\nexport type NodePlaceholder = {\n\tplaceholder: true,\n\tparent: NodeModel,\n\tloading?: boolean,\n\telement?: HTMLElement\n}\n\nexport type TreeNodeRenderer = (div: HTMLDivElement, node: NodeModel) => string|TemplateResult<1>|void;"]}
@@ -1,68 +0,0 @@
1
- import { Button, Dropdown, Tooltip, Input } from "@omegagrid/core";
2
- import { TreeModel, TreeSource } from "../model/treeModel";
3
- import { SelectedItemParams, TreeSelectionModel, SerializedValue } from "../model/selectionModel";
4
- import { TreeDropdownOptions } from "../options";
5
- import { TreeAdapter } from "../model/treeAdapter";
6
- import { Tree, TreeEvent } from "./tree";
7
- import { NodeModel } from "../model";
8
- export declare class TreeDropdown extends Dropdown {
9
- static styles: import("lit").CSSResult[];
10
- options: TreeDropdownOptions;
11
- model: TreeModel;
12
- adapter: TreeAdapter;
13
- selection: TreeSelectionModel;
14
- maxHeight: number;
15
- maxWidth: number;
16
- value: SerializedValue[];
17
- cross: boolean;
18
- caption: string;
19
- placeholder: string;
20
- buttonInput: boolean;
21
- preventInputEnter: boolean;
22
- dynamicWidth: boolean;
23
- selectedItems: Map<string, SelectedItemParams>;
24
- button: Button;
25
- input: Input;
26
- contentDiv: HTMLDivElement;
27
- searchTerm: string;
28
- _tree: Tree;
29
- _renderDropdown: boolean;
30
- _firstOpen: boolean;
31
- _autoHighlight: boolean;
32
- originalWidth: number;
33
- _debounceWidthUpdate: {
34
- (this: unknown, ...args: [] & any[]): Promise<void>;
35
- cancel: (reason?: any) => void;
36
- };
37
- _onTreeRender: () => void;
38
- get hasCrossButton(): boolean;
39
- get tree(): Tree;
40
- tooltip: Tooltip;
41
- _onChange(e: TreeEvent): void;
42
- open(): Promise<void>;
43
- willUpdate(changedProps: Map<PropertyKey, unknown>): Promise<void>;
44
- filter(term: string): Promise<void>;
45
- clearFilter(): Promise<void>;
46
- focus(): void;
47
- constructor();
48
- connectedCallback(): void;
49
- setSourceData(sourceData: TreeSource, options?: Partial<TreeDropdownOptions>): void;
50
- updateOptions(options: Partial<TreeDropdownOptions>): void;
51
- adjustWidth(): void;
52
- clearSelection(dispatchEvent?: boolean): Promise<void>;
53
- _onMouseOver: () => void;
54
- _onMouseOut: () => void;
55
- getSelectionItems(): [NodeModel, [number, boolean][], boolean][];
56
- getButtonContentHtml(): string | import("lit-html").TemplateResult<1>;
57
- getSelectionHtml(): import("lit-html").TemplateResult<1>;
58
- getSelectionText(): string;
59
- _debounceFilter: {
60
- (this: unknown, ...args: [term: string] & any[]): Promise<void>;
61
- cancel: (reason?: any) => void;
62
- };
63
- _onInput: (e: InputEvent) => Promise<void>;
64
- _onInputKeyDown: (e: KeyboardEvent) => void;
65
- _onInputBlur: () => string;
66
- render: () => import("lit-html").TemplateResult<1>;
67
- }
68
- //# sourceMappingURL=dropdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAO,KAAK,EAAqB,MAAM,iBAAiB,CAAC;AAE3F,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe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AC,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,OAAO,CAAC,mBAAmB,CAAQ;IAMlF,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,mBAAmB,CAAC;IAKnD,WAAW;IAaL,cAAc,CAAC,aAAa,UAAQ;IAQ1C,YAAY,aASX;IAED,WAAW,aAEV;IAED,iBAAiB,IAAK,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE;IAgBjE,oBAAoB;IA2BpB,gBAAgB;IAehB,gBAAgB;IAOhB,eAAe;;uBAnTP,CAAC;MAsTD;IAER,QAAQ,GAAU,GAAG,UAAU,mBAK9B;IAED,eAAe,GAAI,GAAG,aAAa,UAmBlC;IAED,YAAY,eAAoD;IAEhE,MAAM,6CAqCJ;CACF"}
@@ -1,383 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { Dropdown, dom, ListSelectTrigger } from "@omegagrid/core";
8
- import { customElement, property, query, state } from "lit/decorators.js";
9
- import { TreeModel } from "../model/treeModel";
10
- import { TreeSelectionModel } from "../model/selectionModel";
11
- import { initOptions } from "../options";
12
- import { html } from "lit";
13
- import { Tree, TreeEvent } from "./tree";
14
- import { map } from 'lit/directives/map.js';
15
- import { join } from 'lit/directives/join.js';
16
- import { debounce } from "ts-debounce";
17
- import { NodeModel } from "../model";
18
- import { style } from "./dropdown.style";
19
- import { unsafeHTML } from "lit-html/directives/unsafe-html.js";
20
- import { html as htmlUtils } from "@omegagrid/core";
21
- let TreeDropdown = class TreeDropdown extends Dropdown {
22
- get hasCrossButton() {
23
- return this.cross && ((this.selection.count > 0 && this.options.allowEmpty) || this.searchTerm !== '');
24
- }
25
- get tree() {
26
- if (this._tree)
27
- return this._tree;
28
- this._tree = new Tree();
29
- this._tree.disableAutoload = true;
30
- this._tree.model = this.adapter ? null : this.model;
31
- this._tree.adapter = this.adapter;
32
- this._tree.selection = this.selection;
33
- this._tree.options = this.options;
34
- this._tree.maxHeight = this.maxHeight;
35
- this._tree.addEventListener('change', (e) => this._onChange(e));
36
- this._tree.addEventListener('render', this._onTreeRender);
37
- this._tree.slot = 'inner-content';
38
- return this._tree;
39
- }
40
- _onChange(e) {
41
- this._autoHighlight = false; // prevent autoscroll after manual selection
42
- this.selectedItems = null;
43
- this.selectedItems = e.component.selection.items;
44
- this.value = e.component.selection.serialize();
45
- if (this.options.autoClose)
46
- this.close();
47
- this.dispatchEvent(new TreeEvent(e.type, { component: e.component, node: e.node }));
48
- // if (this.input) {
49
- // setTimeout(() => this.input.focus(), 1000);
50
- // }
51
- }
52
- async open() {
53
- if (this.tree.parentElement != this.dropdown)
54
- this.dropdown.appendChild(this._tree);
55
- await super.open();
56
- }
57
- async willUpdate(changedProps) {
58
- if (this.buttonInput) {
59
- this.options.search = false;
60
- }
61
- if (changedProps.has('value')) {
62
- this.selection.setItems(this.value);
63
- this.selectedItems = null;
64
- this.selectedItems = this.selection.items;
65
- if (this.isOpen && this.tree) {
66
- if (this._autoHighlight) {
67
- this.tree.highlightFirstSelectedNode();
68
- }
69
- else {
70
- this._autoHighlight = true;
71
- }
72
- this.tree.renderItems(true);
73
- }
74
- }
75
- if (this._tree) {
76
- if (changedProps.has('adapter'))
77
- this._tree.adapter = this.adapter;
78
- if (changedProps.has('model'))
79
- this._tree.model = this.model;
80
- }
81
- if (changedProps.has('adapter') && this.adapter) {
82
- this._firstOpen = true; // force to reload data after opening dropdown
83
- this.options = initOptions(await this.adapter.getOptions(), this.options);
84
- }
85
- this._renderDropdown = true;
86
- }
87
- async filter(term) {
88
- if (this.input)
89
- this.searchTerm = term;
90
- await this.updateComplete;
91
- if (this.input)
92
- this.input.value = term;
93
- await this.tree.updateComplete;
94
- this.tree.filter(term);
95
- }
96
- async clearFilter() {
97
- if (this.input)
98
- this.searchTerm = '';
99
- await this.updateComplete;
100
- if (this.input)
101
- this.input.value = '';
102
- this.tree.clearFilter();
103
- }
104
- focus() {
105
- if (this.buttonInput)
106
- this.input?.focus();
107
- else
108
- super.focus();
109
- }
110
- constructor() {
111
- super();
112
- this.options = initOptions();
113
- this.selection = new TreeSelectionModel(this.options);
114
- this.maxHeight = 300;
115
- this.maxWidth = 400;
116
- this.cross = false;
117
- this.buttonInput = false;
118
- this.preventInputEnter = false;
119
- this.dynamicWidth = false;
120
- this.selectedItems = new Map();
121
- this.searchTerm = '';
122
- this._renderDropdown = true;
123
- this._firstOpen = true;
124
- this._autoHighlight = true;
125
- this.originalWidth = 0;
126
- this._debounceWidthUpdate = debounce(() => {
127
- if (!this.dropdown || !this.dropdown.isConnected)
128
- return;
129
- if (this.dynamicWidth)
130
- this.adjustWidth();
131
- dom.fixElementPosition(this.dropdown);
132
- });
133
- this._onTreeRender = () => {
134
- this._debounceWidthUpdate();
135
- };
136
- this.tooltip = dom.createElement('og-tooltip');
137
- this._onMouseOver = () => {
138
- if (this.contentDiv && this.contentDiv.scrollWidth > this.contentDiv.clientWidth) {
139
- if (!this.tooltip.parentElement) {
140
- document.body.appendChild(this.tooltip);
141
- dom.setSize(this.tooltip, { w: this.button.offsetWidth });
142
- }
143
- this.tooltip.content = this.getSelectionHtml();
144
- this.tooltip.attachTo(this.button, 'bottom');
145
- }
146
- };
147
- this._onMouseOut = () => {
148
- this.tooltip.deatach();
149
- };
150
- this._debounceFilter = debounce((term) => {
151
- this.tree.filter(term);
152
- this.dispatchEvent(new TreeEvent('tree.filter'));
153
- }, 300);
154
- this._onInput = async (e) => {
155
- if (!this.isOpen)
156
- await this.open();
157
- const value = e.target.value;
158
- this._debounceFilter(value);
159
- this.searchTerm = value;
160
- };
161
- this._onInputKeyDown = (e) => {
162
- switch (e.key) {
163
- case 'ArrowDown':
164
- e.preventDefault();
165
- this.tree.list.moveDown();
166
- break;
167
- case 'ArrowUp':
168
- e.preventDefault();
169
- this.tree.list.moveUp();
170
- break;
171
- case 'Enter':
172
- e.preventDefault();
173
- if (this.preventInputEnter)
174
- return;
175
- if (this.tree.list.selectedIndex > -1) {
176
- this.tree.list.select(this.tree.list.selectedIndex, ListSelectTrigger.Enter);
177
- setTimeout(() => this.input.focus(), 100);
178
- }
179
- break;
180
- }
181
- };
182
- this._onInputBlur = () => this.input.value = this.getSelectionText();
183
- this.render = () => html `
184
- ${this.buttonInput ? html `
185
- <og-input
186
- @input="${this._onInput}"
187
- @keydown="${this._onInputKeyDown}"
188
- @blur="${this._onInputBlur}"
189
- .value="${this.getSelectionText()}">
190
- </og-input>
191
- ` : ''}
192
-
193
- <og-button
194
- ?disabled="${this.disabled}"
195
- @mousedown="${this._onMousedown}"
196
- @mouseenter="${this._onMouseOver}"
197
- @mouseleave="${this._onMouseOut}"
198
- color="${this.color}"
199
- class="main"
200
- style="flex: 1"
201
- .caret="${this.noCaret ? 'none' : this.openDirection}">
202
- ${this.buttonInput ? '' : html `
203
- <div class="content" slot="content">
204
- ${this.getButtonContentHtml()}
205
- </div>
206
- `}
207
- </og-button>
208
-
209
- ${this.hasCrossButton ? html `
210
- <og-button
211
- class="cross"
212
- ?disabled="${this.disabled}"
213
- @mousedown="${() => this.clearSelection(true)}"
214
- icon="xmark"
215
- color="red">
216
- </og-button>
217
- ` : ``}
218
-
219
- ${this.renderDropdown()}
220
- `;
221
- this.addEventListener('dropdown.open', async () => {
222
- this.focus();
223
- if (this.adapter && (this._firstOpen || this.options.alwaysRefresh)) {
224
- await this.tree.loadData();
225
- }
226
- this._firstOpen = false;
227
- });
228
- }
229
- connectedCallback() {
230
- super.connectedCallback();
231
- if (!this.hasUpdated) {
232
- if (this.value)
233
- this.selection.setItems(this.value);
234
- this.selectedItems = this.selection.items;
235
- }
236
- }
237
- setSourceData(sourceData, options = null) {
238
- if (options)
239
- this.updateOptions(options);
240
- this.model = new TreeModel(sourceData, this.options);
241
- if (this._tree)
242
- this._tree.model = this.model;
243
- }
244
- updateOptions(options) {
245
- Object.assign(this.options, options ?? {});
246
- this.requestUpdate();
247
- }
248
- adjustWidth() {
249
- if (this.tree?.list && this.dropdown) {
250
- this.originalWidth = this.originalWidth || this.dropdown.offsetWidth;
251
- dom.setSize(this.dropdown, { w: Math.min(this.originalWidth, this.maxWidth) });
252
- const width = this.tree.list.calculateViewportMaxItemWidth();
253
- if (width > this.dropdown.offsetWidth) {
254
- dom.setSize(this.dropdown, { w: Math.min(width, this.maxWidth) });
255
- this.layout();
256
- }
257
- }
258
- }
259
- async clearSelection(dispatchEvent = false) {
260
- this.selection.clear();
261
- await this.clearFilter();
262
- this.requestUpdate();
263
- if (dispatchEvent)
264
- this.dispatchEvent(new TreeEvent('change', { component: this.tree }));
265
- this.tree?.renderItems(true);
266
- }
267
- getSelectionItems() {
268
- const model = this.tree?.model ?? this.model;
269
- return Array.from(this.selectedItems).map(([key, item]) => {
270
- const red = item.levels.has(0) && item.levels.get(0) == false;
271
- const levels = [...item.levels.entries()].filter(item2 => item2[0] > 0);
272
- const node = model?.nodeMap.has(key) ? model.nodeMap.get(key) : new NodeModel(this.tree.model, {
273
- k: key,
274
- v: item?.value ?? key
275
- });
276
- if (levels.length < item.levels.size && levels.length > 0) {
277
- levels.unshift([0, item.levels.get(0)]);
278
- }
279
- return [node, levels, red];
280
- });
281
- }
282
- getButtonContentHtml() {
283
- if (this.options?.textRenderer) {
284
- return this.options.textRenderer(this.selectedItems);
285
- }
286
- const items = this.getSelectionItems();
287
- const caption = this.caption ? html `<div class="caption">${this.caption}</div>` : null;
288
- const placeholder = this.placeholder ? html `<div class="placeholder">${this.placeholder}</div>` : null;
289
- return items.length > 0 ? html `${caption ? html `${caption}:` : ``}${join(map(items, ([node, levels, red]) => html `
290
- <div class="itm">
291
- ${node && node.icon ? html `<og-icon .icon="${node.icon}"></og-icon>` : null}
292
- ${red
293
- ? html `<div style="color:#ff0000">${node.value}</div>`
294
- : html `<div>${node.value}</div>`}
295
- ${levels.length > 0
296
- ? html `${map(levels, level => html `
297
- <og-icon class="lvl" icon="circle-${level[0]}">${level[0]}</og-icon>
298
- `)}` : ``}
299
- </div>
300
- `), html `<div class="sep">,</div>`)}` : (caption
301
- ? html `${caption}${placeholder ? html `: ${placeholder}` : ``}`
302
- : (placeholder ? html `${placeholder}` : html `&nbsp;`));
303
- }
304
- getSelectionHtml() {
305
- const items = this.getSelectionItems();
306
- if (items.length === 0)
307
- null;
308
- return html `${unsafeHTML(items.map(([node, levels, red]) => [
309
- node && node.icon ? `<og-icon icon="${node.icon}"></og-icon>` : ``,
310
- red
311
- ? `<span style="color:#ff0000">${node.value}</span>`
312
- : `<span>${node.value}</span>`,
313
- levels.length > 0
314
- ? levels.map(level => `<og-icon class="lvl" icon="circle-${level[0]}">${level[0]}</og-icon>`).join('')
315
- : ``
316
- ].join('')).join(', '))}`;
317
- }
318
- getSelectionText() {
319
- return this.getSelectionItems().map(([node, levels]) => htmlUtils.escapeHTML(node.value) + (levels.length > 0
320
- ? ` (${levels.map(level => level[0]).join(',')})`
321
- : '')).join(',');
322
- }
323
- };
324
- TreeDropdown.styles = [...Dropdown.styles, style];
325
- __decorate([
326
- property({ type: Object })
327
- ], TreeDropdown.prototype, "options", void 0);
328
- __decorate([
329
- property({ type: Object })
330
- ], TreeDropdown.prototype, "model", void 0);
331
- __decorate([
332
- property({ type: Object })
333
- ], TreeDropdown.prototype, "adapter", void 0);
334
- __decorate([
335
- property({ type: Object })
336
- ], TreeDropdown.prototype, "selection", void 0);
337
- __decorate([
338
- property({ type: Number })
339
- ], TreeDropdown.prototype, "maxHeight", void 0);
340
- __decorate([
341
- property({ type: Number })
342
- ], TreeDropdown.prototype, "maxWidth", void 0);
343
- __decorate([
344
- property({ type: Array })
345
- ], TreeDropdown.prototype, "value", void 0);
346
- __decorate([
347
- property({ type: Boolean, reflect: true })
348
- ], TreeDropdown.prototype, "cross", void 0);
349
- __decorate([
350
- property({ type: String })
351
- ], TreeDropdown.prototype, "caption", void 0);
352
- __decorate([
353
- property({ type: String })
354
- ], TreeDropdown.prototype, "placeholder", void 0);
355
- __decorate([
356
- property({ type: Boolean })
357
- ], TreeDropdown.prototype, "buttonInput", void 0);
358
- __decorate([
359
- property({ type: Boolean })
360
- ], TreeDropdown.prototype, "preventInputEnter", void 0);
361
- __decorate([
362
- property({ type: Boolean })
363
- ], TreeDropdown.prototype, "dynamicWidth", void 0);
364
- __decorate([
365
- state()
366
- ], TreeDropdown.prototype, "selectedItems", void 0);
367
- __decorate([
368
- query('og-button')
369
- ], TreeDropdown.prototype, "button", void 0);
370
- __decorate([
371
- query('og-input')
372
- ], TreeDropdown.prototype, "input", void 0);
373
- __decorate([
374
- query('.content')
375
- ], TreeDropdown.prototype, "contentDiv", void 0);
376
- __decorate([
377
- state()
378
- ], TreeDropdown.prototype, "searchTerm", void 0);
379
- TreeDropdown = __decorate([
380
- customElement('og-tree-dropdown')
381
- ], TreeDropdown);
382
- export { TreeDropdown };
383
- //# sourceMappingURL=dropdown.js.map