@omegagrid/commands 0.8.3 → 0.9.0
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.
- package/dist/adapters/adapter.d.ts +19 -0
- package/dist/adapters/adapter.d.ts.map +1 -0
- package/dist/adapters/adapter.js +23 -0
- package/dist/adapters/adapter.js.map +1 -0
- package/dist/adapters/commandsFlowAdapter.d.ts +25 -0
- package/dist/adapters/commandsFlowAdapter.d.ts.map +1 -0
- package/dist/adapters/commandsFlowAdapter.js +61 -0
- package/dist/adapters/commandsFlowAdapter.js.map +1 -0
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/commandManager.d.ts +34 -0
- package/dist/commandManager.d.ts.map +1 -0
- package/dist/commandManager.js +101 -0
- package/dist/commandManager.js.map +1 -0
- package/dist/common.d.ts +5 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +18 -0
- package/dist/common.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/model/commands.d.ts +54 -22
- package/dist/model/commands.d.ts.map +1 -1
- package/dist/model/commands.js +71 -52
- package/dist/model/commands.js.map +1 -1
- package/dist/model/index.d.ts +0 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +0 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/options.d.ts +6 -2
- package/dist/model/options.d.ts.map +1 -1
- package/dist/model/options.js +5 -1
- package/dist/model/options.js.map +1 -1
- package/dist/ui/commandWindow.d.ts +40 -27
- package/dist/ui/commandWindow.d.ts.map +1 -1
- package/dist/ui/commandWindow.js +249 -170
- package/dist/ui/commandWindow.js.map +1 -1
- package/dist/ui/commandWindow.style.d.ts.map +1 -1
- package/dist/ui/commandWindow.style.js +71 -9
- package/dist/ui/commandWindow.style.js.map +1 -1
- package/dist/ui/floatingCommandWindow.d.ts +7 -0
- package/dist/ui/floatingCommandWindow.d.ts.map +1 -0
- package/dist/ui/floatingCommandWindow.js +41 -0
- package/dist/ui/floatingCommandWindow.js.map +1 -0
- package/package.json +4 -2
- package/dist/model/adapter.d.ts +0 -9
- package/dist/model/adapter.d.ts.map +0 -1
- package/dist/model/adapter.js +0 -7
- package/dist/model/adapter.js.map +0 -1
package/dist/model/commands.js
CHANGED
|
@@ -1,84 +1,109 @@
|
|
|
1
1
|
import { utils } from "@omegagrid/core";
|
|
2
|
-
export class
|
|
3
|
-
constructor(
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export class Command {
|
|
3
|
+
constructor(source) {
|
|
4
|
+
if (source)
|
|
5
|
+
this.populate(source);
|
|
6
|
+
}
|
|
7
|
+
populate(source) {
|
|
8
|
+
this.id = source.id || source.name;
|
|
9
|
+
this.name = source.name || source.id;
|
|
10
|
+
this.group = source.group || 'default';
|
|
11
|
+
this._exec = source.exec;
|
|
12
|
+
this.props = source.props;
|
|
13
|
+
}
|
|
14
|
+
getSourceData() {
|
|
15
|
+
return {
|
|
16
|
+
id: this.id,
|
|
17
|
+
name: this.name,
|
|
18
|
+
group: this.group,
|
|
19
|
+
props: this.props,
|
|
20
|
+
exec: this._exec,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exec(value) {
|
|
24
|
+
return this._exec ? this._exec(this, value) : null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class CommandGroup {
|
|
28
|
+
constructor(source) {
|
|
6
29
|
this.commands = new Map();
|
|
7
30
|
this.open = true;
|
|
31
|
+
this.id = source.id || source.name;
|
|
32
|
+
this.name = source.name || source.id;
|
|
33
|
+
source.commands?.forEach(c => this.addCommand(c));
|
|
8
34
|
}
|
|
9
35
|
addCommand(command) {
|
|
10
|
-
|
|
36
|
+
const cmd = command instanceof Command ? command : new Command(command);
|
|
37
|
+
this.commands.set(cmd.id, cmd);
|
|
11
38
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
exec(...params) {
|
|
20
|
-
if (this.fn)
|
|
21
|
-
this.fn(...params);
|
|
39
|
+
getSourceData() {
|
|
40
|
+
return {
|
|
41
|
+
id: this.id,
|
|
42
|
+
name: this.name,
|
|
43
|
+
commands: Array.from([...this.commands].map(([_, c]) => c.getSourceData())),
|
|
44
|
+
};
|
|
22
45
|
}
|
|
23
46
|
}
|
|
24
47
|
export class Commands {
|
|
25
48
|
get count() {
|
|
26
49
|
let cnt = 0;
|
|
27
|
-
this.
|
|
50
|
+
this.groups.forEach(group => cnt += group.commands.size);
|
|
28
51
|
return cnt;
|
|
29
52
|
}
|
|
30
53
|
constructor(commands) {
|
|
31
|
-
this.
|
|
54
|
+
this.groups = new Map();
|
|
32
55
|
if (commands)
|
|
33
56
|
commands.forEach(c => this.register(c));
|
|
34
57
|
}
|
|
35
58
|
clear() {
|
|
36
|
-
this.
|
|
59
|
+
this.groups.clear();
|
|
37
60
|
return this;
|
|
38
61
|
}
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
return
|
|
62
|
+
registerGroup(group) {
|
|
63
|
+
const g = this.groups.has(group.id) ? this.groups.get(group.id) : new CommandGroup(group);
|
|
64
|
+
group.commands?.forEach(c => g.commands.set(c.id, new Command(c)));
|
|
65
|
+
this.groups.set(g.id, g);
|
|
66
|
+
return g;
|
|
44
67
|
}
|
|
45
68
|
removeSection(sectionId) {
|
|
46
|
-
this.
|
|
69
|
+
this.groups.delete(sectionId);
|
|
47
70
|
}
|
|
48
71
|
register(command) {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
72
|
+
const groupId = command.group || 'default';
|
|
73
|
+
const group = this.groups.get(groupId) || this.registerGroup({ id: groupId, name: groupId });
|
|
74
|
+
group.addCommand(command);
|
|
52
75
|
}
|
|
53
76
|
remove(name) {
|
|
54
|
-
this.
|
|
77
|
+
this.groups.forEach(group => group.commands.delete(name));
|
|
55
78
|
}
|
|
56
79
|
get(name) {
|
|
57
|
-
for (const
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
80
|
+
for (const group of this.groups.values()) {
|
|
81
|
+
if (group.commands.has(name))
|
|
82
|
+
return group.commands.get(name);
|
|
60
83
|
}
|
|
61
84
|
return null;
|
|
62
85
|
}
|
|
63
|
-
exec(
|
|
64
|
-
this.get(
|
|
86
|
+
exec(id, value) {
|
|
87
|
+
return this.get(id)?.exec(value);
|
|
65
88
|
}
|
|
66
|
-
filter(term,
|
|
89
|
+
filter(term, includeGroups = false, emptyGroups = false) {
|
|
67
90
|
const items = [];
|
|
68
91
|
const regex = term == null ? null : new RegExp(utils.escapeRegExp(term), 'ig');
|
|
69
|
-
for (const
|
|
70
|
-
let
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
92
|
+
for (const group of this.groups.values()) {
|
|
93
|
+
let groupIncluded = false;
|
|
94
|
+
const groupMatch = regex ? regex.test(group.name) : true;
|
|
95
|
+
if (groupMatch && emptyGroups) {
|
|
96
|
+
if (includeGroups) {
|
|
97
|
+
items.push(group);
|
|
98
|
+
}
|
|
99
|
+
groupIncluded = true;
|
|
75
100
|
}
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
if (
|
|
80
|
-
items.push(
|
|
81
|
-
|
|
101
|
+
if (group.open) {
|
|
102
|
+
group.commands.forEach(command => {
|
|
103
|
+
if (groupMatch || regex.test(command.name)) {
|
|
104
|
+
if (includeGroups && !groupIncluded) {
|
|
105
|
+
items.push(group);
|
|
106
|
+
groupIncluded = true;
|
|
82
107
|
}
|
|
83
108
|
items.push(command);
|
|
84
109
|
}
|
|
@@ -87,11 +112,5 @@ export class Commands {
|
|
|
87
112
|
}
|
|
88
113
|
return items;
|
|
89
114
|
}
|
|
90
|
-
merge(commands) {
|
|
91
|
-
const mergedCommands = new Commands();
|
|
92
|
-
this.sections.forEach(s => mergedCommands.registerSection(s));
|
|
93
|
-
commands.sections.forEach(s => mergedCommands.registerSection(s));
|
|
94
|
-
return mergedCommands;
|
|
95
|
-
}
|
|
96
115
|
}
|
|
97
116
|
//# sourceMappingURL=commands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/model/commands.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/model/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,EAAE,MAAM,iBAAiB,CAAC;AA6BpE,MAAM,OAAO,OAAO;IASnB,YAAY,MAAsB;QACjC,IAAI,MAAM;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ,CAAC,MAAqB;QAC7B,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,aAAa;QACZ,OAAO;YACN,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,KAAK;SAChB,CA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,IAAI,CAAC;YACzD,IAAI,UAAU,IAAI,WAAW,EAAE,CAAC;gBAC/B,IAAI,aAAa,EAAE,CAAC;oBACnB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC;gBACD,aAAa,GAAG,IAAI,CAAC;YACtB,CAAC;YAED,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;gBAChB,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;oBAChC,IAAI,UAAU,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC5C,IAAI,aAAa,IAAI,CAAC,aAAa,EAAE,CAAC;4BACrC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;4BAClB,aAAa,GAAG,IAAI,CAAC;wBACtB,CAAC;wBACD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACrB,CAAC;gBACF,CAAC,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CASD","sourcesContent":["import { CustomProperties, IconSpec, utils } from \"@omegagrid/core\";\nimport { TabItem } from \"@omegagrid/tabs\";\n\nexport type CommandSectionSwitch = {\n\tkey: string,\n\tvalue: string,\n\tchecked?: boolean,\n\ticon?: IconSpec|string,\n}\n\nexport type CommandsSection = TabItem & {\n\tplaceholder?: string,\n\ttriggerCommand?: string,\n\tswitches?: CommandSectionSwitch[],\n}\n\nexport type CommandMode = 'search' | 'input' | 'none';\nexport type CommandInput = {id: string, value?: string};\nexport type CommandFunction = (command: Command, value?: string) => void|Promise<void>;\n\t\nexport type CommandSource = {\n\tid?: string;\n\tname?: string;\n\tvalue?: string;\n\tgroup?: string;\n\texec?: CommandFunction;\n\tprops?: CustomProperties;\n}\n\nexport class Command {\n\n\tid: string;\n\tname: string;\n\tgroup: string;\n\tprops: CustomProperties;\n\n\tprivate _exec: CommandFunction;\n\n\tconstructor(source?: CommandSource) {\n\t\tif (source) this.populate(source);\n\t}\n\n\tpopulate(source: CommandSource) {\n\t\tthis.id = source.id || source.name;\n\t\tthis.name = source.name || source.id;\n\t\tthis.group = source.group || 'default';\n\t\tthis._exec = source.exec;\n\t\tthis.props = source.props;\n\t}\n\n\tgetSourceData(): CommandSource {\n\t\treturn {\n\t\t\tid: this.id,\n\t\t\tname: this.name,\n\t\t\tgroup: this.group,\n\t\t\tprops: this.props,\n\t\t\texec: this._exec,\n\t\t};\n\t}\n\n\texec(value?: string) {\n\t\treturn this._exec ? this._exec(this, value) : null;\n\t}\n\n}\n\nexport type CommandGroupSource = {\n\tid: string,\n\tname?: string\n\tcommands?: CommandSource[];\n}\n\nexport class CommandGroup {\n\n\tpublic readonly commands = new Map<string, Command>();\n\tpublic readonly id: string;\n\tpublic readonly name: string;\n\tpublic open = true;\n\n\tconstructor(source: CommandGroupSource) {\n\t\tthis.id = source.id || source.name;\n\t\tthis.name = source.name || source.id;\n\t\tsource.commands?.forEach(c => this.addCommand(c));\n\t}\n\n\taddCommand(command: Command|CommandSource) {\n\t\tconst cmd = command instanceof Command ? command : new Command(command);\n\t\tthis.commands.set(cmd.id, cmd);\n\t}\n\n\tgetSourceData(): CommandGroupSource {\n\t\treturn {\n\t\t\tid: this.id,\n\t\t\tname: this.name,\n\t\t\tcommands: Array.from([...this.commands].map(([_, c]) => c.getSourceData())),\n\t\t};\n\t}\n\n}\n\nexport class Commands {\n\t\n\tpublic readonly groups = new Map<string, CommandGroup>();\n\n\tget count() {\n\t\tlet cnt = 0;\n\t\tthis.groups.forEach(group => cnt += group.commands.size);\n\t\treturn cnt;\n\t}\n\n\tconstructor(commands?: CommandSource[]) {\n\t\tif (commands) commands.forEach(c => this.register(c));\n\t}\n\n\tclear() {\n\t\tthis.groups.clear();\n\t\treturn this;\n\t}\n\n\tregisterGroup(group: CommandGroupSource) {\n\t\tconst g = this.groups.has(group.id) ? this.groups.get(group.id) : new CommandGroup(group);\n\t\tgroup.commands?.forEach(c => g.commands.set(c.id, new Command(c)));\n\t\tthis.groups.set(g.id, g);\n\t\treturn g;\n\t}\n\n\tremoveSection(sectionId: string) {\n\t\tthis.groups.delete(sectionId);\n\t}\n\t\n\tregister(command: Command|CommandSource) {\n\t\tconst groupId = command.group || 'default';\n\t\tconst group = this.groups.get(groupId) || this.registerGroup({id: groupId, name: groupId});\n\t\tgroup.addCommand(command);\n\t}\n\n\tremove(name: string) {\n\t\tthis.groups.forEach(group => group.commands.delete(name));\n\t}\n\n\tget(name: string) {\n\t\tfor (const group of this.groups.values()) {\n\t\t\tif (group.commands.has(name)) return group.commands.get(name);\n\t\t}\n\t\treturn null;\n\t}\n\n\texec(id: string, value?: string) {\n\t\treturn this.get(id)?.exec(value);\n\t}\n\n\tfilter(term?: string, includeGroups = false, emptyGroups = false): (CommandGroup|Command)[] {\n\t\tconst items: (CommandGroup|Command)[] = [];\n\t\tconst regex = term == null ? null : new RegExp(utils.escapeRegExp(term), 'ig');\n\t\tfor (const group of this.groups.values()) {\n\t\t\tlet groupIncluded = false;\n\t\t\tconst groupMatch = regex ? regex.test(group.name) : true;\n\t\t\tif (groupMatch && emptyGroups) {\n\t\t\t\tif (includeGroups) {\n\t\t\t\t\titems.push(group);\n\t\t\t\t}\n\t\t\t\tgroupIncluded = true;\n\t\t\t}\n\n\t\t\tif (group.open) {\n\t\t\t\tgroup.commands.forEach(command => {\n\t\t\t\t\tif (groupMatch || regex.test(command.name)) {\n\t\t\t\t\t\tif (includeGroups && !groupIncluded) {\n\t\t\t\t\t\t\titems.push(group);\n\t\t\t\t\t\t\tgroupIncluded = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\titems.push(command);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn items;\n\t}\n\n\t// merge(commands: Commands): Commands {\n\t// \tconst mergedCommands = new Commands();\n\t// \tthis.groups.forEach(g => mergedCommands.registerGroup(g.getSourceData()));\n\t// \tcommands.groups.forEach(g => mergedCommands.registerGroup(g.getSourceData()));\n\t// \treturn mergedCommands;\n\t// }\n\n}"]}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
package/dist/model/index.js
CHANGED
package/dist/model/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC","sourcesContent":["export * from './commands';\nexport * from './options';\n"]}
|
package/dist/model/options.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { CommonOptions } from "@omegagrid/core";
|
|
2
|
-
import { CommandRenderer,
|
|
2
|
+
import { CommandRenderer, GroupRenderer } from "../ui";
|
|
3
|
+
import { CSSResultOrNative } from "lit";
|
|
3
4
|
export type Options = {
|
|
4
5
|
commandRenderer?: CommandRenderer;
|
|
5
|
-
|
|
6
|
+
groupRenderer?: GroupRenderer;
|
|
7
|
+
commandDelimiter?: string;
|
|
8
|
+
itemStyle?: CSSResultOrNative | string | (CSSResultOrNative | string)[];
|
|
9
|
+
itemHeight?: number;
|
|
6
10
|
} & CommonOptions;
|
|
7
11
|
export declare function initOptions(options?: Partial<Options>, origOptions?: Options): Options;
|
|
8
12
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/model/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/model/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAC;AAGxC,MAAM,MAAM,OAAO,GAAG;IACrB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,iBAAiB,GAAC,MAAM,GAAC,CAAC,iBAAiB,GAAC,MAAM,CAAC,EAAE,CAAC;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,aAAa,CAAC;AAOlB,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAE,OAAc,GAAG,OAAO,CAS5F"}
|
package/dist/model/options.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { initCommonOptions } from "@omegagrid/core";
|
|
2
|
-
|
|
2
|
+
import constants from "../constants";
|
|
3
|
+
const DEFAULT_OPTIONS = {
|
|
4
|
+
commandDelimiter: '>',
|
|
5
|
+
itemHeight: constants.COMMAND_ITEM_HEIGHT,
|
|
6
|
+
};
|
|
3
7
|
export function initOptions(options, origOptions = null) {
|
|
4
8
|
const opts = {
|
|
5
9
|
...initCommonOptions(options, origOptions),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/model/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/model/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AAGnE,OAAO,SAAS,MAAM,cAAc,CAAC;AAUrC,MAAM,eAAe,GAAqB;IACzC,gBAAgB,EAAE,GAAG;IACrB,UAAU,EAAE,SAAS,CAAC,mBAAmB;CACzC,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,OAA0B,EAAE,cAAuB,IAAI;IAClF,MAAM,IAAI,GAAG;QACZ,GAAG,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC;QAC1C,GAAG,eAAe;QAClB,GAAG,WAAW;QACd,GAAG,OAAO;KACV,CAAC;IAEF,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import { initCommonOptions, CommonOptions } from \"@omegagrid/core\";\nimport { CommandRenderer, GroupRenderer } from \"../ui\";\nimport { CSSResultOrNative } from \"lit\";\nimport constants from \"../constants\";\n\nexport type Options = {\n\tcommandRenderer?: CommandRenderer,\n\tgroupRenderer?: GroupRenderer,\n\tcommandDelimiter?: string,\n\titemStyle?: CSSResultOrNative|string|(CSSResultOrNative|string)[],\n\titemHeight?: number,\n} & CommonOptions;\n\nconst DEFAULT_OPTIONS: Partial<Options> = {\n\tcommandDelimiter: '>',\n\titemHeight: constants.COMMAND_ITEM_HEIGHT,\n};\n\nexport function initOptions(options?: Partial<Options>, origOptions: Options = null): Options {\n\tconst opts = {\n\t\t...initCommonOptions(options, origOptions),\n\t\t...DEFAULT_OPTIONS,\n\t\t...origOptions,\n\t\t...options,\n\t};\n\n\treturn opts;\n}\n"]}
|
|
@@ -1,60 +1,73 @@
|
|
|
1
|
-
import { Commands, Command,
|
|
2
|
-
import {
|
|
1
|
+
import { Commands, Command, CommandGroup, CommandsSection, CommandMode, CommandSource } from "../model";
|
|
2
|
+
import { CommandsAdapter } from "../adapters";
|
|
3
|
+
import { DropdownList, events, List, ListItemRenderer, ListItemRendererOptions, ListSelectEvent } from "@omegagrid/core";
|
|
3
4
|
import { LitElement, TemplateResult, PropertyValues } from 'lit';
|
|
4
|
-
import {
|
|
5
|
+
import { TabEvent } from "@omegagrid/tabs";
|
|
5
6
|
export declare class CommandEvent extends Event {
|
|
6
7
|
readonly command?: Command;
|
|
7
8
|
readonly value?: string;
|
|
9
|
+
readonly section?: CommandsSection;
|
|
8
10
|
constructor(type: string, args?: Partial<CommandEvent>);
|
|
9
11
|
}
|
|
10
|
-
export type CommandRenderer = (div: HTMLDivElement, command: Command) => string | TemplateResult<1> | null;
|
|
11
|
-
export type
|
|
12
|
+
export type CommandRenderer = (div: HTMLDivElement, command: Command, opts?: ListItemRendererOptions) => string | void | TemplateResult<1> | null;
|
|
13
|
+
export type GroupRenderer = (div: HTMLDivElement, group: CommandGroup, opts?: ListItemRendererOptions) => string | void | TemplateResult<1> | null;
|
|
12
14
|
export declare class CommandWindow extends LitElement {
|
|
13
15
|
static styles: import("lit").CSSResult[];
|
|
14
|
-
private inputRef;
|
|
15
|
-
get input(): HTMLInputElement;
|
|
16
|
-
get inputValue(): string;
|
|
17
|
-
private listRef;
|
|
18
|
-
get list(): List;
|
|
19
16
|
private visibleItems;
|
|
20
|
-
options: Options;
|
|
17
|
+
options: import("../model").Options;
|
|
21
18
|
/**
|
|
22
19
|
* search = commands are filtered by input value
|
|
23
20
|
* input = commands are not filtered, input is used to enter custom value
|
|
24
21
|
* none = no input, only command list is shown
|
|
25
22
|
*/
|
|
26
|
-
mode:
|
|
23
|
+
mode: CommandMode;
|
|
27
24
|
value: string;
|
|
25
|
+
sectionPosition: 'top' | 'bottom' | 'left' | 'right';
|
|
28
26
|
text: string;
|
|
29
|
-
commands:
|
|
27
|
+
commands: CommandSource[];
|
|
30
28
|
adapter: CommandsAdapter;
|
|
31
29
|
target: HTMLElement;
|
|
32
|
-
triggerKey: string;
|
|
33
30
|
placeholder: string;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
showGroups: boolean;
|
|
32
|
+
model: Commands;
|
|
33
|
+
sections: CommandsSection[];
|
|
34
|
+
activeSectionIndex: number;
|
|
35
|
+
noResults: boolean;
|
|
36
|
+
list: List;
|
|
37
|
+
input: HTMLInputElement;
|
|
38
|
+
dropdown: DropdownList;
|
|
39
|
+
get activeSection(): CommandsSection;
|
|
40
|
+
get inputValue(): string;
|
|
41
|
+
get parsedInput(): {
|
|
42
|
+
section: number;
|
|
43
|
+
value: string;
|
|
44
|
+
};
|
|
38
45
|
get filterValue(): string;
|
|
39
|
-
|
|
46
|
+
_commandRenderer: CommandRenderer;
|
|
47
|
+
_groupRenderer: GroupRenderer;
|
|
48
|
+
exec(dispatchEvent?: boolean): Promise<void>;
|
|
40
49
|
_onKeyDown: (e: KeyboardEvent) => void;
|
|
41
|
-
|
|
42
|
-
(this: unknown, ...args: [
|
|
50
|
+
_debounceInput: {
|
|
51
|
+
(this: unknown, ...args: [] & any[]): Promise<void>;
|
|
43
52
|
cancel: (reason?: any) => void;
|
|
44
53
|
};
|
|
54
|
+
_onInput: (e: InputEvent) => void;
|
|
55
|
+
_onSectionSelect: (e: TabEvent) => void;
|
|
56
|
+
_onDropdownChange: (e: events.ChangeEvent) => void;
|
|
45
57
|
constructor();
|
|
46
|
-
open(dispatchEvent?: boolean): Promise<void>;
|
|
47
|
-
close(dispatchEvent?: boolean): void;
|
|
48
58
|
connectedCallback(): void;
|
|
49
|
-
|
|
59
|
+
focus(): void;
|
|
60
|
+
clearFilter(updateCommands?: boolean): void;
|
|
50
61
|
willUpdate(props: PropertyValues): Promise<void>;
|
|
51
62
|
updated(props: Map<PropertyKey, unknown>): Promise<void>;
|
|
52
63
|
_onSelect: (e: ListSelectEvent) => void;
|
|
53
64
|
_itemRenderer: ListItemRenderer;
|
|
54
|
-
firstUpdated(): void;
|
|
55
65
|
updateCommands(): Promise<void>;
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
toggleGroup(groupId: string): Promise<void>;
|
|
67
|
+
private getSectionTitle;
|
|
68
|
+
renderTabs: () => "" | TemplateResult<1>;
|
|
69
|
+
renderDropdown: () => "" | TemplateResult<1>;
|
|
70
|
+
renderSwitches: () => "" | TemplateResult<1>;
|
|
58
71
|
render: () => TemplateResult<1>;
|
|
59
72
|
}
|
|
60
73
|
//# sourceMappingURL=commandWindow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandWindow.d.ts","sourceRoot":"","sources":["../../src/ui/commandWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"commandWindow.d.ts","sourceRoot":"","sources":["../../src/ui/commandWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAe,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrH,OAAO,EAAE,eAAe,EAAC,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAU,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,eAAe,EAAqB,MAAM,iBAAiB,CAAC;AACpJ,OAAO,EAAE,UAAU,EAAQ,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAKvE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,qBAAa,YAAa,SAAQ,KAAK;IAEtC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC;gBAEvB,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC;CAItD;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EA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